Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

orxonox/trunk: updated screenloader with more generic functions

File size: 5.6 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("load_screen.jpg");
83
84  // End of Background image code.
85}
86
87
88/**
89   \brief function to innit screen with all attributes set
90   \param name of the background-image file
91   \param height of the ImageScreen
92   \param width of the Image Screen
93   \param x offset from (0, 0)
94   \param y offset from (0, 0)
95
96   GLMenu uses its own coordinating system: upper left corner is (0, 0). x-axis is down=height,
97   right axis is right direction (=width)
98*/
99void GLMenuImageScreen::init (char* backImageName, float height, float width, 
100                              float offsetX, float offsetY)
101{}
102
103
104/**
105   \brief draws the ImageScreen to the screenbuffer
106*/
107void GLMenuImageScreen::draw ()
108{
109  /*
110  // Display a quad texture to the screen
111  glEnable(GL_TEXTURE_2D);
112  glBegin(GL_QUADS);
113 
114  // Display the top left vertice
115  glTexCoord2f(0.0f, 1.0f);
116  glVertex3f(-2.5, 2.5, 0);
117 
118  // Display the bottom left vertice
119  glTexCoord2f(0.0f, 0.0f);
120  glVertex3f(-2.5, -2.5, 0);
121 
122  // Display the bottom right vertice
123  glTexCoord2f(1.0f, 0.0f);
124  glVertex3f(2.5, -2.5, 0);
125 
126  // Display the top right vertice
127  glTexCoord2f(1.0f, 1.0f);
128  glVertex3f(2.5, 2.5, 0);
129
130  glEnd();
131  glEnable(GL_TEXTURE_2D); 
132  */
133
134  glClear( GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
135
136  /* screen size */
137  int screenWidth = 640;
138  int screenHeight = 480;
139 
140  /* set image size */
141  int imageWidth = 640;
142  int imageHeight = 480;
143 
144  /* start pos of image */
145  int offsetX = (screenWidth - imageWidth)/2;
146  int offsetY = (screenHeight - imageHeight)/2;
147 
148  /* loadbar pos */
149  int barX = 400;
150  int barY = 50;
151  int barWidth = 230;
152  int barHeight = 30;
153
154  glMatrixMode(GL_PROJECTION);
155  glPushMatrix();
156  glLoadIdentity();
157  /* set up an ortho screen */
158  glOrtho(0, screenWidth, 0, screenHeight, -1, 1); 
159  glMatrixMode(GL_MODELVIEW);
160  glLoadIdentity();
161  glPushMatrix();
162
163  glEnable(GL_BLEND);
164  glPushAttrib(GL_LIGHTING_BIT | GL_TRANSFORM_BIT);
165  glDisable(GL_LIGHTING);
166
167  glBegin(GL_QUADS);
168  glColor3f(0.96, 0.84, 0.34);
169  glVertex2i(barX, barY);
170  glVertex2i(barX + barWidth, barY);
171  glVertex2i(barX + barWidth, barY + barHeight);
172  glVertex2i(barX, barY + barHeight);
173  glColor3f(1.0, 1.0, 1.0);
174  glEnd();
175
176  glEnable(GL_TEXTURE_2D);
177  glBegin(GL_QUADS);
178  glTexCoord2i(0, 0); glVertex2i(offsetX, offsetY);
179  glTexCoord2i(1, 0); glVertex2i(offsetX + imageWidth, offsetY);
180  glTexCoord2i(1, 1); glVertex2i(offsetX + imageWidth, offsetY + imageHeight);
181  glTexCoord2i(0, 1); glVertex2i(offsetX, offsetY + imageHeight);
182  glEnd();
183  glDisable(GL_TEXTURE_2D);
184
185  glDisable(GL_BLEND);
186  glPopMatrix();
187  glMatrixMode(GL_PROJECTION);
188  glPopMatrix();
189  glPopAttrib();
190
191  SDL_GL_SwapBuffers();                   
192  SDL_Delay(5000);
193}
194 
195
196/**
197    \brief sets the background image name
198    \param file name of the backgroun-image
199 */
200void GLMenuImageScreen::setBackImageName (char* backImageName)
201{}
202
203
204/**
205   \brief sets position of the ImageScreen
206   \param x offset from (0, 0)
207   \param y offset from (0, 0)
208*/
209void GLMenuImageScreen::setPosition(float offsetX, float offsetY)
210{}
211
212
213/*
214  \brief sets size of the ImageScreen
215  \param height of the ImageScreen
216  \param width of the Image Screen
217*/
218void GLMenuImageScreen::setSize(float height, float width)
219{}
220
221
222/**
223   \brief set the maximum of countable steps
224   \param maximum of steps
225*/
226void GLMenuImageScreen::setMaximum(int maxStep)
227{
228  this->maxStep = maxStep;
229}
230
231
232/**
233   \brief gets the maximum of countable steps
234*/
235int GLMenuImageScreen::getMaximum()
236{
237  return this->maxStep;
238}
239
240
241/**
242   \brief set current value
243   \param current value
244*/
245void GLMenuImageScreen::setValue(int currentValue)
246{
247  this->currentValue = currentValue;
248  this->draw();
249}
250
251
252/**
253   \brief get the current value
254 */
255int GLMenuImageScreen::getValue()
256{
257  return this->currentValue;
258}
259
260
261/**
262    \brief call this to trigger a progress event
263   
264    this has to redraw the progress bar and the whole image
265 */
266void GLMenuImageScreen::step ()
267{
268  this->currentValue++;
269}
Note: See TracBrowser for help on using the repository browser.