Jump to content

  • Log In with Google      Sign In   
  • Create Account

Awesome job so far everyone! Please give us your feedback on how our article efforts are going. We still need more finished articles for our May contest theme: Remake the Classics

#Actualfip

Posted 13 December 2012 - 04:01 AM

Hi,
Ive tested this SDL simple example and it doesnt run in my gpu neither.... although it initializes the video mode with SDL_OPENGL

example from http://lazyfoo.net/SDL_tutorials/lesson36/index.php

This is driving me nuts.............

I'll post my glut+Opengl window creation & initialization code soon, now i have to leave.

[source lang="cpp"]/*This source code copyrighted by Lazy Foo' Productions (2004-2012)and may not be redistributed without written permission.*///The headers#include "SDL.h"#include "SDL_opengl.h"//Screen attributesconst int SCREEN_WIDTH = 640;const int SCREEN_HEIGHT = 480;const int SCREEN_BPP = 32;//The frame rateconst int FRAMES_PER_SECOND = 60;//Event handlerSDL_Event event;//Rendering flagbool renderQuad = true;//The timerclass Timer{    private:    //The clock time when the timer started    int startTicks;    //The ticks stored when the timer was paused    int pausedTicks;    //The timer status    bool paused;    bool started;    public:    //Initializes variables    Timer();    //The various clock actions    void start();    void stop();    void pause();    void unpause();    //Gets the timer's time    int get_ticks();    //Checks the status of the timer    bool is_started();    bool is_paused();};bool initGL(){    //Initialize Projection Matrix    glMatrixMode( GL_PROJECTION );    glLoadIdentity();    //Initialize Modelview Matrix    glMatrixMode( GL_MODELVIEW );    glLoadIdentity();    //Initialize clear color    glClearColor( 0.f, 0.f, 0.f, 1.f );    //Check for error    GLenum error = glGetError();    if( error != GL_NO_ERROR )    {        printf( "Error initializing OpenGL! %s\n", gluErrorString( error ) );        return false;    }    return true;}bool init(){    //Initialize SDL    if( SDL_Init( SDL_INIT_EVERYTHING ) < 0 )    {        return false;    }    //Create Window    if( SDL_SetVideoMode( SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_BPP, SDL_OPENGL ) == NULL )    {        return false;    }    //Enable unicode    SDL_EnableUNICODE( SDL_TRUE );    //Initialize OpenGL    if( initGL() == false )    {        return false;    }    //Set caption    SDL_WM_SetCaption( "OpenGL Test", NULL );    return true;}void handleKeys( unsigned char key, int x, int y ){    //Toggle quad    if( key == 'q' )    {        renderQuad = !renderQuad;    }}void update(){}void render(){    //Clear color buffer    glClear( GL_COLOR_BUFFER_BIT );    //Render quad    if( renderQuad == true )    {        glBegin( GL_QUADS );            glVertex2f( -0.5f, -0.5f );            glVertex2f(  0.5f, -0.5f );            glVertex2f(  0.5f,  0.5f );            glVertex2f( -0.5f,  0.5f );        glEnd();    }    //Update screen    SDL_GL_SwapBuffers();}void clean_up(){    //Quit SDL    SDL_Quit();}Timer::Timer(){    //Initialize the variables    startTicks = 0;    pausedTicks = 0;    paused = false;    started = false;}void Timer::start(){    //Start the timer    started = true;    //Unpause the timer    paused = false;    //Get the current clock time    startTicks = SDL_GetTicks();}void Timer::stop(){    //Stop the timer    started = false;    //Unpause the timer    paused = false;}void Timer::pause(){    //If the timer is running and isn't already paused    if( ( started == true ) &amp;&amp; ( paused == false ) )    {        //Pause the timer        paused = true;        //Calculate the paused ticks        pausedTicks = SDL_GetTicks() - startTicks;    }}void Timer::unpause(){    //If the timer is paused    if( paused == true )    {        //Unpause the timer        paused = false;        //Reset the starting ticks        startTicks = SDL_GetTicks() - pausedTicks;        //Reset the paused ticks        pausedTicks = 0;    }}int Timer::get_ticks(){    //If the timer is running    if( started == true )    {        //If the timer is paused        if( paused == true )        {            //Return the number of ticks when the timer was paused            return pausedTicks;        }        else        {            //Return the current time minus the start time            return SDL_GetTicks() - startTicks;        }    }    //If the timer isn't running    return 0;}bool Timer::is_started(){    return started;}bool Timer::is_paused(){    return paused;}int main( int argc, char *argv[] ){    //Quit flag    bool quit = false;    //Initialize    if( init() == false )    {        return 1;    }    //The frame rate regulator    Timer fps; //Wait for user exit while( quit == false ) {        //Start the frame timer        fps.start();        //While there are events to handle while( SDL_PollEvent( &amp;event ) ) { if( event.type == SDL_QUIT ) {                quit = true;            }            else if( event.type == SDL_KEYDOWN )            {                //Handle keypress with current mouse position                int x = 0, y = 0;                SDL_GetMouseState( &amp;x, &amp;y );                handleKeys( event.key.keysym.unicode, x, y );            } }        //Run frame update        update();        //Render frame        render();        //Cap the frame rate        if( fps.get_ticks() < 1000 / FRAMES_PER_SECOND )        {            SDL_Delay( ( 1000 / FRAMES_PER_SECOND ) - fps.get_ticks() );        } } //Clean up clean_up(); return 0;}[/source]

#1fip

Posted 13 December 2012 - 03:47 AM

Hi,
Ive tested this SDL simple example and it doesnt run in my gpu neither.... although it initializes the video mode with SDL_OPENGL

example from http://lazyfoo.net/SDL_tutorials/lesson36/index.php

This is driving me nuts.............
[source lang="cpp"]/*This source code copyrighted by Lazy Foo' Productions (2004-2012)and may not be redistributed without written permission.*///The headers#include "SDL.h"#include "SDL_opengl.h"//Screen attributesconst int SCREEN_WIDTH = 640;const int SCREEN_HEIGHT = 480;const int SCREEN_BPP = 32;//The frame rateconst int FRAMES_PER_SECOND = 60;//Event handlerSDL_Event event;//Rendering flagbool renderQuad = true;//The timerclass Timer{    private:    //The clock time when the timer started    int startTicks;    //The ticks stored when the timer was paused    int pausedTicks;    //The timer status    bool paused;    bool started;    public:    //Initializes variables    Timer();    //The various clock actions    void start();    void stop();    void pause();    void unpause();    //Gets the timer's time    int get_ticks();    //Checks the status of the timer    bool is_started();    bool is_paused();};bool initGL(){    //Initialize Projection Matrix    glMatrixMode( GL_PROJECTION );    glLoadIdentity();    //Initialize Modelview Matrix    glMatrixMode( GL_MODELVIEW );    glLoadIdentity();    //Initialize clear color    glClearColor( 0.f, 0.f, 0.f, 1.f );    //Check for error    GLenum error = glGetError();    if( error != GL_NO_ERROR )    {        printf( "Error initializing OpenGL! %s\n", gluErrorString( error ) );        return false;    }    return true;}bool init(){    //Initialize SDL    if( SDL_Init( SDL_INIT_EVERYTHING ) < 0 )    {        return false;    }    //Create Window    if( SDL_SetVideoMode( SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_BPP, SDL_OPENGL ) == NULL )    {        return false;    }    //Enable unicode    SDL_EnableUNICODE( SDL_TRUE );    //Initialize OpenGL    if( initGL() == false )    {        return false;    }    //Set caption    SDL_WM_SetCaption( "OpenGL Test", NULL );    return true;}void handleKeys( unsigned char key, int x, int y ){    //Toggle quad    if( key == 'q' )    {        renderQuad = !renderQuad;    }}void update(){}void render(){    //Clear color buffer    glClear( GL_COLOR_BUFFER_BIT );    //Render quad    if( renderQuad == true )    {        glBegin( GL_QUADS );            glVertex2f( -0.5f, -0.5f );            glVertex2f(  0.5f, -0.5f );            glVertex2f(  0.5f,  0.5f );            glVertex2f( -0.5f,  0.5f );        glEnd();    }    //Update screen    SDL_GL_SwapBuffers();}void clean_up(){    //Quit SDL    SDL_Quit();}Timer::Timer(){    //Initialize the variables    startTicks = 0;    pausedTicks = 0;    paused = false;    started = false;}void Timer::start(){    //Start the timer    started = true;    //Unpause the timer    paused = false;    //Get the current clock time    startTicks = SDL_GetTicks();}void Timer::stop(){    //Stop the timer    started = false;    //Unpause the timer    paused = false;}void Timer::pause(){    //If the timer is running and isn't already paused    if( ( started == true ) && ( paused == false ) )    {        //Pause the timer        paused = true;        //Calculate the paused ticks        pausedTicks = SDL_GetTicks() - startTicks;    }}void Timer::unpause(){    //If the timer is paused    if( paused == true )    {        //Unpause the timer        paused = false;        //Reset the starting ticks        startTicks = SDL_GetTicks() - pausedTicks;        //Reset the paused ticks        pausedTicks = 0;    }}int Timer::get_ticks(){    //If the timer is running    if( started == true )    {        //If the timer is paused        if( paused == true )        {            //Return the number of ticks when the timer was paused            return pausedTicks;        }        else        {            //Return the current time minus the start time            return SDL_GetTicks() - startTicks;        }    }    //If the timer isn't running    return 0;}bool Timer::is_started(){    return started;}bool Timer::is_paused(){    return paused;}int main( int argc, char *argv[] ){    //Quit flag    bool quit = false;    //Initialize    if( init() == false )    {        return 1;    }    //The frame rate regulator    Timer fps; //Wait for user exit while( quit == false ) {        //Start the frame timer        fps.start();        //While there are events to handle while( SDL_PollEvent( &event ) ) { if( event.type == SDL_QUIT ) {                quit = true;            }            else if( event.type == SDL_KEYDOWN )            {                //Handle keypress with current mouse position                int x = 0, y = 0;                SDL_GetMouseState( &x, &y );                handleKeys( event.key.keysym.unicode, x, y );            } }        //Run frame update        update();        //Render frame        render();        //Cap the frame rate        if( fps.get_ticks() < 1000 / FRAMES_PER_SECOND )        {            SDL_Delay( ( 1000 / FRAMES_PER_SECOND ) - fps.get_ticks() );        } } //Clean up clean_up(); return 0;}[/source]

PARTNERS