Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/orxonox/trunk/src/glmenu_imagescreen.cc @ 3370

Last change on this file since 3370 was 3368, checked in by patrick, 19 years ago

orxonox/trunk: finished implementing loadscreen. looks quite fancy… enjoy :))

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"
[3358]20#include "importer/texture.h"
[3357]21
22using namespace std;
23
[3367]24GLMenuImageScreen* GLMenuImageScreen::singletonRef = 0;
[3357]25
[3367]26GLMenuImageScreen* GLMenuImageScreen::getInstance()
27{
28  if( singletonRef == NULL)
29    singletonRef = new GLMenuImageScreen ();
30  return singletonRef;
31}
32
[3357]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 ()
[3358]56{
[3361]57  /*
[3358]58  int w = 680;
59  int h = 480;
[3357]60
[3358]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);
[3357]67
[3358]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]);
[3361]77  */
78
79 
80  // Select Our VU Meter Background Texture
81  this->backTex = new Texture();
[3364]82  this->backTex->loadImage("load_screen.jpg");
[3361]83
[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
[3368]157  int val = ((float)this->currentValue/(float)this->maxValue) * barWidth;
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
[3367]210  glEnable(GL_TEXTURE_2D);
[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.