dungeon_crawler
changeset 29:2fc004802739
lalala
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Sun, 26 Aug 2012 03:39:32 +0300 |
parents | f5fb04fe12cd |
children | 938a6a155c94 |
files | prototype/drawtext/drawgl.c prototype/drawtext/drawtext.h prototype/drawtext/drawtext_impl.h prototype/drawtext/font.c prototype/sdr/deferred_omni.p.glsl prototype/src/cmdcon.cc prototype/src/light.cc prototype/src/main.cc prototype/src/renderer.cc |
diffstat | 9 files changed, 68 insertions(+), 36 deletions(-) [+] |
line diff
1.1 --- a/prototype/drawtext/drawgl.c Sat Aug 25 20:20:56 2012 +0300 1.2 +++ b/prototype/drawtext/drawgl.c Sun Aug 26 03:39:32 2012 +0300 1.3 @@ -1,6 +1,6 @@ 1.4 /* 1.5 libdrawtext - a simple library for fast text rendering in OpenGL 1.6 -Copyright (C) 2011 John Tsiombikas <nuclear@member.fsf.org> 1.7 +Copyright (C) 2011-2012 John Tsiombikas <nuclear@member.fsf.org> 1.8 1.9 This program is free software: you can redistribute it and/or modify 1.10 it under the terms of the GNU Lesser General Public License as published by 1.11 @@ -183,10 +183,17 @@ 1.12 1.13 void dtx_flush(void) 1.14 { 1.15 + int vbo; 1.16 + 1.17 if(!num_quads) { 1.18 return; 1.19 } 1.20 1.21 + if(glBindBuffer) { 1.22 + glGetIntegerv(GL_ARRAY_BUFFER_BINDING, &vbo); 1.23 + glBindBuffer(GL_ARRAY_BUFFER, 0); 1.24 + } 1.25 + 1.26 #ifndef GL_ES 1.27 glPushAttrib(GL_ENABLE_BIT); 1.28 glEnable(GL_TEXTURE_2D); 1.29 @@ -242,6 +249,10 @@ 1.30 glDisable(GL_BLEND); 1.31 #endif 1.32 1.33 + if(glBindBuffer && vbo) { 1.34 + glBindBuffer(GL_ARRAY_BUFFER, vbo); 1.35 + } 1.36 + 1.37 num_quads = 0; 1.38 } 1.39
2.1 --- a/prototype/drawtext/drawtext.h Sat Aug 25 20:20:56 2012 +0300 2.2 +++ b/prototype/drawtext/drawtext.h Sun Aug 26 03:39:32 2012 +0300 2.3 @@ -1,6 +1,6 @@ 2.4 /* 2.5 libdrawtext - a simple library for fast text rendering in OpenGL 2.6 -Copyright (C) 2011 John Tsiombikas <nuclear@member.fsf.org> 2.7 +Copyright (C) 2011-2012 John Tsiombikas <nuclear@member.fsf.org> 2.8 2.9 This program is free software: you can redistribute it and/or modify 2.10 it under the terms of the GNU Lesser General Public License as published by 2.11 @@ -153,6 +153,7 @@ 2.12 2.13 2.14 /* ---- metrics ---- */ 2.15 +float dtx_line_height(void); 2.16 2.17 /* rendered dimensions of a single glyph */ 2.18 void dtx_glyph_box(int code, struct dtx_box *box);
3.1 --- a/prototype/drawtext/drawtext_impl.h Sat Aug 25 20:20:56 2012 +0300 3.2 +++ b/prototype/drawtext/drawtext_impl.h Sun Aug 26 03:39:32 2012 +0300 3.3 @@ -1,6 +1,6 @@ 3.4 /* 3.5 libdrawtext - a simple library for fast text rendering in OpenGL 3.6 -Copyright (C) 2011 John Tsiombikas <nuclear@member.fsf.org> 3.7 +Copyright (C) 2011-2012 John Tsiombikas <nuclear@member.fsf.org> 3.8 3.9 This program is free software: you can redistribute it and/or modify 3.10 it under the terms of the GNU Lesser General Public License as published by
4.1 --- a/prototype/drawtext/font.c Sat Aug 25 20:20:56 2012 +0300 4.2 +++ b/prototype/drawtext/font.c Sun Aug 26 03:39:32 2012 +0300 4.3 @@ -477,6 +477,13 @@ 4.4 dtx_font_sz = sz; 4.5 } 4.6 4.7 +float dtx_line_height(void) 4.8 +{ 4.9 + struct dtx_glyphmap *gmap = dtx_get_font_glyphmap(dtx_font, dtx_font_sz, '\n'); 4.10 + 4.11 + return gmap->line_advance; 4.12 +} 4.13 + 4.14 void dtx_glyph_box(int code, struct dtx_box *box) 4.15 { 4.16 int cidx;
5.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 5.2 +++ b/prototype/sdr/deferred_omni.p.glsl Sun Aug 26 03:39:32 2012 +0300 5.3 @@ -0,0 +1,20 @@ 5.4 +uniform sampler2D mrt0, mrt1, mrt2, mrt3; 5.5 +uniform vec2 tex_scale; 5.6 + 5.7 +void main() 5.8 +{ 5.9 + vec2 tc = gl_TexCoord[0].st; 5.10 + 5.11 + vec4 texel; 5.12 + if(tc.x < 0.25) { 5.13 + texel = texture2D(mrt0, tc * vec2(4.0, 1.0) * tex_scale); 5.14 + } else if(tc.x < 0.5) { 5.15 + texel = texture2D(mrt1, (tc - vec2(0.25, 0.0)) * vec2(4.0, 1.0) * tex_scale); 5.16 + } else if(tc.x < 0.75) { 5.17 + texel = texture2D(mrt2, (tc - vec2(0.5, 0.0)) * vec2(4.0, 1.0) * tex_scale); 5.18 + } else { 5.19 + texel = texture2D(mrt3, (tc - vec2(0.75, 0.0)) * vec2(4.0, 1.0) * tex_scale); 5.20 + } 5.21 + 5.22 + gl_FragColor = texel; 5.23 +}
6.1 --- a/prototype/src/cmdcon.cc Sat Aug 25 20:20:56 2012 +0300 6.2 +++ b/prototype/src/cmdcon.cc Sun Aug 26 03:39:32 2012 +0300 6.3 @@ -26,11 +26,11 @@ 6.4 } 6.5 6.6 printf("loading font: %s\n", path); 6.7 - if(!(font = dtx_open_font(path, 12))) { 6.8 + if(!(font = dtx_open_font(path, 14))) { 6.9 fprintf(stderr, "failed to open font file: %s\n", path); 6.10 return false; 6.11 } 6.12 - dtx_use_font(font, 12); 6.13 + dtx_use_font(font, 14); 6.14 return true; 6.15 } 6.16 6.17 @@ -72,20 +72,16 @@ 6.18 6.19 void draw_cmdcon() 6.20 { 6.21 - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 6.22 - 6.23 glMatrixMode(GL_PROJECTION); 6.24 glPushMatrix(); 6.25 glLoadIdentity(); 6.26 - //glOrtho(0, cfg.width, cfg.height, 0, -1, 1); 6.27 - glOrtho(-cfg.width / 2.0, cfg.width / 2.0, -cfg.height / 2.0, cfg.height / 2.0, -1, 1); 6.28 + glOrtho(0, cfg.width, cfg.height, 0, -1, 1); 6.29 glMatrixMode(GL_MODELVIEW); 6.30 glPushMatrix(); 6.31 glLoadIdentity(); 6.32 6.33 - //glTranslatef(100, 100, 0); 6.34 - 6.35 - glPushAttrib(GL_ENABLE_BIT | GL_CURRENT_BIT); 6.36 + glPushAttrib(GL_ENABLE_BIT | GL_CURRENT_BIT | GL_POLYGON_BIT); 6.37 + glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); 6.38 glUseProgram(0); 6.39 glDisable(GL_DEPTH_TEST); 6.40 glDisable(GL_LIGHTING); 6.41 @@ -94,13 +90,16 @@ 6.42 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); 6.43 6.44 glBegin(GL_QUADS); 6.45 - glColor4f(0.4, 0.4, 0.4, 0.5); 6.46 - glVertex2f(-10, -10); 6.47 - glVertex2f(10, -10); 6.48 - glVertex2f(10, 10); 6.49 - glVertex2f(-10, 10); 6.50 + glColor4f(0.2, 0.2, 0.2, 0.6); 6.51 + glVertex2f(0, 0); 6.52 + glVertex2f(0, dtx_line_height() * 1.5); 6.53 + glVertex2f(cfg.width, dtx_line_height() * 1.5); 6.54 + glVertex2f(cfg.width, 0); 6.55 glEnd(); 6.56 6.57 + glTranslatef(0, dtx_line_height(), 0); 6.58 + glScalef(1, -1, 1); 6.59 + 6.60 glColor4f(0.2, 0.9, 0.3, 1.0); 6.61 dtx_string(cmdline.c_str()); 6.62 dtx_flush();
7.1 --- a/prototype/src/light.cc Sat Aug 25 20:20:56 2012 +0300 7.2 +++ b/prototype/src/light.cc Sun Aug 26 03:39:32 2012 +0300 7.3 @@ -108,13 +108,14 @@ 7.4 7.5 void PointLight::draw() const 7.6 { 7.7 - //glMatrixMode(GL_MODELVIEW); 7.8 - //glPushMatrix(); 7.9 - //glScalef(radius, radius, radius); 7.10 + glMatrixMode(GL_MODELVIEW); 7.11 + glPushMatrix(); 7.12 + glTranslatef(pos.x, pos.y, pos.z); 7.13 + glScalef(radius, radius, radius); 7.14 7.15 Light::draw(); 7.16 7.17 - //glPopMatrix(); 7.18 + glPopMatrix(); 7.19 } 7.20 7.21 7.22 @@ -155,13 +156,13 @@ 7.23 for(int j=0; j<udiv; j++) { 7.24 float u = (float)j / (float)udiv; 7.25 7.26 + *vptr++ = sphvertex(u, v + dv); 7.27 + *vptr++ = sphvertex(u + du, v); 7.28 *vptr++ = sphvertex(u, v); 7.29 + 7.30 + *vptr++ = sphvertex(u, v + dv); 7.31 + *vptr++ = sphvertex(u + du, v + dv); 7.32 *vptr++ = sphvertex(u + du, v); 7.33 - *vptr++ = sphvertex(u, v + dv); 7.34 - 7.35 - *vptr++ = sphvertex(u + du, v); 7.36 - *vptr++ = sphvertex(u + du, v + dv); 7.37 - *vptr++ = sphvertex(u, v + dv); 7.38 } 7.39 } 7.40 glUnmapBuffer(GL_ARRAY_BUFFER);
8.1 --- a/prototype/src/main.cc Sat Aug 25 20:20:56 2012 +0300 8.2 +++ b/prototype/src/main.cc Sun Aug 26 03:39:32 2012 +0300 8.3 @@ -169,7 +169,9 @@ 8.4 8.5 void draw() 8.6 { 8.7 - //render_deferred(level); 8.8 + glClear(GL_COLOR_BUFFER_BIT); 8.9 + 8.10 + render_deferred(level); 8.11 8.12 if(show_con) { 8.13 draw_cmdcon();
9.1 --- a/prototype/src/renderer.cc Sat Aug 25 20:20:56 2012 +0300 9.2 +++ b/prototype/src/renderer.cc Sun Aug 26 03:39:32 2012 +0300 9.3 @@ -124,13 +124,6 @@ 9.4 9.5 void render_deferred(const Level *level) 9.6 { 9.7 - glClearColor(0.4, 0.2, 0.1, 0.0); 9.8 - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 9.9 - glPushAttrib(GL_ENABLE_BIT); 9.10 - glDisable(GL_LIGHTING); 9.11 - level->draw_lights(); 9.12 - glPopAttrib(); 9.13 -#if 0 9.14 // render into the MRT buffers 9.15 glUseProgram(mrt_prog); 9.16 glBindFramebufferEXT(GL_FRAMEBUFFER, fbo); 9.17 @@ -145,7 +138,6 @@ 9.18 glPushAttrib(GL_ENABLE_BIT); 9.19 9.20 glDisable(GL_LIGHTING); 9.21 - glDisable(GL_DEPTH_TEST); 9.22 9.23 glUseProgram(deferred_omni); 9.24 for(int i=0; i<MRT_COUNT; i++) { 9.25 @@ -165,7 +157,6 @@ 9.26 9.27 glUseProgram(0); 9.28 glPopAttrib(); 9.29 -#endif 9.30 } 9.31 9.32 static bool create_fbo(int xsz, int ysz)