Note that there are some explanatory texts on larger screens.

plurals
  1. POSDL OpenGL C++ problem
    primarykey
    data
    text
    <p>I'm trying to make a simple game of pong using SDL and OpenGL in C++ and I'm having trouble displaying any sort of OpenGL image onto the screen and was wondering if anybody could help: </p> <p>Initialization: </p> <pre><code>void init_everything() { SDL_Init( SDL_INIT_EVERYTHING ); SDL_SetVideoMode( width_of_screen, height_of_screen, bpp_of_screen, SDL_OPENGL ); glClearColor( 0, 0, 0, 0 ); // Sets the projection glMatrixMode( GL_PROJECTION ); glLoadIdentity(); glOrtho( 0, width_of_screen, height_of_screen, 0, 1, -1 ); // initalises the modelview matrix glMatrixMode( GL_MODELVIEW ); glLoadIdentity(); SDL_WM_SetCaption( "Pong - By Michael Clover", NULL ); } </code></pre> <p>After this I call the class function: </p> <pre><code>void paddle::show() { //Move to offset glTranslatef( x, y, 0 ); //Start quad glBegin( GL_QUADS ); //Set color to white glColor4f( 1.0, 1.0, 1.0, 1.0 ); //Draw square glVertex3f( 0, 0, 0 ); glVertex3f( paddle_width, 0, 0 ); glVertex3f( paddle_width, paddle_height, 0 ); glVertex3f( 0, paddle_height, 0 ); //End quad glEnd(); //Reset glLoadIdentity(); } </code></pre> <p>I then put this in my main function: </p> <pre><code>int main( int argc, char **argv ) { bool quit = false; init_everything(); paddle playerpaddle; while (quit == false ) { while( SDL_PollEvent( &amp;event ) ) { playerpaddle.handle_input(); if (event.type == SDL_QUIT) { quit = true; } } playerpaddle.move(); glClear( GL_COLOR_BUFFER_BIT ); playerpaddle.show(); SDL_GL_SwapBuffers(); } clean_up(); return 0; } </code></pre> <p>All I get is a constant black background screen that I set within a 640 by 480px SDL screen. </p> <p>Sorry for the huge amount of text and I would be extremely grateful for any insight on what the problem could be here, I'm guessing I'm making a silly mistake somewhere.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload