Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/orxonox/branches/parenting/src/glmenu_imagescreen.cc @ 3363

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

orxonox/branches/parenting: extended functionality to implement progress bar

File size: 5.0 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
24
25/**
26   \brief standard constructor
27
28   \todo this constructor is not jet implemented - do it
29*/
30GLMenuImageScreen::GLMenuImageScreen () 
31{
32   this->setClassName ("GLMenuImageScreen");
33}
34
35
36/**
37   \brief standard deconstructor
38
39   \todo this deconstructor is not jet implemented - do it
40*/
41GLMenuImageScreen::~GLMenuImageScreen () {}
42
43
44/**
45   \brief function to init the screen
46*/
47void GLMenuImageScreen::init ()
48{
49  /*
50  int w = 680;
51  int h = 480;
52
53  glViewport(0,0,w,h);
54 
55  glMatrixMode(GL_PROJECTION);
56  glLoadIdentity();
57  gluPerspective(45.0f,(GLfloat)w/(GLfloat)h, .5f ,150.0f);
58  glMatrixMode(GL_MODELVIEW);
59
60  this->backTex = new Texture();
61  this->backTex->loadImage("orx_tex.bmp");
62
63  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
64  glLoadIdentity();
65  gluLookAt(0, 0, 6,     0, 0, 0,     0, 1, 0);
66
67  // Bind the texture stored at the zero index of g_Texture[]
68  //glBindTexture(GL_TEXTURE_2D, g_Texture[0]);
69  */
70
71 
72  // Select Our VU Meter Background Texture
73  this->backTex = new Texture();
74  this->backTex->loadImage("orx_tex.bmp");
75
76  // End of Background image code.
77}
78
79
80/**
81   \brief function to innit screen with all attributes set
82   \param name of the background-image file
83   \param height of the ImageScreen
84   \param width of the Image Screen
85   \param x offset from (0, 0)
86   \param y offset from (0, 0)
87
88   GLMenu uses its own coordinating system: upper left corner is (0, 0). x-axis is down=height,
89   right axis is right direction (=width)
90*/
91void GLMenuImageScreen::init (char* backImageName, float height, float width, 
92                              float offsetX, float offsetY)
93{}
94
95
96/**
97   \brief draws the ImageScreen to the screenbuffer
98*/
99void GLMenuImageScreen::draw ()
100{
101  /*
102  // Display a quad texture to the screen
103  glEnable(GL_TEXTURE_2D);
104  glBegin(GL_QUADS);
105 
106  // Display the top left vertice
107  glTexCoord2f(0.0f, 1.0f);
108  glVertex3f(-2.5, 2.5, 0);
109 
110  // Display the bottom left vertice
111  glTexCoord2f(0.0f, 0.0f);
112  glVertex3f(-2.5, -2.5, 0);
113 
114  // Display the bottom right vertice
115  glTexCoord2f(1.0f, 0.0f);
116  glVertex3f(2.5, -2.5, 0);
117 
118  // Display the top right vertice
119  glTexCoord2f(1.0f, 1.0f);
120  glVertex3f(2.5, 2.5, 0);
121
122  glEnd();
123  glEnable(GL_TEXTURE_2D); 
124  */
125
126  glClear( GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
127
128  // Screen Size.
129  int screen_width = 640;
130  int screen_height = 480;
131 
132  // Set Image Size.
133  int hud_width = 400;
134  int hud_height = 400;
135 
136  // Start pos of image.
137  int hud_x = 120;
138  int hud_y = 40;
139 
140  glEnable(GL_BLEND);
141  glEnable(GL_TEXTURE_2D);
142
143  glPushAttrib(GL_LIGHTING_BIT | GL_TRANSFORM_BIT);
144 
145  glDisable(GL_LIGHTING);
146  glMatrixMode(GL_PROJECTION);
147  glPushMatrix();
148  glLoadIdentity();
149  glOrtho(0,screen_width,0,screen_height,-1,1); // Set Up An Ortho Screen
150  glMatrixMode(GL_MODELVIEW);
151  glLoadIdentity();
152  glPushMatrix();
153  glEnable(GL_BLEND);
154
155  glBegin(GL_QUADS);
156  glTexCoord2i(0, 0); glVertex2i(hud_x, hud_y);
157  glTexCoord2i(1, 0 ); glVertex2i( hud_x+hud_width, hud_y );
158  glTexCoord2i( 1, 1 ); glVertex2i( hud_x+hud_width, hud_y+hud_height );
159  glTexCoord2i( 0, 1 ); glVertex2i( hud_x, hud_y+hud_height );
160  glEnd();
161
162  glDisable(GL_BLEND);
163  glPopMatrix();
164  glMatrixMode(GL_PROJECTION);
165  glPopMatrix();
166  glPopAttrib();
167  glDisable(GL_TEXTURE_2D);
168
169
170  SDL_GL_SwapBuffers();                   
171  SDL_Delay(1000);
172}
173 
174
175/**
176    \brief sets the background image name
177    \param file name of the backgroun-image
178 */
179void GLMenuImageScreen::setBackImageName (char* backImageName)
180{}
181
182
183/**
184   \brief sets position of the ImageScreen
185   \param x offset from (0, 0)
186   \param y offset from (0, 0)
187*/
188void GLMenuImageScreen::setPosition(float offsetX, float offsetY)
189{}
190
191
192/*
193  \brief sets size of the ImageScreen
194  \param height of the ImageScreen
195  \param width of the Image Screen
196*/
197void GLMenuImageScreen::setSize(float height, float width)
198{}
199
200
201/**
202   \brief set the maximum of countable steps
203   \param maximum of steps
204*/
205void GLMenuImageScreen::setMaximum(int maxStep)
206{
207  this->maxStep = maxStep;
208}
209
210
211/**
212   \brief gets the maximum of countable steps
213*/
214int GLMenuImageScreen::getMaximum()
215{
216  return this->maxStep;
217}
218
219
220/**
221   \brief set current value
222   \param current value
223*/
224void GLMenuImageScreen::setValue(int currentValue)
225{
226  this->currentValue = currentValue;
227  this->draw();
228}
229
230
231/**
232   \brief get the current value
233 */
234int GLMenuImageScreen::getValue()
235{
236  return this->currentValue;
237}
238
239
240/**
241    \brief call this to trigger a progress event
242   
243    this has to redraw the progress bar and the whole image
244 */
245void GLMenuImageScreen::step ()
246{
247  this->currentValue++;
248}
Note: See TracBrowser for help on using the repository browser.