Salatinjsh

Members
  • Content count

    11
  • Joined

  • Last visited

Community Reputation

106 Neutral

About Salatinjsh

  • Rank
    Member
  1. SDL and opengl textures

    Well thanks for answer. I have tryed usng soil and SDL but no difference and glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); didn't help. Can it be problem with libraries? can they be at wrong positions?
  2. 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.
  3. undefined reference to `WinMain@16

    [quote name='rip-off' timestamp='1309773495' post='4830869'] SDL is #defining your main function to a function called SDL_main. Try to disable this by using #undef main. [/quote] Thank you! everything works fine but now i have next problem i have to solve
  4. 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: [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; } [/code] If i could find way how to load OpenGL textures without SDL and it works for every OS i wouldn't use SDL.
  5. Varables usable in whole project

    Aardvajk, thank you very much and yes i think a frgot to mention language im using i'm using C++ and thanks for "Your inglish is fine" Owl i thank you for your link but i think I have miswritten i ment i can't find "That" not hat about the C++ problem ;)
  6. Hi everyone! I have a little problem , 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 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 With ope for your help Salatinjsh Really wanted to write last 2 lines
  7. OpenGL OpenGL problem with Fog

    [quote name='Brother Bob' timestamp='1307913512' post='4822516'] You're not calling SetUpFog() anywhere. [/quote] i don't have to, because when computer goes through all file it reads it and sets up fog, and i don't need to do it again, do i? It's like with lighting i haven't called it anywhere but it is set Edit: Realy it was the problem, i though it just initializes fog like with light, but then i tryed to add it when i enable fog and it worked, thank you man ;)
  8. Hi guys! I'm again with a problem 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: [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; } [/code]
  9. OpenGL GL lighting problem

    [quote name='bluntman' timestamp='1305820466' post='4813042'] Try glEnable(GL_LIGHTING); Check this out: [url="http://www.sjbaker.org/steve/omniv/opengl_lighting.html"]http://www.sjbaker.o...l_lighting.html[/url] [url="http://translate.google.com/translate?sl=auto&tl=lv&js=n&prev=_t&hl=en&ie=UTF-8&layout=2&eotf=1&u=http%3A%2F%2Fwww.sjbaker.org%2Fsteve%2Fomniv%2Fopengl_lighting.html"]Google translated to latvian, shame it doesn't do the image aswell.[/url] [/quote] Thx nice page, made my mind clear but i still can't get light working :@ :@ EDIT: I GOT THE LIGHT THANK U GUYS!!!!!! I found that the problem realy was with normals
  10. OpenGL GL lighting problem

    may work but i dont know how it works and cant get it working, i'm reading about normals now in opengl website but anyway can't make it working
  11. 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 : [code] #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; }[/code] 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 )