Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 3362 was 3362, checked in by patrick, 20 years ago

orxonox/branches/parenting: remved HUD, reimplemented the display function. now rocks.

File size: 4.2 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
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 ()
[3358]48{
[3361]49  /*
[3358]50  int w = 680;
51  int h = 480;
[3357]52
[3358]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);
[3357]59
[3358]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]);
[3361]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.
[3358]77}
78
79
[3357]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 ()
[3358]100{
[3361]101  /*
[3358]102  // Display a quad texture to the screen
[3359]103  glEnable(GL_TEXTURE_2D);
[3358]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);
[3357]121
[3358]122  glEnd();
[3359]123  glEnable(GL_TEXTURE_2D); 
[3361]124  */
[3362]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;
[3361]131 
[3362]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
[3358]170  SDL_GL_SwapBuffers();                   
[3362]171  SDL_Delay(1000);
[3358]172}
173
[3357]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{}
Note: See TracBrowser for help on using the repository browser.