Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/orxonox/branches/nico/src/glmenu_imagescreen.cc @ 3943

Last change on this file since 3943 was 3399, checked in by bensch, 20 years ago

orxonox/branches/nico: merged trunk into branches/nico
merged with command:
svn merge ../trunk/ nico/ -r 3238:HEAD
resolved conflict in favor of branches/nico.

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