Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- ** 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;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement