[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 | |
---|
| 22 | using namespace std; |
---|
| 23 | |
---|
| 24 | |
---|
| 25 | /** |
---|
| 26 | \brief standard constructor |
---|
| 27 | |
---|
| 28 | \todo this constructor is not jet implemented - do it |
---|
| 29 | */ |
---|
| 30 | GLMenuImageScreen::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 | */ |
---|
| 41 | GLMenuImageScreen::~GLMenuImageScreen () {} |
---|
| 42 | |
---|
| 43 | |
---|
| 44 | /** |
---|
| 45 | \brief function to init the screen |
---|
| 46 | */ |
---|
| 47 | void 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(); |
---|
[3364] | 74 | this->backTex->loadImage("load_screen.jpg"); |
---|
[3361] | 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 | */ |
---|
| 91 | void 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 | */ |
---|
| 99 | void 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. |
---|
[3364] | 129 | int screenWidth = 640; |
---|
| 130 | int screenHeight = 480; |
---|
[3361] | 131 | |
---|
[3362] | 132 | // Set Image Size. |
---|
[3364] | 133 | int imageWidth = 640; |
---|
| 134 | int imageHeight = 480; |
---|
[3362] | 135 | |
---|
| 136 | // Start pos of image. |
---|
[3364] | 137 | int offsetX = (screenWidth - imageWidth)/2; |
---|
| 138 | int offsetY = (screenHeight - imageHeight)/2; |
---|
[3362] | 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(); |
---|
[3364] | 149 | /* set up an ortho screen */ |
---|
| 150 | glOrtho(0, screenWidth, 0, screenHeight, -1, 1); |
---|
[3362] | 151 | glMatrixMode(GL_MODELVIEW); |
---|
| 152 | glLoadIdentity(); |
---|
| 153 | glPushMatrix(); |
---|
| 154 | glEnable(GL_BLEND); |
---|
| 155 | |
---|
| 156 | glBegin(GL_QUADS); |
---|
[3364] | 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); |
---|
[3362] | 161 | glEnd(); |
---|
| 162 | |
---|
[3364] | 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 | |
---|
[3362] | 174 | glDisable(GL_BLEND); |
---|
| 175 | glPopMatrix(); |
---|
| 176 | glMatrixMode(GL_PROJECTION); |
---|
| 177 | glPopMatrix(); |
---|
| 178 | glPopAttrib(); |
---|
| 179 | |
---|
[3358] | 180 | SDL_GL_SwapBuffers(); |
---|
[3362] | 181 | SDL_Delay(1000); |
---|
[3358] | 182 | } |
---|
[3363] | 183 | |
---|
[3358] | 184 | |
---|
[3357] | 185 | /** |
---|
| 186 | \brief sets the background image name |
---|
| 187 | \param file name of the backgroun-image |
---|
| 188 | */ |
---|
| 189 | void 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 | */ |
---|
| 198 | void 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 | */ |
---|
| 207 | void GLMenuImageScreen::setSize(float height, float width) |
---|
| 208 | {} |
---|
[3363] | 209 | |
---|
| 210 | |
---|
| 211 | /** |
---|
| 212 | \brief set the maximum of countable steps |
---|
| 213 | \param maximum of steps |
---|
| 214 | */ |
---|
| 215 | void GLMenuImageScreen::setMaximum(int maxStep) |
---|
| 216 | { |
---|
| 217 | this->maxStep = maxStep; |
---|
| 218 | } |
---|
| 219 | |
---|
| 220 | |
---|
| 221 | /** |
---|
| 222 | \brief gets the maximum of countable steps |
---|
| 223 | */ |
---|
| 224 | int GLMenuImageScreen::getMaximum() |
---|
| 225 | { |
---|
| 226 | return this->maxStep; |
---|
| 227 | } |
---|
| 228 | |
---|
| 229 | |
---|
| 230 | /** |
---|
| 231 | \brief set current value |
---|
| 232 | \param current value |
---|
| 233 | */ |
---|
| 234 | void GLMenuImageScreen::setValue(int currentValue) |
---|
| 235 | { |
---|
| 236 | this->currentValue = currentValue; |
---|
| 237 | this->draw(); |
---|
| 238 | } |
---|
| 239 | |
---|
| 240 | |
---|
| 241 | /** |
---|
| 242 | \brief get the current value |
---|
| 243 | */ |
---|
| 244 | int 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 | */ |
---|
| 255 | void GLMenuImageScreen::step () |
---|
| 256 | { |
---|
| 257 | this->currentValue++; |
---|
| 258 | } |
---|