# HG changeset patch # User John Tsiombikas # Date 1345941572 -10800 # Node ID 2fc0048027395e12cd7200e043ac6f8d690737d5 # Parent f5fb04fe12cdc8a7a25e39d63da19bca2a8195d5 lalala diff -r f5fb04fe12cd -r 2fc004802739 prototype/drawtext/drawgl.c --- a/prototype/drawtext/drawgl.c Sat Aug 25 20:20:56 2012 +0300 +++ b/prototype/drawtext/drawgl.c Sun Aug 26 03:39:32 2012 +0300 @@ -1,6 +1,6 @@ /* libdrawtext - a simple library for fast text rendering in OpenGL -Copyright (C) 2011 John Tsiombikas +Copyright (C) 2011-2012 John Tsiombikas This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by @@ -183,10 +183,17 @@ void dtx_flush(void) { + int vbo; + if(!num_quads) { return; } + if(glBindBuffer) { + glGetIntegerv(GL_ARRAY_BUFFER_BINDING, &vbo); + glBindBuffer(GL_ARRAY_BUFFER, 0); + } + #ifndef GL_ES glPushAttrib(GL_ENABLE_BIT); glEnable(GL_TEXTURE_2D); @@ -242,6 +249,10 @@ glDisable(GL_BLEND); #endif + if(glBindBuffer && vbo) { + glBindBuffer(GL_ARRAY_BUFFER, vbo); + } + num_quads = 0; } diff -r f5fb04fe12cd -r 2fc004802739 prototype/drawtext/drawtext.h --- a/prototype/drawtext/drawtext.h Sat Aug 25 20:20:56 2012 +0300 +++ b/prototype/drawtext/drawtext.h Sun Aug 26 03:39:32 2012 +0300 @@ -1,6 +1,6 @@ /* libdrawtext - a simple library for fast text rendering in OpenGL -Copyright (C) 2011 John Tsiombikas +Copyright (C) 2011-2012 John Tsiombikas This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by @@ -153,6 +153,7 @@ /* ---- metrics ---- */ +float dtx_line_height(void); /* rendered dimensions of a single glyph */ void dtx_glyph_box(int code, struct dtx_box *box); diff -r f5fb04fe12cd -r 2fc004802739 prototype/drawtext/drawtext_impl.h --- a/prototype/drawtext/drawtext_impl.h Sat Aug 25 20:20:56 2012 +0300 +++ b/prototype/drawtext/drawtext_impl.h Sun Aug 26 03:39:32 2012 +0300 @@ -1,6 +1,6 @@ /* libdrawtext - a simple library for fast text rendering in OpenGL -Copyright (C) 2011 John Tsiombikas +Copyright (C) 2011-2012 John Tsiombikas This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by diff -r f5fb04fe12cd -r 2fc004802739 prototype/drawtext/font.c --- a/prototype/drawtext/font.c Sat Aug 25 20:20:56 2012 +0300 +++ b/prototype/drawtext/font.c Sun Aug 26 03:39:32 2012 +0300 @@ -477,6 +477,13 @@ dtx_font_sz = sz; } +float dtx_line_height(void) +{ + struct dtx_glyphmap *gmap = dtx_get_font_glyphmap(dtx_font, dtx_font_sz, '\n'); + + return gmap->line_advance; +} + void dtx_glyph_box(int code, struct dtx_box *box) { int cidx; diff -r f5fb04fe12cd -r 2fc004802739 prototype/sdr/deferred_omni.p.glsl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/prototype/sdr/deferred_omni.p.glsl Sun Aug 26 03:39:32 2012 +0300 @@ -0,0 +1,20 @@ +uniform sampler2D mrt0, mrt1, mrt2, mrt3; +uniform vec2 tex_scale; + +void main() +{ + vec2 tc = gl_TexCoord[0].st; + + vec4 texel; + if(tc.x < 0.25) { + texel = texture2D(mrt0, tc * vec2(4.0, 1.0) * tex_scale); + } else if(tc.x < 0.5) { + texel = texture2D(mrt1, (tc - vec2(0.25, 0.0)) * vec2(4.0, 1.0) * tex_scale); + } else if(tc.x < 0.75) { + texel = texture2D(mrt2, (tc - vec2(0.5, 0.0)) * vec2(4.0, 1.0) * tex_scale); + } else { + texel = texture2D(mrt3, (tc - vec2(0.75, 0.0)) * vec2(4.0, 1.0) * tex_scale); + } + + gl_FragColor = texel; +} diff -r f5fb04fe12cd -r 2fc004802739 prototype/src/cmdcon.cc --- a/prototype/src/cmdcon.cc Sat Aug 25 20:20:56 2012 +0300 +++ b/prototype/src/cmdcon.cc Sun Aug 26 03:39:32 2012 +0300 @@ -26,11 +26,11 @@ } printf("loading font: %s\n", path); - if(!(font = dtx_open_font(path, 12))) { + if(!(font = dtx_open_font(path, 14))) { fprintf(stderr, "failed to open font file: %s\n", path); return false; } - dtx_use_font(font, 12); + dtx_use_font(font, 14); return true; } @@ -72,20 +72,16 @@ void draw_cmdcon() { - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - glMatrixMode(GL_PROJECTION); glPushMatrix(); glLoadIdentity(); - //glOrtho(0, cfg.width, cfg.height, 0, -1, 1); - glOrtho(-cfg.width / 2.0, cfg.width / 2.0, -cfg.height / 2.0, cfg.height / 2.0, -1, 1); + glOrtho(0, cfg.width, cfg.height, 0, -1, 1); glMatrixMode(GL_MODELVIEW); glPushMatrix(); glLoadIdentity(); - //glTranslatef(100, 100, 0); - - glPushAttrib(GL_ENABLE_BIT | GL_CURRENT_BIT); + glPushAttrib(GL_ENABLE_BIT | GL_CURRENT_BIT | GL_POLYGON_BIT); + glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); glUseProgram(0); glDisable(GL_DEPTH_TEST); glDisable(GL_LIGHTING); @@ -94,13 +90,16 @@ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glBegin(GL_QUADS); - glColor4f(0.4, 0.4, 0.4, 0.5); - glVertex2f(-10, -10); - glVertex2f(10, -10); - glVertex2f(10, 10); - glVertex2f(-10, 10); + glColor4f(0.2, 0.2, 0.2, 0.6); + glVertex2f(0, 0); + glVertex2f(0, dtx_line_height() * 1.5); + glVertex2f(cfg.width, dtx_line_height() * 1.5); + glVertex2f(cfg.width, 0); glEnd(); + glTranslatef(0, dtx_line_height(), 0); + glScalef(1, -1, 1); + glColor4f(0.2, 0.9, 0.3, 1.0); dtx_string(cmdline.c_str()); dtx_flush(); diff -r f5fb04fe12cd -r 2fc004802739 prototype/src/light.cc --- a/prototype/src/light.cc Sat Aug 25 20:20:56 2012 +0300 +++ b/prototype/src/light.cc Sun Aug 26 03:39:32 2012 +0300 @@ -108,13 +108,14 @@ void PointLight::draw() const { - //glMatrixMode(GL_MODELVIEW); - //glPushMatrix(); - //glScalef(radius, radius, radius); + glMatrixMode(GL_MODELVIEW); + glPushMatrix(); + glTranslatef(pos.x, pos.y, pos.z); + glScalef(radius, radius, radius); Light::draw(); - //glPopMatrix(); + glPopMatrix(); } @@ -155,13 +156,13 @@ for(int j=0; jdraw_lights(); - glPopAttrib(); -#if 0 // render into the MRT buffers glUseProgram(mrt_prog); glBindFramebufferEXT(GL_FRAMEBUFFER, fbo); @@ -145,7 +138,6 @@ glPushAttrib(GL_ENABLE_BIT); glDisable(GL_LIGHTING); - glDisable(GL_DEPTH_TEST); glUseProgram(deferred_omni); for(int i=0; i