Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/orxonox/branches/levelloader/src/glmenu/glmenu_imagescreen.cc @ 3715

Last change on this file since 3715 was 3605, checked in by bensch, 20 years ago

orxonox/trunk: merged trunk back to levelloader
merged with command:
svn merge -r 3499:HEAD trunk branches/levelloader

Conflicts in
C track_manager.h
C world_entities/player.cc
C world_entities/player.h
C world_entities/environment.h
C lib/coord/p_node.cc
C defs/debug.h
C track_manager.cc
C story_entities/campaign.h

solved in merge-favouring. It was quite easy because Chris only worked on the headers, and he didi it quite clean. Thats the spirit :)

Conflits in world.cc are a MESS: fix it

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
21#include "stdincl.h"
22#include "material.h"
23
24using namespace std;
25
26GLMenuImageScreen* GLMenuImageScreen::singletonRef = 0;
27
28GLMenuImageScreen* GLMenuImageScreen::getInstance()
29{
30  if(!singletonRef)
31    singletonRef = new GLMenuImageScreen ();
32  return singletonRef;
33}
34
35/**
36   \brief standard constructor
37
38   \todo this constructor is not jet implemented - do it
39*/
40GLMenuImageScreen::GLMenuImageScreen () 
41{
42   this->setClassName ("GLMenuImageScreen");
43}
44
45
46/**
47   \brief standard deconstructor
48   \todo this deconstructor is not jet implemented - do it
49*/
50GLMenuImageScreen::~GLMenuImageScreen() 
51{
52  if (backMat)
53    delete backMat;
54}
55
56/**
57   \brief function to init the screen
58*/
59void GLMenuImageScreen::init ()
60{
61  /*
62  int w = 680;
63  int h = 480;
64
65  glViewport(0,0,w,h);
66 
67  glMatrixMode(GL_PROJECTION);
68  glLoadIdentity();
69  gluPerspective(45.0f,(GLfloat)w/(GLfloat)h, .5f ,150.0f);
70  glMatrixMode(GL_MODELVIEW);
71
72  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
73  glLoadIdentity();
74  gluLookAt(0, 0, 6,     0, 0, 0,     0, 1, 0);
75
76  // Bind the texture stored at the zero index of g_Texture[]
77  //glBindTexture(GL_TEXTURE_2D, g_Texture[0]);
78  */
79
80 
81  // Select Our VU Meter Background Texture
82  this->backMat = new Material("load_screen");
83  this->backMat->setDiffuseMap("../data/pictures/load_screen.jpg");
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 = (int)((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  backMat->select();
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.