1 | |
---|
2 | |
---|
3 | /* |
---|
4 | orxonox - the future of 3D-vertical-scrollers |
---|
5 | |
---|
6 | Copyright (C) 2004 orx |
---|
7 | |
---|
8 | This program is free software; you can redistribute it and/or modify |
---|
9 | it under the terms of the GNU General Public License as published by |
---|
10 | the Free Software Foundation; either version 2, or (at your option) |
---|
11 | any later version. |
---|
12 | |
---|
13 | ### File Specific: |
---|
14 | main-programmer: Patrick Boenzli |
---|
15 | co-programmer: |
---|
16 | */ |
---|
17 | |
---|
18 | |
---|
19 | #include "glmenu_imagescreen.h" |
---|
20 | #include "importer/texture.h" |
---|
21 | |
---|
22 | using namespace std; |
---|
23 | |
---|
24 | |
---|
25 | /** |
---|
26 | \brief standard constructor |
---|
27 | |
---|
28 | \todo this constructor is not jet implemented - do it |
---|
29 | */ |
---|
30 | GLMenuImageScreen::GLMenuImageScreen () |
---|
31 | { |
---|
32 | this->setClassName ("GLMenuImageScreen"); |
---|
33 | } |
---|
34 | |
---|
35 | |
---|
36 | /** |
---|
37 | \brief standard deconstructor |
---|
38 | |
---|
39 | \todo this deconstructor is not jet implemented - do it |
---|
40 | */ |
---|
41 | GLMenuImageScreen::~GLMenuImageScreen () {} |
---|
42 | |
---|
43 | |
---|
44 | /** |
---|
45 | \brief function to init the screen |
---|
46 | */ |
---|
47 | void GLMenuImageScreen::init () |
---|
48 | { |
---|
49 | /* |
---|
50 | int w = 680; |
---|
51 | int h = 480; |
---|
52 | |
---|
53 | glViewport(0,0,w,h); |
---|
54 | |
---|
55 | glMatrixMode(GL_PROJECTION); |
---|
56 | glLoadIdentity(); |
---|
57 | gluPerspective(45.0f,(GLfloat)w/(GLfloat)h, .5f ,150.0f); |
---|
58 | glMatrixMode(GL_MODELVIEW); |
---|
59 | |
---|
60 | this->backTex = new Texture(); |
---|
61 | this->backTex->loadImage("orx_tex.bmp"); |
---|
62 | |
---|
63 | glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); |
---|
64 | glLoadIdentity(); |
---|
65 | gluLookAt(0, 0, 6, 0, 0, 0, 0, 1, 0); |
---|
66 | |
---|
67 | // Bind the texture stored at the zero index of g_Texture[] |
---|
68 | //glBindTexture(GL_TEXTURE_2D, g_Texture[0]); |
---|
69 | */ |
---|
70 | |
---|
71 | int e_bnd=0,b0=0,BANDS=64,j=0,k=0; // 0 = 32 band and 1 = 64 band. |
---|
72 | int red,green,blue,alpha=100; |
---|
73 | |
---|
74 | float vuX,vuY; |
---|
75 | long x; |
---|
76 | float gap=7.915f; // for default |
---|
77 | double equVal,y1=0; |
---|
78 | float AV_peak_falloff = 0.8f; // Spead the Peaks fall. |
---|
79 | |
---|
80 | int n; |
---|
81 | |
---|
82 | // Screen Size. |
---|
83 | int screen_width = 640; |
---|
84 | int screen_height = 480; |
---|
85 | |
---|
86 | // Set Image Size. |
---|
87 | int hud_width = 50; |
---|
88 | int hud_height = 50; |
---|
89 | |
---|
90 | // Start pos of image. |
---|
91 | int hud_x = 10; |
---|
92 | int hud_y = 10; |
---|
93 | |
---|
94 | glEnable(GL_BLEND); |
---|
95 | glEnable(GL_TEXTURE_2D); |
---|
96 | |
---|
97 | // Select Our VU Meter Background Texture |
---|
98 | this->backTex = new Texture(); |
---|
99 | this->backTex->loadImage("orx_tex.bmp"); |
---|
100 | glPushAttrib(GL_LIGHTING_BIT | GL_TRANSFORM_BIT); |
---|
101 | |
---|
102 | glDisable(GL_LIGHTING); |
---|
103 | glMatrixMode(GL_PROJECTION); |
---|
104 | glPushMatrix(); |
---|
105 | glLoadIdentity(); |
---|
106 | glOrtho(0,screen_width,0,screen_height,-1,1); // Set Up An Ortho Screen |
---|
107 | glMatrixMode(GL_MODELVIEW); |
---|
108 | glLoadIdentity(); |
---|
109 | glPushMatrix(); |
---|
110 | glEnable(GL_BLEND); |
---|
111 | |
---|
112 | glBegin(GL_QUADS); |
---|
113 | glTexCoord2i(0, 0); glVertex2i(hud_x, hud_y); |
---|
114 | glTexCoord2i(1, 0 ); glVertex2i( hud_x+hud_width, hud_y ); |
---|
115 | glTexCoord2i( 1, 1 ); glVertex2i( hud_x+hud_width, hud_y+hud_height ); |
---|
116 | glTexCoord2i( 0, 1 ); glVertex2i( hud_x, hud_y+hud_height ); |
---|
117 | glEnd(); |
---|
118 | |
---|
119 | glDisable(GL_BLEND); |
---|
120 | glPopMatrix(); |
---|
121 | glMatrixMode(GL_PROJECTION); |
---|
122 | glPopMatrix(); |
---|
123 | glPopAttrib(); |
---|
124 | glDisable(GL_TEXTURE_2D); |
---|
125 | glDisable(GL_BLEND); |
---|
126 | // End of Background image code. |
---|
127 | } |
---|
128 | |
---|
129 | |
---|
130 | /** |
---|
131 | \brief function to innit screen with all attributes set |
---|
132 | \param name of the background-image file |
---|
133 | \param height of the ImageScreen |
---|
134 | \param width of the Image Screen |
---|
135 | \param x offset from (0, 0) |
---|
136 | \param y offset from (0, 0) |
---|
137 | |
---|
138 | GLMenu uses its own coordinating system: upper left corner is (0, 0). x-axis is down=height, |
---|
139 | right axis is right direction (=width) |
---|
140 | */ |
---|
141 | void GLMenuImageScreen::init (char* backImageName, float height, float width, |
---|
142 | float offsetX, float offsetY) |
---|
143 | {} |
---|
144 | |
---|
145 | |
---|
146 | /** |
---|
147 | \brief draws the ImageScreen to the screenbuffer |
---|
148 | */ |
---|
149 | void GLMenuImageScreen::draw () |
---|
150 | { |
---|
151 | /* |
---|
152 | // Display a quad texture to the screen |
---|
153 | glEnable(GL_TEXTURE_2D); |
---|
154 | glBegin(GL_QUADS); |
---|
155 | |
---|
156 | // Display the top left vertice |
---|
157 | glTexCoord2f(0.0f, 1.0f); |
---|
158 | glVertex3f(-2.5, 2.5, 0); |
---|
159 | |
---|
160 | // Display the bottom left vertice |
---|
161 | glTexCoord2f(0.0f, 0.0f); |
---|
162 | glVertex3f(-2.5, -2.5, 0); |
---|
163 | |
---|
164 | // Display the bottom right vertice |
---|
165 | glTexCoord2f(1.0f, 0.0f); |
---|
166 | glVertex3f(2.5, -2.5, 0); |
---|
167 | |
---|
168 | // Display the top right vertice |
---|
169 | glTexCoord2f(1.0f, 1.0f); |
---|
170 | glVertex3f(2.5, 2.5, 0); |
---|
171 | |
---|
172 | glEnd(); |
---|
173 | glEnable(GL_TEXTURE_2D); |
---|
174 | */ |
---|
175 | |
---|
176 | SDL_GL_SwapBuffers(); |
---|
177 | |
---|
178 | delete this->backTex; |
---|
179 | SDL_Delay(5000); |
---|
180 | } |
---|
181 | |
---|
182 | |
---|
183 | /** |
---|
184 | \brief sets the background image name |
---|
185 | \param file name of the backgroun-image |
---|
186 | */ |
---|
187 | void GLMenuImageScreen::setBackImageName (char* backImageName) |
---|
188 | {} |
---|
189 | |
---|
190 | |
---|
191 | /** |
---|
192 | \brief sets position of the ImageScreen |
---|
193 | \param x offset from (0, 0) |
---|
194 | \param y offset from (0, 0) |
---|
195 | */ |
---|
196 | void GLMenuImageScreen::setPosition(float offsetX, float offsetY) |
---|
197 | {} |
---|
198 | |
---|
199 | |
---|
200 | /* |
---|
201 | \brief sets size of the ImageScreen |
---|
202 | \param height of the ImageScreen |
---|
203 | \param width of the Image Screen |
---|
204 | */ |
---|
205 | void GLMenuImageScreen::setSize(float height, float width) |
---|
206 | {} |
---|