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