godly boob located

This commit is contained in:
malloc 2018-08-31 10:07:11 -05:00
parent c76e9bbade
commit 8f1662e862
5 changed files with 39 additions and 30 deletions

View file

@ -6,9 +6,9 @@ uniform vec4 fontColor;
uniform sampler2D fontBitmap;
void main() {
vec4 outColor = texture(fontBitmap, texCoords);
/*vec4 outColor = texture(fontBitmap, texCoords);
if(outColor.xyz == vec3(0.0, 0.0, 0.0))
discard;
discard;*/
//fragColor = fontColor * vec4(0, 1, 0, 1);
fragColor = vec4(0, 1, 0, 1);

View file

@ -8,6 +8,6 @@ uniform mat4 transMatrix;
uniform mat4 orthoMatrix;
void main() {
gl_Position = orthoMatrix * vec4(aScreenCoords, 0.0, 1.0);
gl_Position = orthoMatrix * vec4(aScreenCoords, 1.0, 1.0);
texCoords = aTexCoords;
}

View file

@ -54,11 +54,6 @@ int main(int argc, char* argv[]) {
return -1;
#endif
auto a = glGetString(GL_VENDOR);
auto b = glGetString(GL_RENDERER);
auto c = glGetString(GL_VERSION);
auto d = glGetString(GL_SHADING_LANGUAGE_VERSION);
ui::font_init_subsystem(window);
ui::Font scapeFont(
SOSC_RESC("fonts/scape.bmp"),
@ -71,16 +66,15 @@ int main(int argc, char* argv[]) {
glDisable(GL_CULL_FACE);
glDisable(GL_DEPTH_TEST);
bool running = true;
while(running) {
SDL_GL_SwapWindow(window);
glClear(GL_COLOR_BUFFER_BIT);
glClearColor(1, 1, 1, 1);
text.Render();
SDL_GL_SwapWindow(window);
SDL_Event event;
while(SDL_PollEvent(&event)) {
if(event.type == SDL_QUIT)

View file

@ -6,10 +6,19 @@
((((uint32_t)(X)[(N)+2])) << 16u) | \
((((uint32_t)(X)[(N)+3])) << 24u))
// FONT SHADER CLASS //
namespace sosc {
namespace ui {
// STATE STRUCT //
class FontShader;
static struct {
sosc::ui::FontShader* shader;
sosc::ui::Font* default_font;
glm::mat4 orthoMatrix;
} _font_ctx;
// FONT SHADER CLASS //
class FontShader : public sosc::shdr::Shader {
public:
enum Uniforms {
@ -24,9 +33,10 @@ public:
int width, height;
SDL_GetWindowSize(window, &width, &height);
glm::mat4 orthoMatrix = glm::ortho(0, width, height, 0);
_font_ctx.orthoMatrix = glm::ortho(0, width, height, 0);
glUniformMatrix4fv(
(*this)[ORTHO_MATRIX], 1, GL_FALSE, glm::value_ptr(orthoMatrix)
(*this)[ORTHO_MATRIX], 1, GL_FALSE,
glm::value_ptr(_font_ctx.orthoMatrix)
);
this->Stop();
@ -52,18 +62,12 @@ protected:
};
}}
// STATE STRUCT //
static struct {
sosc::ui::FontShader shader;
sosc::ui::Font* default_font;
} _font_ctx;
// SUBSYSTEM FUNCS //
void sosc::ui::font_init_subsystem(SDL_Window* window) {
_font_ctx.shader.Load();
_font_ctx.shader.UpdateWindow(window);
_font_ctx.shader = new FontShader();
_font_ctx.shader->Load();
_font_ctx.shader->UpdateWindow(window);
_font_ctx.default_font = nullptr;
}
@ -72,11 +76,12 @@ void sosc::ui::font_set_default(Font *font) {
}
void sosc::ui::font_window_changed(SDL_Window* window) {
_font_ctx.shader.UpdateWindow(window);
_font_ctx.shader->UpdateWindow(window);
}
void sosc::ui::font_deinit_subsystem() {
_font_ctx.shader.Unload();
_font_ctx.shader->Unload();
delete _font_ctx.shader;
}
// FONT CLASS //
@ -255,9 +260,9 @@ void sosc::ui::Text::SetWrapWidth(uint32_t w) {
}
void sosc::ui::Text::Render() {
auto shdr = &_font_ctx.shader;
auto shdr = _font_ctx.shader;
_font_ctx.shader.Start();
shdr->Start();
glUniformMatrix4fv(
(*shdr)[shdr->TRANSLATION_MATRIX],
1, GL_FALSE,
@ -277,7 +282,7 @@ void sosc::ui::Text::Render() {
glBindVertexArray(0);
this->font->UnbindBitmap();
_font_ctx.shader.Stop();
shdr->Stop();
}
void sosc::ui::Text::Destroy() {
@ -308,6 +313,14 @@ void sosc::ui::Text::Redraw() {
top_y += height;
}
glm::vec4 result =
_font_ctx.orthoMatrix * glm::vec4(320.f, 240.f, 0.f, 1.f);
std::cout << "(" << result.x << "," << result.y
<< "," << result.z << "," << result.w << ")" << std::endl;
auto test = glm::to_string(_font_ctx.orthoMatrix);
std::cout << test << std::endl;
/// TRIANGLE 1 ///
// TOP LEFT
this->vertices[i*12] = top_x;

View file

@ -6,11 +6,13 @@
#include <GLM/glm.hpp>
#include <GLM/gtc/matrix_transform.hpp>
#include <GLM/gtc/type_ptr.hpp>
#define GLM_ENABLE_EXPERIMENTAL
#include <GLM/gtx/string_cast.hpp>
#include <SDL_image.h>
#include <string>
#include <fstream>
#include "utils/net.hpp"
#include <iostream>
#include "shaders/_shader.hpp"
namespace sosc {