X-Git-Url: https://git.ucc.asn.au/?p=ipdf%2Fcode.git;a=blobdiff_plain;f=src%2Fscreen.cpp;h=5bca5544dc9042a04f051265b66ec56339397b81;hp=2d63bc945d85740b3fb579f1ab7df09507916fb7;hb=433bde2ed090928b264203c9f422a5b220857120;hpb=280f0d7d34b9bd377fb49580b69aebcbd60cc440 diff --git a/src/screen.cpp b/src/screen.cpp index 2d63bc9..5bca554 100644 --- a/src/screen.cpp +++ b/src/screen.cpp @@ -8,47 +8,8 @@ #include "bufferbuilder.h" #include "shaderprogram.h" -#define BASICTEX_VERT \ - "#version 140\n"\ - "#extension GL_ARB_shading_language_420pack : require\n"\ - "#extension GL_ARB_explicit_attrib_location : require\n"\ - "\n"\ - "layout(std140, binding=0) uniform Viewport\n"\ - "{\n"\ - "\tfloat width;\n"\ - "\tfloat height;\n"\ - "};\n"\ - "\n"\ - "layout(location = 0) in vec2 position;\n"\ - "layout(location = 1) in vec2 tex_coord;\n"\ - "\n"\ - "out vec2 fp_tex_coord;\n"\ - "\n"\ - "void main()\n"\ - "{\n"\ - "\t// Transform to clip coordinates (-1,1, -1,1).\n"\ - "\tgl_Position.x = (position.x*2/width) - 1;\n"\ - "\tgl_Position.y = 1 - (position.y*2/height);\n"\ - "\tgl_Position.z = 0.0;\n"\ - "\tgl_Position.w = 1.0;\n"\ - "\tfp_tex_coord = tex_coord;\n"\ - "}\n" - -#define BASICTEX_FRAG \ - "#version 140\n"\ - "\n"\ - "in vec2 fp_tex_coord;\n"\ - "\n"\ - "out vec4 output_colour;\n"\ - "\n"\ - "uniform sampler2D tex;\n"\ - "uniform vec4 colour;\n"\ - "\n"\ - "void main()\n"\ - "{\n"\ - "\toutput_colour = colour;\n"\ - "\toutput_colour.a = texture(tex, fp_tex_coord).r;\n"\ - "}\n" +#define BASICTEX_VERT "shaders/basictex_vert.glsl" +#define BASICTEX_FRAG "shaders/basictex_frag.glsl" using namespace IPDF; using namespace std; @@ -309,7 +270,7 @@ void Screen::RenderBMP(const char * filename) const int w = bmp->w; int h = bmp->h; - GLenum texture_format; + GLenum texture_format = GL_RGBA; switch (bmp->format->BytesPerPixel) { case 4: //contains alpha @@ -425,6 +386,8 @@ void Screen::DebugFontFlush() glDisable(GL_BLEND); + m_debug_font_vertices.Invalidate(); + m_debug_font_indices.Invalidate(); m_debug_font_vertex_head = 0; m_debug_font_index_head = 0; } @@ -451,7 +414,7 @@ void Screen::DebugFontPrint(const char* str) DebugFontPrint(str); return; } - if (*str >= 32 && *str < 128) { + if (*str >= 32 && (unsigned char)(*str) < 128) { stbtt_aligned_quad q; stbtt_GetBakedQuad(m_debug_font_rects, 1024,1024, *str-32, &m_debug_font_x,&m_debug_font_y,&q,1); size_t index = vertexData.Add({q.x0, q.y0, q.s0, q.t0});