Advertisement
Guest User

Untitled

a guest
Jun 15th, 2011
311
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //
  2. //  main.c
  3. //  myapp
  4. //
  5. //  Created by David on 15/06/2011.
  6. //  Copyright 2011 __MyCompanyName__. All rights reserved.
  7. //
  8. #include <stdio.h>
  9. #include <stdlib.h>
  10. #include "myapp/myapp.h"
  11.  
  12. static const int screen_width = 320;
  13. static const int screen_height = 480;
  14.  
  15. static SDL_Window *win;
  16. static SDL_GLContext glcontext;
  17.  
  18. void sdl_error_die() {
  19.    printf("Error: %s\n", SDL_GetError());
  20.    exit(1);
  21. }
  22.  
  23. int main(int argc, char *argv[]) {
  24.    if(SDL_Init(SDL_INIT_VIDEO) < 0) {
  25.       sdl_error_die();
  26.    }
  27.    
  28.    win = SDL_CreateWindow(NULL, 0, 0, screen_width, screen_height, \
  29.                           SDL_WINDOW_OPENGL | SDL_WINDOW_BORDERLESS | \
  30.                           SDL_WINDOW_RESIZABLE | SDL_WINDOW_SHOWN);
  31.    if(!win) {
  32.       sdl_error_die();
  33.    }
  34.    
  35.    glcontext = SDL_GL_CreateContext(win);
  36.    if (glcontext==NULL)
  37.    {
  38.       sdl_error_die();
  39.    }
  40.    
  41.    SDL_GL_SetSwapInterval(1);
  42.    
  43.    //   glMatrixMode(GL_PROJECTION
  44.    
  45.    int running = 1;
  46.    SDL_Event event;
  47.    
  48.    while(running) {
  49.       while(SDL_PollEvent(&event)) {
  50.          if(event.type == SDL_WINDOWEVENT && event.window.event == SDL_WINDOWEVENT_RESIZED) {
  51.             printf("Rotated...\n");
  52.          }
  53.          if(event.type == SDL_QUIT) {
  54.             running = 0;
  55.          }
  56.          if(event.type == SDL_FINGERDOWN) {
  57.             printf("touch\n");
  58.          }
  59.       }
  60.       glClearColor(1.0, 0.0, 0.0, 1.0);
  61.       glClear(GL_COLOR_BUFFER_BIT);
  62.    }
  63.    
  64.    SDL_GL_DeleteContext(glcontext);
  65.    SDL_DestroyWindow(win);
  66.    SDL_Quit();
  67.    return 0;
  68. }
Advertisement
RAW Paste Data Copied
Advertisement