Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/orxonox/branches/trackManager/src/glmenu_imagescreen.cc @ 3426

Last change on this file since 3426 was 3369, checked in by bensch, 20 years ago

orxonox/branches: added branche trackManager.

File size: 5.2 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("load_screen.jpg");
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 screenWidth = 640;
130  int screenHeight = 480;
131 
132  // Set Image Size.
133  int imageWidth = 640;
134  int imageHeight = 480;
135 
136  // Start pos of image.
137  int offsetX = (screenWidth - imageWidth)/2;
138  int offsetY = (screenHeight - imageHeight)/2;
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  /* set up an ortho screen */
150  glOrtho(0, screenWidth, 0, screenHeight, -1, 1); 
151  glMatrixMode(GL_MODELVIEW);
152  glLoadIdentity();
153  glPushMatrix();
154  glEnable(GL_BLEND);
155
156  glBegin(GL_QUADS);
157  glTexCoord2i(0, 0); glVertex2i(offsetX, offsetY);
158  glTexCoord2i(1, 0 ); glVertex2i(offsetX + imageWidth, offsetY);
159  glTexCoord2i( 1, 1 ); glVertex2i(offsetX + imageWidth, offsetY + imageHeight);
160  glTexCoord2i( 0, 1 ); glVertex2i(offsetX, offsetY + imageHeight);
161  glEnd();
162
163  glDisable(GL_TEXTURE_2D);
164
165  glBegin(GL_QUADS);
166  glColor3f(1.0, 0.0, 0.0);
167  glVertex2i(100, 100);
168  glVertex2i(200, 100);
169  glVertex2i(200, 150);
170  glVertex2i(100, 150);
171  glEnd();
172
173
174  glDisable(GL_BLEND);
175  glPopMatrix();
176  glMatrixMode(GL_PROJECTION);
177  glPopMatrix();
178  glPopAttrib();
179
180  SDL_GL_SwapBuffers();                   
181  SDL_Delay(1000);
182}
183 
184
185/**
186    \brief sets the background image name
187    \param file name of the backgroun-image
188 */
189void GLMenuImageScreen::setBackImageName (char* backImageName)
190{}
191
192
193/**
194   \brief sets position of the ImageScreen
195   \param x offset from (0, 0)
196   \param y offset from (0, 0)
197*/
198void GLMenuImageScreen::setPosition(float offsetX, float offsetY)
199{}
200
201
202/*
203  \brief sets size of the ImageScreen
204  \param height of the ImageScreen
205  \param width of the Image Screen
206*/
207void GLMenuImageScreen::setSize(float height, float width)
208{}
209
210
211/**
212   \brief set the maximum of countable steps
213   \param maximum of steps
214*/
215void GLMenuImageScreen::setMaximum(int maxStep)
216{
217  this->maxStep = maxStep;
218}
219
220
221/**
222   \brief gets the maximum of countable steps
223*/
224int GLMenuImageScreen::getMaximum()
225{
226  return this->maxStep;
227}
228
229
230/**
231   \brief set current value
232   \param current value
233*/
234void GLMenuImageScreen::setValue(int currentValue)
235{
236  this->currentValue = currentValue;
237  this->draw();
238}
239
240
241/**
242   \brief get the current value
243 */
244int GLMenuImageScreen::getValue()
245{
246  return this->currentValue;
247}
248
249
250/**
251    \brief call this to trigger a progress event
252   
253    this has to redraw the progress bar and the whole image
254 */
255void GLMenuImageScreen::step ()
256{
257  this->currentValue++;
258}
Note: See TracBrowser for help on using the repository browser.