Results 1 to 3 of 3
  1. Xeron's Avatar
    Posts
    237 Posts
    Global Posts
    250 Global Posts
       #1  
    Hello,

    I have written software before using SDL/OpenGL, but I have never used OpenGL-ES before. I also have never written any software for webOS before (i intended to when i got my pre last year, but never did. Getting a touchpad has rekindled my interest...)

    At the moment, I just want to set up a 2D orthographic view and get a square on the screen, but all I seem to be able to get is a black empty card.

    Here is the code:
    Code:
    /*
    ** Ortho test
    */
    
    #include <stdio.h>
    
    #include <GLES/gl.h>
    #include "SDL.h"
    #include "PDL.h"
    
    SDL_Surface *surface = NULL;               // Screen surface to retrieve width/height information
    
    GLfloat square[] = {
    	0.25, 0.25, 0.0,
    	0.75, 0.25, 0.0,
    	0.25, 0.75, 0.0,
    	0.75, 0.75, 0.0
        };
    
    int init( void )
    {
      glClearColor (0.0f, 0.0f, 0.7f, 1.0f);
    
      glMatrixMode(GL_PROJECTION);
      glLoadIdentity();
      glOrthof(0.0f, 1.0f, 0.0f, 1.0f, -1.0f, 1.0f);
      glMatrixMode(GL_MODELVIEW);
    
      return 1;
    }
    
    void shut( void )
    {
    }
    
    void display()
    {
      glLoadIdentity();
      glClear (GL_COLOR_BUFFER_BIT);
    
      glEnableClientState(GL_VERTEX_ARRAY);
      glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
      glVertexPointer(3, GL_FLOAT, 0, square);
      glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
      glDisableClientState(GL_VERTEX_ARRAY);
    
      SDL_GL_SwapBuffers();
    }
    
    int main( int argc, char** argv )
    {
      // Initialize the SDL library with the Video subsystem
      SDL_Init(SDL_INIT_VIDEO | SDL_INIT_NOPARACHUTE);
      atexit(SDL_Quit);
        
      // start the PDL library
      PDL_Init(0);
      atexit(PDL_Quit);
    
      PDL_SetOrientation(PDL_ORIENTATION_90);
        
      // Set the video mode to full screen with OpenGL-ES support
      // use zero for width/height to use maximum resolution
      surface = SDL_SetVideoMode(0, 0, 0, SDL_OPENGL);
    
      init();
    
    
      // Event descriptor
      SDL_Event Event;
      SDL_bool paused = SDL_FALSE;
      SDL_bool done = SDL_FALSE;
    
      while( !done )
      {
        // Render our scene
        display();
    
        SDL_bool gotEvent;
        if (paused)
        {
          SDL_WaitEvent(&Event);
          gotEvent = SDL_TRUE;
        }
        else
        {
          gotEvent = SDL_PollEvent(&Event);
        }
            
        while( gotEvent )
        {
          switch (Event.type)
          {
            // List of keys that have been pressed
            case SDL_KEYDOWN:
              switch (Event.key.keysym.sym)
              {
                case PDLK_GESTURE_BACK: /* also maps to ESC */
                  if( PDL_GetPDKVersion() >= 200 )
                  {
                    // standard behavior is to minimize to a card when you perform a back
                    // gesture at the top level of the app
                    PDL_Minimize();
                  }
                  break;
    
                default:
                  break;
              }
              break;
    
            case SDL_ACTIVEEVENT:
              if( Event.active.state == SDL_APPACTIVE )
              {
                paused = !Event.active.gain;
              }
              break;
    
            case SDL_QUIT:
              // We exit anytime we get a request to quit the app
              // all shutdown code is registered via atexit() so this is clean.
              done = SDL_TRUE;
              break;
    
            default:
              break;
          }
          gotEvent = SDL_PollEvent(&Event);
        }
      }
    
      shut();
    
      return 0;
    }
    I know its a bit ugly, this is just test code at this point. Why do I get nothing on the screen?
  2. #2  
    Any luck with this? I am also having trouble doing the same thing
  3. Xeron's Avatar
    Posts
    237 Posts
    Global Posts
    250 Global Posts
       #3  
    I was so close. I just needed to put a call in setting the gl major version to 1. Now it works fine.

Posting Permissions