/* orxonox - the future of 3D-vertical-scrollers Copyright (C) 2004 orx This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. ### File Specific: main-programmer: Patrick Boenzli co-programmer: */ #include "glmenu_imagescreen.h" #include "importer/texture.h" using namespace std; /** \brief standard constructor \todo this constructor is not jet implemented - do it */ GLMenuImageScreen::GLMenuImageScreen () { this->setClassName ("GLMenuImageScreen"); } /** \brief standard deconstructor \todo this deconstructor is not jet implemented - do it */ GLMenuImageScreen::~GLMenuImageScreen () {} /** \brief function to init the screen */ void GLMenuImageScreen::init () { /* int w = 680; int h = 480; glViewport(0,0,w,h); glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluPerspective(45.0f,(GLfloat)w/(GLfloat)h, .5f ,150.0f); glMatrixMode(GL_MODELVIEW); this->backTex = new Texture(); this->backTex->loadImage("orx_tex.bmp"); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glLoadIdentity(); gluLookAt(0, 0, 6, 0, 0, 0, 0, 1, 0); // Bind the texture stored at the zero index of g_Texture[] //glBindTexture(GL_TEXTURE_2D, g_Texture[0]); */ // Select Our VU Meter Background Texture this->backTex = new Texture(); this->backTex->loadImage("load_screen.jpg"); // End of Background image code. } /** \brief function to innit screen with all attributes set \param name of the background-image file \param height of the ImageScreen \param width of the Image Screen \param x offset from (0, 0) \param y offset from (0, 0) GLMenu uses its own coordinating system: upper left corner is (0, 0). x-axis is down=height, right axis is right direction (=width) */ void GLMenuImageScreen::init (char* backImageName, float height, float width, float offsetX, float offsetY) {} /** \brief draws the ImageScreen to the screenbuffer */ void GLMenuImageScreen::draw () { /* // Display a quad texture to the screen glEnable(GL_TEXTURE_2D); glBegin(GL_QUADS); // Display the top left vertice glTexCoord2f(0.0f, 1.0f); glVertex3f(-2.5, 2.5, 0); // Display the bottom left vertice glTexCoord2f(0.0f, 0.0f); glVertex3f(-2.5, -2.5, 0); // Display the bottom right vertice glTexCoord2f(1.0f, 0.0f); glVertex3f(2.5, -2.5, 0); // Display the top right vertice glTexCoord2f(1.0f, 1.0f); glVertex3f(2.5, 2.5, 0); glEnd(); glEnable(GL_TEXTURE_2D); */ glClear( GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); // Screen Size. int screenWidth = 640; int screenHeight = 480; // Set Image Size. int imageWidth = 640; int imageHeight = 480; // Start pos of image. int offsetX = (screenWidth - imageWidth)/2; int offsetY = (screenHeight - imageHeight)/2; glEnable(GL_BLEND); glEnable(GL_TEXTURE_2D); glPushAttrib(GL_LIGHTING_BIT | GL_TRANSFORM_BIT); glDisable(GL_LIGHTING); glMatrixMode(GL_PROJECTION); glPushMatrix(); glLoadIdentity(); /* set up an ortho screen */ glOrtho(0, screenWidth, 0, screenHeight, -1, 1); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glPushMatrix(); glEnable(GL_BLEND); glBegin(GL_QUADS); glTexCoord2i(0, 0); glVertex2i(offsetX, offsetY); glTexCoord2i(1, 0 ); glVertex2i(offsetX + imageWidth, offsetY); glTexCoord2i( 1, 1 ); glVertex2i(offsetX + imageWidth, offsetY + imageHeight); glTexCoord2i( 0, 1 ); glVertex2i(offsetX, offsetY + imageHeight); glEnd(); glDisable(GL_TEXTURE_2D); glBegin(GL_QUADS); glColor3f(1.0, 0.0, 0.0); glVertex2i(100, 100); glVertex2i(200, 100); glVertex2i(200, 150); glVertex2i(100, 150); glEnd(); glDisable(GL_BLEND); glPopMatrix(); glMatrixMode(GL_PROJECTION); glPopMatrix(); glPopAttrib(); SDL_GL_SwapBuffers(); SDL_Delay(1000); } /** \brief sets the background image name \param file name of the backgroun-image */ void GLMenuImageScreen::setBackImageName (char* backImageName) {} /** \brief sets position of the ImageScreen \param x offset from (0, 0) \param y offset from (0, 0) */ void GLMenuImageScreen::setPosition(float offsetX, float offsetY) {} /* \brief sets size of the ImageScreen \param height of the ImageScreen \param width of the Image Screen */ void GLMenuImageScreen::setSize(float height, float width) {} /** \brief set the maximum of countable steps \param maximum of steps */ void GLMenuImageScreen::setMaximum(int maxStep) { this->maxStep = maxStep; } /** \brief gets the maximum of countable steps */ int GLMenuImageScreen::getMaximum() { return this->maxStep; } /** \brief set current value \param current value */ void GLMenuImageScreen::setValue(int currentValue) { this->currentValue = currentValue; this->draw(); } /** \brief get the current value */ int GLMenuImageScreen::getValue() { return this->currentValue; } /** \brief call this to trigger a progress event this has to redraw the progress bar and the whole image */ void GLMenuImageScreen::step () { this->currentValue++; }