dbf-udg
annotate 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 |
rev | line source |
---|---|
nuclear@3 | 1 #include <math.h> |
nuclear@3 | 2 #include "opengl.h" |
nuclear@3 | 3 #include "texture.h" |
nuclear@3 | 4 |
nuclear@3 | 5 unsigned int hiero_tex; |
nuclear@3 | 6 |
nuclear@3 | 7 bool init_scroller() |
nuclear@3 | 8 { |
nuclear@3 | 9 if(!(hiero_tex = load_texture("data/hieroglyph2.png"))) { |
nuclear@3 | 10 return false; |
nuclear@3 | 11 } |
nuclear@3 | 12 |
nuclear@3 | 13 glBindTexture(GL_TEXTURE_2D, hiero_tex); |
nuclear@3 | 14 /*glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); |
nuclear@3 | 15 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);*/ |
nuclear@3 | 16 |
nuclear@3 | 17 return true; |
nuclear@3 | 18 } |
nuclear@3 | 19 |
nuclear@3 | 20 void destroy_scroller() |
nuclear@3 | 21 { |
nuclear@3 | 22 free_texture(hiero_tex); |
nuclear@3 | 23 hiero_tex = 0; |
nuclear@3 | 24 } |
nuclear@3 | 25 |
nuclear@3 | 26 void draw_scroller(float sec) |
nuclear@3 | 27 { |
nuclear@3 | 28 glPushAttrib(GL_ENABLE_BIT); |
nuclear@3 | 29 |
nuclear@3 | 30 glDisable(GL_DEPTH_TEST); |
nuclear@3 | 31 glDisable(GL_LIGHTING); |
nuclear@3 | 32 glEnable(GL_TEXTURE_2D); |
nuclear@3 | 33 glBindTexture(GL_TEXTURE_2D, hiero_tex); |
nuclear@3 | 34 |
nuclear@3 | 35 glMatrixMode(GL_MODELVIEW); |
nuclear@3 | 36 glPushMatrix(); |
nuclear@3 | 37 glLoadIdentity(); |
nuclear@3 | 38 glScalef(1.4, 0.4, 1.4); |
nuclear@3 | 39 glMatrixMode(GL_PROJECTION); |
nuclear@3 | 40 glPushMatrix(); |
nuclear@3 | 41 glLoadIdentity(); |
nuclear@3 | 42 glMatrixMode(GL_TEXTURE); |
nuclear@3 | 43 glPushMatrix(); |
nuclear@3 | 44 glLoadIdentity(); |
nuclear@3 | 45 |
nuclear@3 | 46 glTranslatef(sec * 0.25, 0, 0); |
nuclear@3 | 47 |
nuclear@3 | 48 glBegin(GL_QUADS); |
nuclear@3 | 49 glColor3f(1, 1, 1); |
nuclear@3 | 50 glTexCoord2f(0, 1); glVertex2f(-1, -1); |
nuclear@3 | 51 glTexCoord2f(1, 1); glVertex2f(1, -1); |
nuclear@3 | 52 glTexCoord2f(1, 0); glVertex2f(1, 1); |
nuclear@3 | 53 glTexCoord2f(0, 0); glVertex2f(-1, 1); |
nuclear@3 | 54 glEnd(); |
nuclear@3 | 55 |
nuclear@3 | 56 glPopMatrix(); |
nuclear@3 | 57 glMatrixMode(GL_PROJECTION); |
nuclear@3 | 58 glPopMatrix(); |
nuclear@3 | 59 glMatrixMode(GL_MODELVIEW); |
nuclear@3 | 60 glPopMatrix(); |
nuclear@3 | 61 glPopAttrib(); |
nuclear@3 | 62 } |