2010-10-12 10:55:23 +02:00
|
|
|
/*
|
2011-03-05 13:44:21 +01:00
|
|
|
* This software is licensed under the terms of the MIT-License
|
|
|
|
* See COPYING for further information.
|
|
|
|
* ---
|
|
|
|
* Copyright (C) 2011, Lukas Weber <laochailan@web.de>
|
2010-10-12 10:55:23 +02:00
|
|
|
*/
|
|
|
|
|
2011-06-26 20:23:28 +02:00
|
|
|
#include <SDL.h>
|
2011-06-26 16:10:13 +02:00
|
|
|
#include <GL/glew.h>
|
|
|
|
#include "taisei_err.h"
|
2010-10-12 10:55:23 +02:00
|
|
|
|
|
|
|
#include "global.h"
|
|
|
|
#include "stages/stage0.h"
|
2011-06-13 18:48:36 +02:00
|
|
|
#include "menu/mainmenu.h"
|
2010-10-12 10:55:23 +02:00
|
|
|
|
2011-06-26 20:23:28 +02:00
|
|
|
|
2010-10-18 14:40:15 +02:00
|
|
|
SDL_Surface *display;
|
|
|
|
|
2010-10-12 10:55:23 +02:00
|
|
|
void init_gl() {
|
|
|
|
glClearColor(0, 0, 0, 0);
|
|
|
|
|
|
|
|
glShadeModel(GL_SMOOTH);
|
|
|
|
glEnable(GL_BLEND);
|
2011-04-25 19:40:21 +02:00
|
|
|
|
|
|
|
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
2010-10-12 10:55:23 +02:00
|
|
|
|
|
|
|
glEnable(GL_LINE_SMOOTH);
|
|
|
|
glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);
|
|
|
|
|
|
|
|
glViewport(0, 0, SCREEN_W, SCREEN_H);
|
2011-06-13 18:48:36 +02:00
|
|
|
|
2011-03-23 12:26:30 +01:00
|
|
|
glClearDepth(1.0);
|
|
|
|
glEnable(GL_DEPTH_TEST);
|
|
|
|
glDepthFunc(GL_LEQUAL);
|
2010-10-12 10:55:23 +02:00
|
|
|
glEnable(GL_CULL_FACE);
|
|
|
|
glCullFace(GL_BACK);
|
|
|
|
}
|
|
|
|
|
2010-10-18 14:40:15 +02:00
|
|
|
void shutdown() {
|
2011-03-19 16:21:48 +01:00
|
|
|
delete_textures();
|
|
|
|
delete_animations();
|
2011-04-25 19:40:21 +02:00
|
|
|
delete_sounds();
|
|
|
|
delete_shaders();
|
2011-03-19 16:21:48 +01:00
|
|
|
|
2011-04-02 12:14:37 +02:00
|
|
|
alutExit();
|
2010-10-18 14:40:15 +02:00
|
|
|
SDL_FreeSurface(display);
|
|
|
|
SDL_Quit();
|
|
|
|
}
|
|
|
|
|
2010-10-12 10:55:23 +02:00
|
|
|
int main(int argc, char** argv) {
|
2011-06-26 20:23:28 +02:00
|
|
|
printf("initialize:\n");
|
2010-10-12 10:55:23 +02:00
|
|
|
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");
|
|
|
|
|
2010-10-12 10:55:23 +02:00
|
|
|
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
|
2011-04-25 19:40:21 +02:00
|
|
|
if((display = SDL_SetVideoMode(SCREEN_W, SCREEN_H, 32, SDL_OPENGL)) == NULL)
|
2010-10-12 10:55:23 +02:00
|
|
|
errx(-1, "Error opening screen: %s", SDL_GetError());
|
2011-06-26 20:23:28 +02:00
|
|
|
|
|
|
|
printf("-- SDL viewport\n");
|
|
|
|
|
2011-06-13 18:48:36 +02:00
|
|
|
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 16:10:13 +02:00
|
|
|
|
2011-06-26 20:23:28 +02:00
|
|
|
printf("-- GLEW\n");
|
2010-10-12 10:55:23 +02:00
|
|
|
init_gl();
|
2011-06-26 20:23:28 +02:00
|
|
|
|
|
|
|
printf("-- GL\n");
|
2011-04-25 19:40:21 +02:00
|
|
|
|
2011-04-02 12:14:37 +02:00
|
|
|
if(!alutInit(&argc, argv))
|
|
|
|
errx(-1, "Error initializing audio: %s", alutGetErrorString(alutGetError()));
|
2011-06-26 20:23:28 +02:00
|
|
|
printf("-- ALUT\n");
|
|
|
|
|
2010-10-12 10:55:23 +02:00
|
|
|
init_global();
|
2011-06-26 20:23:28 +02:00
|
|
|
printf("-- initialized gamedata\n");
|
2011-06-13 18:48:36 +02:00
|
|
|
MenuData menu;
|
|
|
|
create_main_menu(&menu);
|
2011-06-26 20:23:28 +02:00
|
|
|
printf("-- menu\n");
|
2011-06-13 18:48:36 +02:00
|
|
|
|
|
|
|
main_menu_loop(&menu);
|
2010-10-12 10:55:23 +02:00
|
|
|
|
2011-05-08 13:48:25 +02:00
|
|
|
shutdown();
|
|
|
|
|
|
|
|
return 1;
|
2010-10-12 10:55:23 +02:00
|
|
|
}
|