sys::DO_FADE()
{
for (int f=0;f<255;f++)
{
glClearColor(f,f,f,f);
SDL_Delay(0);
glLoadIdentity();
}
}
while game
clear color bit
handle keys
aSYS.DO_FADE();
SDL_GL_SwapBuffers();
sys::DO_FADE()
{
for (int f=0;f<255;f++)
{
glClearColor(f,f,f,f);
SDL_Delay(0);
glLoadIdentity();
}
}
while game
clear color bit
handle keys
aSYS.DO_FADE();
SDL_GL_SwapBuffers();
Quote:Original post by cow_in_the_well
a. In your loop, you're setting the clear colour but not actually clearing the buffer on each iteration.
b. You're not swapping the buffer on each iteration, so you'll only see the final colour (ie. white).
c. glLoadIdentity in the loop isn't going to do anything useful.
d. It'll probably happen WAYYYY to fast since you're not doing any delay.
e. Why not use a full screen quad and fade that from fully transparent to fully opaque?
f. It may be what you intend, but the DO_FADE is going to block the rest of the application until the fade is finished (e.g. you won't be able to fade out over the top of a game that is running).
for (GLfloat i=0.0f;i<255.0f;i++){glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);glLoadIdentity();glTranslatef( 0,0, 0 );glBegin( GL_QUADS );glColor4f(i,i,i,i);glVertex3f( 0,0,0 );glVertex3f( SCREEN_WIDTH, 0,0 );glVertex3f( SCREEN_WIDTH, SCREEN_HEIGHT,0 );glVertex3f( 0,SCREEN_HEIGHT, 0 );glEnd();SDL_GL_SwapBuffers();}
Quote:Original post by cow_in_the_well
f. It may be what you intend, but the DO_FADE is going to block the rest of the application until the fade is finished (e.g. you won't be able to fade out over the top of a game that is running).
glMatrixMode(GL_PROJECTION);glLoadIdentity(); glOrtho(0,SCREEN_WIDTH,SCREEN_WIDTH,0,-1,1);glMatrixMode(GL_MODELVIEW);glLoadIdentity();
for (GLfloat i=0.0f;i<256.0f;i++){glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);glLoadIdentity();glTranslatef( 0,0, 0 );glLoadIdentity();glBegin( GL_QUADS );glColor4ub(i,i,i,i);glVertex3f( 0,0,0 );glVertex3f( SCREEN_WIDTH, 0,0 );glVertex3f( SCREEN_WIDTH, SCREEN_HEIGHT,0 );glVertex3f( 0,SCREEN_HEIGHT, 0 );glEnd();SDL_GL_SwapBuffers();SDL_Delay(1);}
Quote:Original post by 3Dgonewild
edited:
My desktop resolution is setted to 1024x768..the game is setted to 800x600.
The weird thing is , that if i set the game's resolution to 1024x768 everything's fine..
GLfloat _div = ( GLfloat ) SCREEN_WIDTH / ( GLfloat )SCREEN_HEIGHT; glViewport( 0, 0, ( GLint ) SCREEN_WIDTH , ( GLint )SCREEN_HEIGHT );glMatrixMode(GL_PROJECTION);glLoadIdentity(); gluPerspective( 45.0f, _div, 0.1f, 100.0f );glMatrixMode(GL_MODELVIEW);glLoadIdentity();
Quote:Original post by 3Dgonewild
I've edited the open gl init function a little:
*** Source Snippet Removed ***
And now , i cant draw 2d objects...just 3d..
Quote:Original post by Brother BobQuote:Original post by 3Dgonewild
I've edited the open gl init function a little:
*** Source Snippet Removed ***
And now , i cant draw 2d objects...just 3d..
If you insist on setting the projection matrix just once at startup, then yes, it will be dificult to mix them. But nothing stops you from changing it while the program is running. While drawing, set projection matrix to perspective and draw the 3D object. Change it to orthographic and draw the 2D objects. Repeat as many times as you like.