taisei/src/main.c

88 lines
1.7 KiB
C
Raw Normal View History

/*
* This software is licensed under the terms of the MIT-License
* See COPYING for further information.
* ---
* Copyright (C) 2011, Lukas Weber <laochailan@web.de>
*/
2011-06-26 20:23:28 +02:00
#include <SDL.h>
#include <GL/glew.h>
#include "taisei_err.h"
#include "global.h"
#include "stages/stage0.h"
#include "menu/mainmenu.h"
2011-06-26 20:23:28 +02:00
SDL_Surface *display;
void init_gl() {
glClearColor(0, 0, 0, 0);
glShadeModel(GL_SMOOTH);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_LINE_SMOOTH);
glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);
glViewport(0, 0, SCREEN_W, SCREEN_H);
glClearDepth(1.0);
glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_LEQUAL);
glEnable(GL_CULL_FACE);
glCullFace(GL_BACK);
}
void shutdown() {
delete_textures();
delete_animations();
delete_sounds();
delete_shaders();
alutExit();
SDL_FreeSurface(display);
SDL_Quit();
}
int main(int argc, char** argv) {
2011-06-26 20:23:28 +02:00
printf("initialize:\n");
if(SDL_Init(SDL_INIT_VIDEO) < 0)
errx(-1, "Error initializing SDL: %s", SDL_GetError());
2011-06-26 20:23:28 +02:00
printf("-- SDL_Init\n");
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
if((display = SDL_SetVideoMode(SCREEN_W, SCREEN_H, 32, SDL_OPENGL)) == NULL)
errx(-1, "Error opening screen: %s", SDL_GetError());
2011-06-26 20:23:28 +02:00
printf("-- SDL viewport\n");
SDL_WM_SetCaption("TaiseiProject", NULL);
2011-06-26 20:23:28 +02:00
int e;
if((e = glewInit()) != GLEW_OK)
errx(-1, "GLEW failed: %s", glewGetErrorString(e));
2011-06-26 20:23:28 +02:00
printf("-- GLEW\n");
init_gl();
2011-06-26 20:23:28 +02:00
printf("-- GL\n");
if(!alutInit(&argc, argv))
errx(-1, "Error initializing audio: %s", alutGetErrorString(alutGetError()));
2011-06-26 20:23:28 +02:00
printf("-- ALUT\n");
init_global();
2011-06-26 20:23:28 +02:00
printf("-- initialized gamedata\n");
MenuData menu;
create_main_menu(&menu);
2011-06-26 20:23:28 +02:00
printf("-- menu\n");
main_menu_loop(&menu);
shutdown();
return 1;
}