dbf-udg
diff src/scroller.cc @ 3:403ec1be3a1a
foo
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Fri, 11 Jan 2013 22:52:56 +0200 |
parents | |
children | 5fb21401b7c8 |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/src/scroller.cc Fri Jan 11 22:52:56 2013 +0200 1.3 @@ -0,0 +1,62 @@ 1.4 +#include <math.h> 1.5 +#include "opengl.h" 1.6 +#include "texture.h" 1.7 + 1.8 +unsigned int hiero_tex; 1.9 + 1.10 +bool init_scroller() 1.11 +{ 1.12 + if(!(hiero_tex = load_texture("data/hieroglyph2.png"))) { 1.13 + return false; 1.14 + } 1.15 + 1.16 + glBindTexture(GL_TEXTURE_2D, hiero_tex); 1.17 + /*glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); 1.18 + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);*/ 1.19 + 1.20 + return true; 1.21 +} 1.22 + 1.23 +void destroy_scroller() 1.24 +{ 1.25 + free_texture(hiero_tex); 1.26 + hiero_tex = 0; 1.27 +} 1.28 + 1.29 +void draw_scroller(float sec) 1.30 +{ 1.31 + glPushAttrib(GL_ENABLE_BIT); 1.32 + 1.33 + glDisable(GL_DEPTH_TEST); 1.34 + glDisable(GL_LIGHTING); 1.35 + glEnable(GL_TEXTURE_2D); 1.36 + glBindTexture(GL_TEXTURE_2D, hiero_tex); 1.37 + 1.38 + glMatrixMode(GL_MODELVIEW); 1.39 + glPushMatrix(); 1.40 + glLoadIdentity(); 1.41 + glScalef(1.4, 0.4, 1.4); 1.42 + glMatrixMode(GL_PROJECTION); 1.43 + glPushMatrix(); 1.44 + glLoadIdentity(); 1.45 + glMatrixMode(GL_TEXTURE); 1.46 + glPushMatrix(); 1.47 + glLoadIdentity(); 1.48 + 1.49 + glTranslatef(sec * 0.25, 0, 0); 1.50 + 1.51 + glBegin(GL_QUADS); 1.52 + glColor3f(1, 1, 1); 1.53 + glTexCoord2f(0, 1); glVertex2f(-1, -1); 1.54 + glTexCoord2f(1, 1); glVertex2f(1, -1); 1.55 + glTexCoord2f(1, 0); glVertex2f(1, 1); 1.56 + glTexCoord2f(0, 0); glVertex2f(-1, 1); 1.57 + glEnd(); 1.58 + 1.59 + glPopMatrix(); 1.60 + glMatrixMode(GL_PROJECTION); 1.61 + glPopMatrix(); 1.62 + glMatrixMode(GL_MODELVIEW); 1.63 + glPopMatrix(); 1.64 + glPopAttrib(); 1.65 +}