Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/orxonox/branches/dave/src/glmenu_imagescreen.cc @ 3500

Last change on this file since 3500 was 3380, checked in by bensch, 20 years ago

orxonox/trunk: added property that merges the Data-Repository into the Trunk

File size: 6.5 KB
Line 
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
22using namespace std;
23
24GLMenuImageScreen* GLMenuImageScreen::singletonRef = 0;
25
26GLMenuImageScreen* GLMenuImageScreen::getInstance()
27{
28  if( singletonRef == NULL)
29    singletonRef = new GLMenuImageScreen ();
30  return singletonRef;
31}
32
33/**
34   \brief standard constructor
35
36   \todo this constructor is not jet implemented - do it
37*/
38GLMenuImageScreen::GLMenuImageScreen () 
39{
40   this->setClassName ("GLMenuImageScreen");
41}
42
43
44/**
45   \brief standard deconstructor
46
47   \todo this deconstructor is not jet implemented - do it
48*/
49GLMenuImageScreen::~GLMenuImageScreen () {}
50
51
52/**
53   \brief function to init the screen
54*/
55void GLMenuImageScreen::init ()
56{
57  /*
58  int w = 680;
59  int h = 480;
60
61  glViewport(0,0,w,h);
62 
63  glMatrixMode(GL_PROJECTION);
64  glLoadIdentity();
65  gluPerspective(45.0f,(GLfloat)w/(GLfloat)h, .5f ,150.0f);
66  glMatrixMode(GL_MODELVIEW);
67
68  this->backTex = new Texture();
69  this->backTex->loadImage("orx_tex.bmp");
70
71  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
72  glLoadIdentity();
73  gluLookAt(0, 0, 6,     0, 0, 0,     0, 1, 0);
74
75  // Bind the texture stored at the zero index of g_Texture[]
76  //glBindTexture(GL_TEXTURE_2D, g_Texture[0]);
77  */
78
79 
80  // Select Our VU Meter Background Texture
81  this->backTex = new Texture();
82  this->backTex->loadImage("../data/pictures/load_screen.jpg");
83
84  this->maxValue = 10;
85  this->currentValue = 0;
86
87  // End of Background image code.
88}
89
90
91/**
92   \brief function to innit screen with all attributes set
93   \param name of the background-image file
94   \param height of the ImageScreen
95   \param width of the Image Screen
96   \param x offset from (0, 0)
97   \param y offset from (0, 0)
98
99   GLMenu uses its own coordinating system: upper left corner is (0, 0). x-axis is down=height,
100   right axis is right direction (=width)
101*/
102void GLMenuImageScreen::init (char* backImageName, float height, float width, 
103                              float offsetX, float offsetY)
104{}
105
106
107/**
108   \brief draws the ImageScreen to the screenbuffer
109*/
110void GLMenuImageScreen::draw ()
111{
112  /*
113  // Display a quad texture to the screen
114  glEnable(GL_TEXTURE_2D);
115  glBegin(GL_QUADS);
116 
117  // Display the top left vertice
118  glTexCoord2f(0.0f, 1.0f);
119  glVertex3f(-2.5, 2.5, 0);
120 
121  // Display the bottom left vertice
122  glTexCoord2f(0.0f, 0.0f);
123  glVertex3f(-2.5, -2.5, 0);
124 
125  // Display the bottom right vertice
126  glTexCoord2f(1.0f, 0.0f);
127  glVertex3f(2.5, -2.5, 0);
128 
129  // Display the top right vertice
130  glTexCoord2f(1.0f, 1.0f);
131  glVertex3f(2.5, 2.5, 0);
132
133  glEnd();
134  glEnable(GL_TEXTURE_2D); 
135  */
136
137  glClear( GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
138
139  /* screen size */
140  int screenWidth = 640;
141  int screenHeight = 480;
142 
143  /* set image size */
144  int imageWidth = 640;
145  int imageHeight = 480;
146 
147  /* start pos of image */
148  int offsetX = (screenWidth - imageWidth)/2;
149  int offsetY = (screenHeight - imageHeight)/2;
150 
151  /* loadbar pos */
152  int barX = 390;
153  int barY = 50;
154  int barWidth = 230;
155  int barHeight = 30;
156
157  int val = ((float)this->currentValue/(float)this->maxValue) * barWidth;
158
159  glMatrixMode(GL_PROJECTION);
160  glPushMatrix();
161  glLoadIdentity();
162  /* set up an ortho screen */
163  glOrtho(0, screenWidth, 0, screenHeight, -1, 1); 
164  glMatrixMode(GL_MODELVIEW);
165  glLoadIdentity();
166  glPushMatrix();
167
168  glEnable(GL_BLEND);
169  glPushAttrib(GL_LIGHTING_BIT | GL_TRANSFORM_BIT);
170  glDisable(GL_LIGHTING);
171
172  glBegin(GL_QUADS);
173  glColor3f(0.96, 0.84, 0.34);
174  glVertex2i(barX, barY);
175  glVertex2i(barX + val, barY);
176  glVertex2i(barX + val, barY + barHeight);
177  glVertex2i(barX, barY + barHeight);
178  glColor3f(1.0, 1.0, 1.0);
179  glEnd();
180
181  glBegin(GL_QUADS);
182  glColor3f(0.0, 0.0, 0.0);
183  glVertex2i(barX, barY);
184  glVertex2i(barX + barWidth, barY);
185  glVertex2i(barX + barWidth, barY + barHeight);
186  glVertex2i(barX, barY + barHeight);
187  glColor3f(1.0, 1.0, 1.0);
188  glEnd();
189
190  /* draw black border */
191  glBegin(GL_QUADS);
192  glColor3f(0.0, 0.0, 0.0);
193  glVertex2i(barX-1, barY-1);
194  glVertex2i(barX + barWidth +1, barY-1);
195  glVertex2i(barX + barWidth+1, barY + barHeight+1);
196  glVertex2i(barX - 1, barY + barHeight +1);
197  glColor3f(1.0, 1.0, 1.0);
198  glEnd();
199
200  /* draw white border */
201  glBegin(GL_QUADS);
202  glColor3f(1.0, 1.0, 1.0);
203  glVertex2i(barX-2, barY-2);
204  glVertex2i(barX + barWidth +2, barY-2);
205  glVertex2i(barX + barWidth+2, barY + barHeight+2);
206  glVertex2i(barX - 2, barY + barHeight +2);
207  glColor3f(1.0, 1.0, 1.0);
208  glEnd();
209
210  glEnable(GL_TEXTURE_2D);
211  glBegin(GL_QUADS);
212  glTexCoord2i(0, 0); glVertex2i(offsetX, offsetY);
213  glTexCoord2i(1, 0); glVertex2i(offsetX + imageWidth, offsetY);
214  glTexCoord2i(1, 1); glVertex2i(offsetX + imageWidth, offsetY + imageHeight);
215  glTexCoord2i(0, 1); glVertex2i(offsetX, offsetY + imageHeight);
216  glEnd();
217  glDisable(GL_TEXTURE_2D);
218
219  glDisable(GL_BLEND);
220  glPopMatrix();
221  glMatrixMode(GL_PROJECTION);
222  glPopMatrix();
223  glPopAttrib();
224
225  SDL_GL_SwapBuffers();                   
226}
227 
228
229/**
230    \brief sets the background image name
231    \param file name of the backgroun-image
232 */
233void GLMenuImageScreen::setBackImageName (char* backImageName)
234{}
235
236
237/**
238   \brief sets position of the ImageScreen
239   \param x offset from (0, 0)
240   \param y offset from (0, 0)
241*/
242void GLMenuImageScreen::setPosition(float offsetX, float offsetY)
243{}
244
245
246/*
247  \brief sets size of the ImageScreen
248  \param height of the ImageScreen
249  \param width of the Image Screen
250*/
251void GLMenuImageScreen::setSize(float height, float width)
252{}
253
254
255/**
256   \brief set the maximum of countable steps
257   \param maximum of steps
258*/
259void GLMenuImageScreen::setMaximum(int maxValue)
260{
261  this->maxValue = maxValue;
262}
263
264
265/**
266   \brief gets the maximum of countable steps
267*/
268int GLMenuImageScreen::getMaximum()
269{
270  return this->maxValue;
271}
272
273
274/**
275   \brief set current value
276   \param current value
277*/
278void GLMenuImageScreen::setValue(int currentValue)
279{
280  this->currentValue = currentValue;
281  this->draw();
282}
283
284
285/**
286   \brief get the current value
287 */
288int GLMenuImageScreen::getValue()
289{
290  return this->currentValue;
291}
292
293
294/**
295    \brief call this to trigger a progress event
296   
297    this has to redraw the progress bar and the whole image
298 */
299void GLMenuImageScreen::step ()
300{
301  this->currentValue++;
302  this->draw();
303}
Note: See TracBrowser for help on using the repository browser.