Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/orxonox/trunk/src/glmenu/glmenu_imagescreen.cc @ 3624

Last change on this file since 3624 was 3544, checked in by bensch, 20 years ago

orxonox/trunk: now the delete-process is as inteded by c++
virtual ~ClassName extends deletion and deletes also the MasterClass

File size: 6.5 KB
RevLine 
[3357]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"
[3428]20
[3543]21#include "stdincl.h"
[3484]22#include "material.h"
[3357]23
24using namespace std;
25
[3367]26GLMenuImageScreen* GLMenuImageScreen::singletonRef = 0;
[3357]27
[3367]28GLMenuImageScreen* GLMenuImageScreen::getInstance()
29{
[3543]30  if(!singletonRef)
[3367]31    singletonRef = new GLMenuImageScreen ();
32  return singletonRef;
33}
34
[3357]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
[3544]48   \todo this deconstructor is not jet implemented - do it
[3543]49*/
50GLMenuImageScreen::~GLMenuImageScreen() 
51{
[3394]52  if (backMat)
53    delete backMat;
54}
[3357]55
56/**
57   \brief function to init the screen
58*/
59void GLMenuImageScreen::init ()
[3358]60{
[3361]61  /*
[3358]62  int w = 680;
63  int h = 480;
[3357]64
[3358]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);
[3357]71
[3358]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]);
[3361]78  */
79
80 
81  // Select Our VU Meter Background Texture
[3394]82  this->backMat = new Material("load_screen");
83  this->backMat->setDiffuseMap("../data/pictures/load_screen.jpg");
[3368]84  this->maxValue = 10;
85  this->currentValue = 0;
86
[3361]87  // End of Background image code.
[3358]88}
89
90
[3357]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 ()
[3358]111{
[3361]112  /*
[3358]113  // Display a quad texture to the screen
[3359]114  glEnable(GL_TEXTURE_2D);
[3358]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);
[3357]132
[3358]133  glEnd();
[3359]134  glEnable(GL_TEXTURE_2D); 
[3361]135  */
[3362]136
137  glClear( GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
138
[3367]139  /* screen size */
[3364]140  int screenWidth = 640;
141  int screenHeight = 480;
[3361]142 
[3367]143  /* set image size */
[3364]144  int imageWidth = 640;
145  int imageHeight = 480;
[3362]146 
[3367]147  /* start pos of image */
[3364]148  int offsetX = (screenWidth - imageWidth)/2;
149  int offsetY = (screenHeight - imageHeight)/2;
[3362]150 
[3367]151  /* loadbar pos */
[3368]152  int barX = 390;
[3367]153  int barY = 50;
154  int barWidth = 230;
155  int barHeight = 30;
[3362]156
[3428]157  int val = (int)((float)this->currentValue/(float)this->maxValue) * barWidth;
[3368]158
[3362]159  glMatrixMode(GL_PROJECTION);
160  glPushMatrix();
161  glLoadIdentity();
[3364]162  /* set up an ortho screen */
163  glOrtho(0, screenWidth, 0, screenHeight, -1, 1); 
[3362]164  glMatrixMode(GL_MODELVIEW);
165  glLoadIdentity();
166  glPushMatrix();
[3367]167
[3362]168  glEnable(GL_BLEND);
[3367]169  glPushAttrib(GL_LIGHTING_BIT | GL_TRANSFORM_BIT);
170  glDisable(GL_LIGHTING);
[3362]171
172  glBegin(GL_QUADS);
[3367]173  glColor3f(0.96, 0.84, 0.34);
174  glVertex2i(barX, barY);
[3368]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);
[3367]184  glVertex2i(barX + barWidth, barY);
185  glVertex2i(barX + barWidth, barY + barHeight);
186  glVertex2i(barX, barY + barHeight);
187  glColor3f(1.0, 1.0, 1.0);
[3362]188  glEnd();
189
[3368]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
[3536]210  backMat->select();
[3364]211  glBegin(GL_QUADS);
[3367]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);
[3364]216  glEnd();
[3367]217  glDisable(GL_TEXTURE_2D);
[3364]218
[3362]219  glDisable(GL_BLEND);
220  glPopMatrix();
221  glMatrixMode(GL_PROJECTION);
222  glPopMatrix();
223  glPopAttrib();
224
[3358]225  SDL_GL_SwapBuffers();                   
226}
[3363]227 
[3358]228
[3357]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{}
[3363]253
254
255/**
256   \brief set the maximum of countable steps
257   \param maximum of steps
258*/
[3368]259void GLMenuImageScreen::setMaximum(int maxValue)
[3363]260{
[3368]261  this->maxValue = maxValue;
[3363]262}
263
264
265/**
266   \brief gets the maximum of countable steps
267*/
268int GLMenuImageScreen::getMaximum()
269{
[3368]270  return this->maxValue;
[3363]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++;
[3368]302  this->draw();
[3363]303}
Note: See TracBrowser for help on using the repository browser.