hi!
can anybody tell me, whats wrong with that code? the polygon i'm attempting to draw doesnt appear on the screen, but as in the original example, the 2d quad does appear on the screen!?!
Sample.cpp:
Engine.cpp:Code:#include <SDL/SDL.h> #include "glut.h" #include "Engine.h" void RefreshScreen() { glClearColor(0, 0, 0, 0); glClear(GL_COLOR_BUFFER_BIT); glLoadIdentity(); //working properly: /*glBegin(GL_QUADS); glColor3ub(255, 0, 0); glVertex2i(0, 240); glColor3ub(0, 255, 0); glVertex2i(240, 240); glColor3ub(0, 0, 255); glVertex2i(240, 480); glColor3ub(255, 255, 0); glVertex2i(0, 480); glEnd();*/ //not working: glBegin(GL_TRIANGLES); glColor3ub(255, 0, 0); glVertex3f(-1, -.5, 3); glColor3ub(0, 255, 0); glVertex3f(1, -.5, 3); glColor3ub(0, 0, 255); glVertex3f(0, .5, 3); glEnd(); } int main(int argc, char *argv[]) { EngineInit(640, 480, 32); bool done = false; while(!done) { SDL_Event event; while(SDL_PollEvent(&event)) { switch(event.type) { case SDL_KEYDOWN: case SDL_QUIT: done = true; break; } } RefreshScreen(); SDL_GL_SwapBuffers(); } EngineFree(); return(0); }thanks for upcoming helpCode:#include <SDL/SDL.h> #include "glut.h" class Engine { public: SDL_Surface *screen; }; Engine engine; void EngineInit(int width, int height, int depth) { SDL_Init(SDL_INIT_VIDEO); SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 5); SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 5); SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 5); SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 16); SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); engine.screen = SDL_SetVideoMode(width, height, depth, SDL_OPENGL); glViewport(0, 0, engine.screen->w, engine.screen->h); glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho(0, engine.screen->w, engine.screen->h, 0, -1, 1); glMatrixMode(GL_MODELVIEW); } void EngineFree() { }![]()



LinkBack URL
About LinkBacks




CornedBee
