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; uniform sampler2D fontBitmap;
void main() { void main() {
vec4 outColor = texture(fontBitmap, texCoords); /*vec4 outColor = texture(fontBitmap, texCoords);
if(outColor.xyz == vec3(0.0, 0.0, 0.0)) if(outColor.xyz == vec3(0.0, 0.0, 0.0))
discard; discard;*/
//fragColor = fontColor * vec4(0, 1, 0, 1); //fragColor = fontColor * vec4(0, 1, 0, 1);
fragColor = vec4(0, 1, 0, 1); fragColor = vec4(0, 1, 0, 1);

View file

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

View file

@ -54,11 +54,6 @@ int main(int argc, char* argv[]) {
return -1; return -1;
#endif #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_init_subsystem(window);
ui::Font scapeFont( ui::Font scapeFont(
SOSC_RESC("fonts/scape.bmp"), SOSC_RESC("fonts/scape.bmp"),
@ -71,16 +66,15 @@ int main(int argc, char* argv[]) {
glDisable(GL_CULL_FACE); glDisable(GL_CULL_FACE);
glDisable(GL_DEPTH_TEST); glDisable(GL_DEPTH_TEST);
bool running = true; bool running = true;
while(running) { while(running) {
SDL_GL_SwapWindow(window);
glClear(GL_COLOR_BUFFER_BIT); glClear(GL_COLOR_BUFFER_BIT);
glClearColor(1, 1, 1, 1); glClearColor(1, 1, 1, 1);
text.Render(); text.Render();
SDL_GL_SwapWindow(window);
SDL_Event event; SDL_Event event;
while(SDL_PollEvent(&event)) { while(SDL_PollEvent(&event)) {
if(event.type == SDL_QUIT) if(event.type == SDL_QUIT)

View file

@ -6,10 +6,19 @@
((((uint32_t)(X)[(N)+2])) << 16u) | \ ((((uint32_t)(X)[(N)+2])) << 16u) | \
((((uint32_t)(X)[(N)+3])) << 24u)) ((((uint32_t)(X)[(N)+3])) << 24u))
// FONT SHADER CLASS //
namespace sosc { namespace sosc {
namespace ui { 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 { class FontShader : public sosc::shdr::Shader {
public: public:
enum Uniforms { enum Uniforms {
@ -24,9 +33,10 @@ public:
int width, height; int width, height;
SDL_GetWindowSize(window, &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( 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(); this->Stop();
@ -52,18 +62,12 @@ protected:
}; };
}} }}
// STATE STRUCT //
static struct {
sosc::ui::FontShader shader;
sosc::ui::Font* default_font;
} _font_ctx;
// SUBSYSTEM FUNCS // // SUBSYSTEM FUNCS //
void sosc::ui::font_init_subsystem(SDL_Window* window) { void sosc::ui::font_init_subsystem(SDL_Window* window) {
_font_ctx.shader.Load(); _font_ctx.shader = new FontShader();
_font_ctx.shader.UpdateWindow(window); _font_ctx.shader->Load();
_font_ctx.shader->UpdateWindow(window);
_font_ctx.default_font = nullptr; _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) { 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() { void sosc::ui::font_deinit_subsystem() {
_font_ctx.shader.Unload(); _font_ctx.shader->Unload();
delete _font_ctx.shader;
} }
// FONT CLASS // // FONT CLASS //
@ -255,9 +260,9 @@ void sosc::ui::Text::SetWrapWidth(uint32_t w) {
} }
void sosc::ui::Text::Render() { void sosc::ui::Text::Render() {
auto shdr = &_font_ctx.shader; auto shdr = _font_ctx.shader;
_font_ctx.shader.Start(); shdr->Start();
glUniformMatrix4fv( glUniformMatrix4fv(
(*shdr)[shdr->TRANSLATION_MATRIX], (*shdr)[shdr->TRANSLATION_MATRIX],
1, GL_FALSE, 1, GL_FALSE,
@ -277,7 +282,7 @@ void sosc::ui::Text::Render() {
glBindVertexArray(0); glBindVertexArray(0);
this->font->UnbindBitmap(); this->font->UnbindBitmap();
_font_ctx.shader.Stop(); shdr->Stop();
} }
void sosc::ui::Text::Destroy() { void sosc::ui::Text::Destroy() {
@ -308,6 +313,14 @@ void sosc::ui::Text::Redraw() {
top_y += height; 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 /// /// TRIANGLE 1 ///
// TOP LEFT // TOP LEFT
this->vertices[i*12] = top_x; this->vertices[i*12] = top_x;

View file

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