Jump to content

  • Log In with Google      Sign In   
  • Create Account


Salatinjsh

Member Since 19 May 2011
Offline Last Active Jan 01 2013 04:57 PM
-----

Topics I've Started

SDL and opengl textures

28 September 2012 - 05:50 AM

Hello!

I have decided to move from glut to SDL to make window and handle other things. But now i encounter an issue. When im trying to print texture on objects it does nothing. I have tried different ways of loading textures but it seems not to be the problem

Linker:
SOIL
mingw32
SDLmain
SDL
opengl32
glu32

Im using classes:

Main App:
[source lang="cpp"]#include "CApp.h"CApp::CApp() { Surf_Display = NULL; w = 640; h = 480; Running = true; angle = 0;}int CApp::OnExecute() { if(OnInit() == false) { return -1; } glLoadIdentity(); SDL_Event Event; while(Running) { while(SDL_PollEvent(&Event)) { OnEvent(&Event); } OnLoop(); OnRender(); } OnCleanup(); glGetError(); return 0;}int main(int argc, char* argv[]) { CApp theApp; return theApp.OnExecute();}[/source]
Main header
[source lang="cpp"]#ifndef _CAPP_H_ #define _CAPP_H_#include <SDL/SDL.h>#include <GL/gl.h>#include <GL/glu.h>#include <GL/SOIL.h>#include <iostream>#include "CEvent.h"class CApp : public CEvent { private: // local variables bool Running; int w,h; //window width and height SDL_Surface* Surf_Display; GLuint texture[3]; GLUquadricObj* quadratic; GLfloat angle; public: CApp(); int OnExecute(); public: // Natural things in game application bool OnInit(); void OnEvent(SDL_Event* Event); void OnLoop(); void OnRender(); void OnCleanup(); public: // Events used void OnKeyDown(SDLKey sym, SDLMod mod, Uint16 unicode); void OnExit();};#endif[/source]
Init:
[source lang="cpp"]#include "CApp.h"void RenderInit();GLuint LoadTextures(const char* filename);bool CApp::OnInit() { if(SDL_Init(SDL_INIT_EVERYTHING) < 0) { return false; } SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8); SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8); SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8); SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, 8); SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 16); SDL_GL_SetAttribute(SDL_GL_BUFFER_SIZE, 32); SDL_GL_SetAttribute(SDL_GL_ACCUM_RED_SIZE, 8); SDL_GL_SetAttribute(SDL_GL_ACCUM_GREEN_SIZE, 8); SDL_GL_SetAttribute(SDL_GL_ACCUM_BLUE_SIZE, 8); SDL_GL_SetAttribute(SDL_GL_ACCUM_ALPHA_SIZE, 8); SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 1); SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, 2); if((Surf_Display = SDL_SetVideoMode(w, h, 32, SDL_HWSURFACE | SDL_GL_DOUBLEBUFFER | SDL_OPENGL)) == NULL) { return false; } SDL_ShowCursor(SDL_DISABLE); texture[0] = LoadTextures("Crate.bmp"); quadratic=gluNewQuadric(); gluQuadricNormals(quadratic, GLU_SMOOTH); gluQuadricTexture(quadratic, GL_TRUE); RenderInit(); glClearColor(0,0,0,1); glViewport(0, 0, w, h); glMatrixMode(GL_PROJECTION); gluPerspective(45, (double)w / (double)h, 1, 200); GLfloat AmbientLightColor[] = {0,0,0, 1}; glLightModelfv(GL_LIGHT_MODEL_AMBIENT, AmbientLightColor); GLfloat Light0Color[] = {0.8,0.8,0.8,1}; GLfloat Light0Pos[] = {0.000000000000000000000000000000000000015,0,0}; glLightfv(GL_LIGHT0, GL_DIFFUSE, Light0Color); glLightfv(GL_LIGHT0, GL_POSITION, Light0Pos); glMatrixMode(GL_MODELVIEW); glEnable(GL_BLEND); glEnable(GL_DEPTH_TEST); glEnable(GL_TEXTURE_2D); glShadeModel(GL_SMOOTH); glClearColor(0.0f, 0.0f, 0.0f, 0.5f); // Black Background glClearDepth(1.0f); glDepthFunc(GL_LEQUAL); glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); glEnable(GL_LIGHTING); glEnable(GL_LIGHT0); return true;}void RenderInit(){ glNewList(1, GL_COMPILE); glBegin(GL_QUADS); glNormal3f(0,0,-1); glTexCoord2d(0,0);glVertex3d(-1,-1,-1); glTexCoord2d(1,0);glVertex3d(1,-1,-1); glTexCoord2d(1,1);glVertex3d(1,1,-1); glTexCoord2d(0,1);glVertex3d(-1,1,-1); glNormal3f(0,0,1); glTexCoord2d(0,0);glVertex3d(-1,-1,1); glTexCoord2d(1,0);glVertex3d(1,-1,1); glTexCoord2d(1,1);glVertex3d(1,1,1); glTexCoord2d(0,1);glVertex3d(-1,1,1); glNormal3f(-1,0,0); glTexCoord2d(1,0);glVertex3d(-1,-1,-1); glTexCoord2d(1,1);glVertex3d(-1,1,-1); glTexCoord2d(0,1);glVertex3d(-1,1,1); glTexCoord2d(0,0);glVertex3d(-1,-1,1); glNormal3f(1,0,0); glTexCoord2d(1,0);glVertex3d(1,-1,-1); glTexCoord2d(1,1);glVertex3d(1,1,-1); glTexCoord2d(0,1);glVertex3d(1,1,1); glTexCoord2d(0,0);glVertex3d(1,-1,1); glEnd(); glEndList();}GLuint LoadTextures(const char* filename){ GLuint texture = SOIL_load_OGL_texture ( filename, SOIL_LOAD_AUTO, SOIL_CREATE_NEW_ID, SOIL_FLAG_INVERT_Y ); if(texture == 0) return false; glBindTexture(GL_TEXTURE_2D, texture); glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR); glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR); return texture;}[/source]
Render:
[source lang="cpp"]#include "CApp.h"void CApp::OnRender() { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glTranslated(0,0,-5); glTranslated(0,0,-5); glRotatef(angle,0,1,0); //glRotatef(90,-1,0,0); glBindTexture(GL_TEXTURE_2D, texture[0]); //gluSphere(quadratic,1.3,32,16); glBegin(GL_QUADS); glTexCoord2d(0,0);glVertex3d(-1,-1,0); glTexCoord2d(0,1);glVertex3d(-1,1,0); glTexCoord2d(1,1);glVertex3d(1,1,0); glTexCoord2d(1,0);glVertex3d(1,-1,0); glEnd(); SDL_GL_SwapBuffers();}[/source]

ill be glad if someone could help. i've been looking for issue for about week now.

undefined reference to `WinMain@16

04 July 2011 - 01:36 AM

Hi!

I'm writing a OpenGL program and for texture reading I'm using SDL, but when i add SDL header file it says - "undefined reference to `WinMain@16". I haven't written function to load image and added this SDL header and without SDL header program works. I hope you can help me.

Here is the code:





#include "include/GL/glew.h"
#include "include/GL/glut.h"
#include "include/SDL/SDL.h"




int width = 500;
int height = 500;


GLfloat  LightPosition[] = { 0, 0, 0, 0};
GLfloat  LightAmbient[]  = { 0, 0, 0, 1 };
GLfloat  LightDiffuse[]  = { 1, 1, 1, 1 };

GLfloat  fogColor[4] = {0.5, 0.5, 0.5, 1};


void SetUpFog ()
{
    glClearColor(0.5, 0.5, 0.5, 1);

    glFogi  (GL_FOG_MODE, GL_LINEAR);
    glFogfv (GL_FOG_COLOR, fogColor);
    glFogf  (GL_FOG_DENSITY, 0.01);
    glHint  (GL_FOG_HINT, GL_NICEST);
    glFogf  (GL_FOG_START, 0);
    glFogf  (GL_FOG_END, 10);
}

void Init ()
{
    glEnable (GL_BLEND);
    glEnable (GL_DEPTH_TEST);
    glEnable (GL_COLOR_MATERIAL);
    glEnable (GL_LIGHT0);
    glEnable (GL_LIGHTING);
    glEnable (GL_FOG);
    SetUpFog ();
    //glutFullScreen();
}

void SetUpLight ()
{
    glLightfv(GL_LIGHT0, GL_AMBIENT,  LightAmbient);
    glLightfv(GL_LIGHT0, GL_DIFFUSE,  LightDiffuse);
    glLightfv(GL_LIGHT0, GL_POSITION, LightPosition);

    glColorMaterial (GL_FRONT, GL_AMBIENT_AND_DIFFUSE);
}




float posz = -6;

void Display()
{
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    glLoadIdentity();

    glTranslatef(0.0f, 0.0f, posz);

    glRotatef(25, 1, 0, 0);
    glRotatef(25, 0, 1, 0);

   void ToDraw()
{
    glColor4f(1, 0, 0, 1);
    //glBindTexture(GL_TEXTURE_2D, texture[0]);
    glBegin(GL_QUADS);
        // Front Face
        glNormal3f(0,0,1);
		glTexCoord2f(0.0f, 0.0f); glVertex3f(-1.0f, -1.0f,  1.0f);	// Bottom Left Of The Texture and Quad
		glTexCoord2f(1.0f, 0.0f); glVertex3f( 1.0f, -1.0f,  1.0f);	// Bottom Right Of The Texture and Quad
		glTexCoord2f(1.0f, 1.0f); glVertex3f( 1.0f,  1.0f,  1.0f);	// Top Right Of The Texture and Quad
		glTexCoord2f(0.0f, 1.0f); glVertex3f(-1.0f,  1.0f,  1.0f);	// Top Left Of The Texture and Quad
		// Back Face
		glNormal3f(0,0,-1);
		glTexCoord2f(1.0f, 0.0f); glVertex3f(-1.0f, -1.0f, -1.0f);	// Bottom Right Of The Texture and Quad
		glTexCoord2f(1.0f, 1.0f); glVertex3f(-1.0f,  1.0f, -1.0f);	// Top Right Of The Texture and Quad
		glTexCoord2f(0.0f, 1.0f); glVertex3f( 1.0f,  1.0f, -1.0f);	// Top Left Of The Texture and Quad
		glTexCoord2f(0.0f, 0.0f); glVertex3f( 1.0f, -1.0f, -1.0f);	// Bottom Left Of The Texture and Quad
		// Top Face
		glNormal3f(0,1,0);
		glTexCoord2f(0.0f, 1.0f); glVertex3f(-1.0f,  1.0f, -1.0f);	// Top Left Of The Texture and Quad
		glTexCoord2f(0.0f, 0.0f); glVertex3f(-1.0f,  1.0f,  1.0f);	// Bottom Left Of The Texture and Quad
		glTexCoord2f(1.0f, 0.0f); glVertex3f( 1.0f,  1.0f,  1.0f);	// Bottom Right Of The Texture and Quad
		glTexCoord2f(1.0f, 1.0f); glVertex3f( 1.0f,  1.0f, -1.0f);	// Top Right Of The Texture and Quad
		// Bottom Face
		glNormal3f(0,-1,0);
		glTexCoord2f(1.0f, 1.0f); glVertex3f(-1.0f, -1.0f, -1.0f);	// Top Right Of The Texture and Quad
		glTexCoord2f(0.0f, 1.0f); glVertex3f( 1.0f, -1.0f, -1.0f);	// Top Left Of The Texture and Quad
		glTexCoord2f(0.0f, 0.0f); glVertex3f( 1.0f, -1.0f,  1.0f);	// Bottom Left Of The Texture and Quad
		glTexCoord2f(1.0f, 0.0f); glVertex3f(-1.0f, -1.0f,  1.0f);	// Bottom Right Of The Texture and Quad
		// Right face
		glNormal3f(1,0,0);
		glTexCoord2f(1.0f, 0.0f); glVertex3f( 1.0f, -1.0f, -1.0f);	// Bottom Right Of The Texture and Quad
		glTexCoord2f(1.0f, 1.0f); glVertex3f( 1.0f,  1.0f, -1.0f);	// Top Right Of The Texture and Quad
		glTexCoord2f(0.0f, 1.0f); glVertex3f( 1.0f,  1.0f,  1.0f);	// Top Left Of The Texture and Quad
		glTexCoord2f(0.0f, 0.0f); glVertex3f( 1.0f, -1.0f,  1.0f);	// Bottom Left Of The Texture and Quad
		// Left Face
		glNormal3f(-1,0,0);
		glTexCoord2f(0.0f, 0.0f); glVertex3f(-1.0f, -1.0f, -1.0f);	// Bottom Left Of The Texture and Quad
		glTexCoord2f(1.0f, 0.0f); glVertex3f(-1.0f, -1.0f,  1.0f);	// Bottom Right Of The Texture and Quad
		glTexCoord2f(1.0f, 1.0f); glVertex3f(-1.0f,  1.0f,  1.0f);	// Top Right Of The Texture and Quad
		glTexCoord2f(0.0f, 1.0f); glVertex3f(-1.0f,  1.0f, -1.0f);	// Top Left Of The Texture and Quad
		//ground
		glNormal3f(0,1,0);
		glVertex3f(-100,-1,-100);
		glVertex3f(100,-1,-100);
		glVertex3f(100,-1,100);
		glVertex3f(-100,-1,100);
	glEnd();
}

    glutSwapBuffers();
}


void OnReshape(int w, int h)
{
    glViewport(0, 0, (GLsizei)w, (GLsizei)h);
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    gluPerspective(60, (GLfloat)w / (GLfloat)h, 1.0, 100.0);
    glMatrixMode(GL_MODELVIEW);
}

int main(int argc, char **argv)
{
    glutInit(&argc, argv);
    glutInitDisplayMode (GLUT_DOUBLE| GLUT_RGBA);
    glutInitWindowSize (width, height);
    glutInitWindowPosition (100, 100);
    glutCreateWindow ("TEST");

    Init();

    glutDisplayFunc  (Display);
    glutIdleFunc 	(Display);
    glutKeyboardFunc (Keyboard);
    glutSpecialFunc  (KeyboardSpec);
    glutReshapeFunc  (OnReshape);

    glutMainLoop();

    return 0;
}





If i could find way how to load OpenGL textures without SDL and it works for every OS i wouldn't use SDL.

Varables usable in whole project

18 June 2011 - 02:58 AM

Hi everyone!

I have a little problem :D, i have a project now where i'm doing quite primitive operations on graphics with OpenGL and i havein this project about 6 files and I want to use few vriables in whole project, but i ont know how, never have had needing for that, so I come to you to learn this :D

P.S. i have been looking for hat through net and havent find anything, maybe i'm not looking correctly or there is none but hope you could help me.

i'm quite bad writer so some of things may be written incorrectly :D

With ope for your help

Salatinjsh

Really wanted to write last 2 lines :D

OpenGL problem with Fog

12 June 2011 - 12:54 PM

Hi guys! I'm again with a problem :D

So i got this problem, i have made that fog appears or disapears when click 'f' key, but when fog is enabled object (in my case its a cube) that is drawn becomes black. i Have written this problem to tutorials author but he haven't respond to my question :(, so i hope someone of you could help ;)

there is the code:


#include <GL/glew.h>
#include <GL/glut.h>
#include <stdio.h>


GLfloat  LightPosition[] = { 0, 0, 0, 0};
GLfloat  LightAmbient[]  = { 0, 0, 0, 1 };
GLfloat  LightDiffuse[]  = { 1, 1, 1, 1 };

GLfloat  density = 0.3;
GLfloat  fogColor[4] = {0.5, 0.5, 0.5, 1.0};


bool    fog = false;

void Keyboard (unsigned char key, int x, int y)
{
    if (key == 'f')
    {
        if (fog)
        {
            glDisable(GL_FOG);
        } else
        {
            glEnable(GL_FOG);
        }
        fog = !fog;
    }
}

void KeyboardSpec (int key, int x, int y)
{

}


void ToDraw()
{
    glBegin(GL_QUADS);					// Start Drawing The Cube

        //glColor4f(1, 0, 0, 1);
        glNormal3f(0, 1, 0);
		glVertex3f( 1, 1,-1);			// Top Right Of The Quad (Top)
		glVertex3f(-1, 1,-1);			// Top Left Of The Quad (Top)
		glVertex3f(-1, 1, 1);			// Bottom Left Of The Quad (Top)
		glVertex3f( 1, 1, 1);			// Bottom Right Of The Quad (Top)

        //glColor4f(0, 1, 1, 1);
        glNormal3f(0, -1, 0);
		glVertex3f( 1,-1, 1);			// Top Right Of The Quad (Bottom)
		glVertex3f(-1,-1, 1);			// Top Left Of The Quad (Bottom)
		glVertex3f(-1,-1,-1);			// Bottom Left Of The Quad (Bottom)
		glVertex3f( 1,-1,-1);			// Bottom Right Of The Quad (Bottom)

        //glColor4f(1, 0, 1, -1);
        glNormal3f(0, 0, 1);
		glVertex3f( 1, 1, 1);			// Top Right Of The Quad (Front)
		glVertex3f(-1, 1, 1);			// Top Left Of The Quad (Front)
		glVertex3f(-1,-1, 1);			// Bottom Left Of The Quad (Front)
		glVertex3f( 1,-1, 1);			// Bottom Right Of The Quad (Front)

        //glColor4f(1, 1, 0, 1);
        glNormal3f(0, 0, -1);
		glVertex3f( 1,-1,-1);			// Bottom Left Of The Quad (Back)
		glVertex3f(-1,-1,-1);			// Bottom Right Of The Quad (Back)
		glVertex3f(-1, 1,-1);			// Top Right Of The Quad (Back)
		glVertex3f( 1, 1,-1);			// Top Left Of The Quad (Back)

        //glColor4f ( 0, 0, 1, 1 );
        glNormal3f( -1, 0, 0 );
		glVertex3f(-1, 1, 1);			// Top Right Of The Quad (Left)
		glVertex3f(-1, 1,-1);			// Top Left Of The Quad (Left)
		glVertex3f(-1,-1,-1);			// Bottom Left Of The Quad (Left)
		glVertex3f(-1,-1, 1);			// Bottom Right Of The Quad (Left)

        //glColor4f ( 0, 1, 0, 1 );
        glNormal3f( 1, 0, 0 );
		glVertex3f( 1, 1,-1);			// Top Right Of The Quad (Right)
		glVertex3f( 1, 1, 1);			// Top Left Of The Quad (Right)
		glVertex3f( 1,-1, 1);			// Bottom Left Of The Quad (Right)
		glVertex3f( 1,-1,-1);			// Bottom Right Of The Quad (Right)
	glEnd();
}



void Init()
{
    glEnable (GL_BLEND);
    glEnable (GL_DEPTH_TEST);
    glEnable (GL_COLOR_MATERIAL);
    glEnable (GL_LIGHT0);
    glEnable (GL_LIGHTING);
}

void SetUpLight ()
{
    glLightfv(GL_LIGHT0, GL_AMBIENT,  LightAmbient);
    glLightfv(GL_LIGHT0, GL_DIFFUSE,  LightDiffuse);
    glLightfv(GL_LIGHT0, GL_POSITION, LightPosition);

    glColorMaterial (GL_FRONT, GL_AMBIENT_AND_DIFFUSE);
}

void SetUpFog()
{
    glFogi  (GL_FOG_MODE, GL_LINEAR);
    glFogfv (GL_FOG_COLOR, fogColor);
    glFogf  (GL_FOG_DENSITY, density);
    glHint  (GL_FOG_HINT, GL_NICEST);
    glFogf  (GL_FOG_START, 1.0f);
    glFogf  (GL_FOG_END, 5.0f);
}


void Display()
{
    glClearColor(0.2, 0.2, 0.2, 1);
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    glLoadIdentity();

    glTranslatef(0.0f, 0.0f, -6.0f);

    glRotatef(rotquad, 1, 0, 0);
    glRotatef(rotquad, 0, 1, 0);

    ToDraw();

    rotquad -= 1.5f;

    glutSwapBuffers();
}

void OnReshape(int width, int height)
{
    glViewport(0, 0, (GLsizei)width, (GLsizei)height); // Set our viewport to the size of our window
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    gluPerspective(60, (GLfloat)width / (GLfloat)height, 1.0, 100.0);
    glMatrixMode(GL_MODELVIEW); // Switch back to the model view matrix, so that we can start drawing shapes correctly
}

int main(int argc, char **argv)
{
    glutInit(&argc, argv); // Initialize GLUT
    glutInitDisplayMode (GLUT_DOUBLE| GLUT_RGBA); // Set up a basic display buffer (only single buffered for now)
    glutInitWindowSize (500, 500); // Set the width and height of the window
    glutInitWindowPosition (100, 100); // Set the position of the window
    glutCreateWindow ("First GLUT window"); // Set the title for the window

    Init();

    glutDisplayFunc  (Display);
    glutIdleFunc 	(Display);
    glutKeyboardFunc (Keyboard);
    glutSpecialFunc  (KeyboardSpec);
    glutReshapeFunc  (OnReshape);

    glutMainLoop(); // Enter GLUT's main loop

    return 0;
}



GL lighting problem

19 May 2011 - 07:15 AM

Hi!

I'm learning OpenGL using GLUT window. So far i have made a colorful cube rotating on y and x asis and now i have added lighting but it doesnt work. It only makes it all in shadow but it should make nice perspectively shaded cube.

There is the code and i hope i'll have help :

#include <GL/glew.h>
#include <GL/glut.h>

GLfloat rotquad;

GLfloat  LightPosition[] = { 0, 0, 0, 1 };
GLfloat  LightAmbient[]  = { 1, 1, 1, 1 };
GLfloat  LightDiffuse[]  = { 1, 1, 1, 1 };

bool 	light = false;
bool 	diffuse = false;
bool 	emissive = false;
bool 	specular = false;

void Keyboard (unsigned char key, int x, int y)
{
 	if (key=='l')
 	{
 		light=!light;
 		if (!light)
 		{
 			glDisable(GL_LIGHTING);
 		} else
 		{
 			glEnable(GL_LIGHTING);
 		}
 	}
}

void KeyboardSpec (int key, int x, int y)
{

}


void Init()
{
	glEnable (GL_BLEND);
	glEnable (GL_DEPTH_TEST);
	glEnable (GL_COLOR_MATERIAL);
	glEnable (GL_LIGHT1);
}

void SetUpLight ()
{
	glLightfv(GL_LIGHT1, GL_AMBIENT,  LightAmbient);
	glLightfv(GL_LIGHT1, GL_DIFFUSE,  LightDiffuse);
	glLightfv(GL_LIGHT1, GL_POSITION, LightPosition);
}

void Display()
{
	glClearColor(0.2, 0.2, 0.2, 1);
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
	glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
	glLoadIdentity();

	glTranslatef(0, 0, -6);

	glRotatef(rotquad, 1, 0, 0);
	glRotatef(rotquad, 0, 1, 0);

	glBegin(GL_QUADS);					// Start Drawing The Cube

    	glColor4f(1, 0, 0, 1);
		glVertex3f( 1.0f, 1.0f,-1.0f);			// Top Right Of The Quad (Top)
		glVertex3f(-1.0f, 1.0f,-1.0f);			// Top Left Of The Quad (Top)
		glVertex3f(-1.0f, 1.0f, 1.0f);			// Bottom Left Of The Quad (Top)
		glVertex3f( 1.0f, 1.0f, 1.0f);			// Bottom Right Of The Quad (Top)

    	glColor4f(0, 1, 1, 1);
		glVertex3f( 1.0f,-1.0f, 1.0f);			// Top Right Of The Quad (Bottom)
		glVertex3f(-1.0f,-1.0f, 1.0f);			// Top Left Of The Quad (Bottom)
		glVertex3f(-1.0f,-1.0f,-1.0f);			// Bottom Left Of The Quad (Bottom)
		glVertex3f( 1.0f,-1.0f,-1.0f);			// Bottom Right Of The Quad (Bottom)

    	glColor4f(1, 0, 1, 1);
		glVertex3f( 1.0f, 1.0f, 1.0f);			// Top Right Of The Quad (Front)
		glVertex3f(-1.0f, 1.0f, 1.0f);			// Top Left Of The Quad (Front)
		glVertex3f(-1.0f,-1.0f, 1.0f);			// Bottom Left Of The Quad (Front)
		glVertex3f( 1.0f,-1.0f, 1.0f);			// Bottom Right Of The Quad (Front)

    	glColor4f(1, 1, 0, 1);
		glVertex3f( 1.0f,-1.0f,-1.0f);			// Bottom Left Of The Quad (Back)
		glVertex3f(-1.0f,-1.0f,-1.0f);			// Bottom Right Of The Quad (Back)
		glVertex3f(-1.0f, 1.0f,-1.0f);			// Top Right Of The Quad (Back)
		glVertex3f( 1.0f, 1.0f,-1.0f);			// Top Left Of The Quad (Back)

    	glColor4f(0, 0, 1, 1);
		glVertex3f(-1.0f, 1.0f, 1.0f);			// Top Right Of The Quad (Left)
		glVertex3f(-1.0f, 1.0f,-1.0f);			// Top Left Of The Quad (Left)
		glVertex3f(-1.0f,-1.0f,-1.0f);			// Bottom Left Of The Quad (Left)
		glVertex3f(-1.0f,-1.0f, 1.0f);			// Bottom Right Of The Quad (Left)

    	glColor4f(0, 1, 0, 1);
		glVertex3f( 1.0f, 1.0f,-1.0f);			// Top Right Of The Quad (Right)
		glVertex3f( 1.0f, 1.0f, 1.0f);			// Top Left Of The Quad (Right)
		glVertex3f( 1.0f,-1.0f, 1.0f);			// Bottom Left Of The Quad (Right)
		glVertex3f( 1.0f,-1.0f,-1.0f);			// Bottom Right Of The Quad (Right)
	glEnd();

	rotquad -= 1.5f;

	glutSwapBuffers();
}

void OnReshape(int width, int height)
{
	glViewport(0, 0, (GLsizei)width, (GLsizei)height); // Set our viewport to the size of our window
	glMatrixMode(GL_PROJECTION);
	glLoadIdentity();
	gluPerspective(60, (GLfloat)width / (GLfloat)height, 1.0, 100.0);
	glMatrixMode(GL_MODELVIEW); // Switch back to the model view matrix, so that we can start drawing shapes correctly
}

int main(int argc, char **argv)
{
	glutInit(&argc, argv); // Initialize GLUT
	glutInitDisplayMode (GLUT_DOUBLE| GLUT_RGBA); // Set up a basic display buffer (only single buffered for now)
	glutInitWindowSize (500, 500); // Set the width and height of the window
	glutInitWindowPosition (100, 100); // Set the position of the window
	glutCreateWindow ("First GLUT window"); // Set the title for the window

	Init();

	glutDisplayFunc  (Display);
	glutIdleFunc 	(Display);
	glutKeyboardFunc (Keyboard);
	glutSpecialFunc  (KeyboardSpec);
	glutReshapeFunc  (OnReshape);

	glutMainLoop(); // Enter GLUT's main loop

	return 0;
}

few functions may be quite strange, thats because i have combined header and files asociated to it ;) (im not sure that im saing it right because not english :D )

PARTNERS