Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //
- // main.c
- // myapp
- //
- // Created by David on 15/06/2011.
- // Copyright 2011 __MyCompanyName__. All rights reserved.
- //
- #include <stdio.h>
- #include <stdlib.h>
- #include "myapp/myapp.h"
- static const int screen_width = 320;
- static const int screen_height = 480;
- static SDL_Window *win;
- static SDL_GLContext glcontext;
- void sdl_error_die() {
- printf("Error: %s\n", SDL_GetError());
- exit(1);
- }
- int main(int argc, char *argv[]) {
- if(SDL_Init(SDL_INIT_VIDEO) < 0) {
- sdl_error_die();
- }
- win = SDL_CreateWindow(NULL, 0, 0, screen_width, screen_height, \
- SDL_WINDOW_OPENGL | SDL_WINDOW_BORDERLESS | \
- SDL_WINDOW_RESIZABLE | SDL_WINDOW_SHOWN);
- if(!win) {
- sdl_error_die();
- }
- glcontext = SDL_GL_CreateContext(win);
- if (glcontext==NULL)
- {
- sdl_error_die();
- }
- SDL_GL_SetSwapInterval(1);
- // glMatrixMode(GL_PROJECTION
- int running = 1;
- SDL_Event event;
- while(running) {
- while(SDL_PollEvent(&event)) {
- if(event.type == SDL_WINDOWEVENT && event.window.event == SDL_WINDOWEVENT_RESIZED) {
- printf("Rotated...\n");
- }
- if(event.type == SDL_QUIT) {
- running = 0;
- }
- if(event.type == SDL_FINGERDOWN) {
- printf("touch\n");
- }
- }
- glClearColor(1.0, 0.0, 0.0, 1.0);
- glClear(GL_COLOR_BUFFER_BIT);
- }
- SDL_GL_DeleteContext(glcontext);
- SDL_DestroyWindow(win);
- SDL_Quit();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement