Advertisement
Guest User

LuaJIT-FFI ShivaVG Proof of Concept Test: C Equivalent

a guest
Oct 17th, 2011
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.25 KB | None | 0 0
  1.  
  2. #include <SDL/SDL.h>
  3. #include <vg/openvg.h>
  4. #include <vg/vgu.h>
  5.  
  6. int screenWidth = 640;
  7. int screenHeight = 480;
  8. SDL_Surface* screen;
  9. VGfloat blue[4] = {0, 0, 1, 1};
  10.  
  11. int main(int argc, char* argv[]) {
  12.   SDL_Event e;
  13.   int finished = 0;
  14.  
  15.   SDL_Init(SDL_INIT_VIDEO);
  16.   SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
  17.   SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, 1);
  18.   screen = SDL_SetVideoMode(screenWidth, screenHeight, 0, SDL_OPENGL | SDL_RESIZABLE);
  19.  
  20.   vgCreateContextSH(screenWidth, screenHeight);
  21.  
  22.   vgSetfv(VG_CLEAR_COLOR, 4, blue);
  23.  
  24.   while (!finished) {
  25.     while (SDL_PollEvent(&e)) {
  26.       switch(e.type) {
  27.         case SDL_QUIT:
  28.           finished = 1;
  29.           break;
  30.         case SDL_KEYDOWN:
  31.           if (e.key.keysym.sym == SDLK_ESCAPE) {
  32.             finished = 1;
  33.           }
  34.           break;
  35.         case SDL_VIDEORESIZE:
  36.           screenWidth = e.resize.w;
  37.           screenHeight = e.resize.h;
  38.           screen = SDL_SetVideoMode(screenWidth, screenHeight, 0, SDL_OPENGL | SDL_RESIZABLE);
  39.           vgResizeSurfaceSH(screenWidth, screenHeight);
  40.           break;
  41.       }
  42.     }
  43.     vgClear(0, 0, screenWidth, screenHeight);
  44.     SDL_GL_SwapBuffers();
  45.       SDL_Delay(SDL_TIMESLICE);
  46.   }
  47.   vgDestroyContextSH();
  48.   return 0;
  49. }
  50.  
  51.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement