use glew and err.h replacement
some changes for compatibility and windows.
This commit is contained in:
parent
5a2ac5b7ba
commit
e470236379
25 changed files with 145 additions and 36 deletions
46
FindGLEW.cmake
Normal file
46
FindGLEW.cmake
Normal file
|
@ -0,0 +1,46 @@
|
|||
# Try to find GLEW library and include path.
|
||||
# Once done this will define
|
||||
#
|
||||
# GLEW_FOUND
|
||||
# GLEW_INCLUDE_PATH
|
||||
# GLEW_LIBRARY
|
||||
#
|
||||
|
||||
IF (WIN32)
|
||||
FIND_PATH( GLEW_INCLUDE_PATH GL/glew.h
|
||||
$ENV{PROGRAMFILES}/GLEW/include
|
||||
${PROJECT_SOURCE_DIR}/src/nvgl/glew/include
|
||||
DOC "The directory where GL/glew.h resides")
|
||||
FIND_LIBRARY( GLEW_LIBRARY
|
||||
NAMES glew GLEW glew32 glew32s
|
||||
PATHS
|
||||
$ENV{PROGRAMFILES}/GLEW/lib
|
||||
${PROJECT_SOURCE_DIR}/src/nvgl/glew/bin
|
||||
${PROJECT_SOURCE_DIR}/src/nvgl/glew/lib
|
||||
DOC "The GLEW library")
|
||||
ELSE (WIN32)
|
||||
FIND_PATH( GLEW_INCLUDE_PATH GL/glew.h
|
||||
/usr/include
|
||||
/usr/local/include
|
||||
/sw/include
|
||||
/opt/local/include
|
||||
DOC "The directory where GL/glew.h resides")
|
||||
FIND_LIBRARY( GLEW_LIBRARY
|
||||
NAMES GLEW glew
|
||||
PATHS
|
||||
/usr/lib64
|
||||
/usr/lib
|
||||
/usr/local/lib64
|
||||
/usr/local/lib
|
||||
/sw/lib
|
||||
/opt/local/lib
|
||||
DOC "The GLEW library")
|
||||
ENDIF (WIN32)
|
||||
|
||||
IF (GLEW_INCLUDE_PATH)
|
||||
SET( GLEW_FOUND 1 CACHE STRING "Set to 1 if GLEW is found, 0 otherwise")
|
||||
ELSE (GLEW_INCLUDE_PATH)
|
||||
SET( GLEW_FOUND 0 CACHE STRING "Set to 1 if GLEW is found, 0 otherwise")
|
||||
ENDIF (GLEW_INCLUDE_PATH)
|
||||
|
||||
MARK_AS_ADVANCED( GLEW_FOUND )
|
3
README
3
README
|
@ -9,8 +9,9 @@ Taisei is an open clone of the Touhou series. Touhou is a one-man project of sho
|
|||
Dependencies:
|
||||
- SDL, SDL_ttf
|
||||
- libpng
|
||||
- OpenGL
|
||||
- OpenGL, GLEW
|
||||
- OpenAL, ALUT
|
||||
- flex/bison
|
||||
- CMake (build system)
|
||||
|
||||
To build and install Taisei just follow these steps.
|
||||
|
|
|
@ -6,6 +6,7 @@ find_package(OpenAL REQUIRED)
|
|||
find_package(ALUT REQUIRED)
|
||||
find_package(PNG REQUIRED)
|
||||
find_package(SDL_ttf REQUIRED)
|
||||
find_package(GLEW REQUIRED)
|
||||
find_package(BISON)
|
||||
find_package(FLEX)
|
||||
|
||||
|
@ -38,15 +39,17 @@ set(SRCs
|
|||
resource/font.c
|
||||
resource/shader.c
|
||||
resource/audio.c
|
||||
taisei_err.c
|
||||
${BISON_cfgparser_OUTPUTS}
|
||||
${FLEX_cfgscanner_OUTPUTS})
|
||||
|
||||
add_definitions(-DPREFIX="${CMAKE_INSTALL_PREFIX}" -DGL_GLEXT_PROTOTYPES)
|
||||
add_definitions(-DPREFIX="${CMAKE_INSTALL_PREFIX}")
|
||||
|
||||
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
|
||||
|
||||
include_directories(${SDL_INCLUDE_DIRS} ${ALUT_INCLUDE_DIRS})
|
||||
add_executable(taisei ${SRCs})
|
||||
target_link_libraries(taisei ${SDL_LIBRARY} ${OPENGL_LIBRARY} ${PNG_LIBRARY} ${SDLTTF_LIBRARY} ${OPENAL_LIBRARY} ${ALUT_LIBRARY})
|
||||
target_link_libraries(taisei ${SDL_LIBRARY} ${OPENGL_LIBRARY} ${PNG_LIBRARY}
|
||||
${SDLTTF_LIBRARY} ${OPENAL_LIBRARY} ${ALUT_LIBRARY} ${GLEW_LIBRARY})
|
||||
|
||||
install(TARGETS taisei RUNTIME DESTINATION bin)
|
||||
|
|
12
src/config.l
12
src/config.l
|
@ -40,14 +40,14 @@
|
|||
|
||||
|
||||
[0-9]+ { yylval = atoi(yytext); return NUMBER; }
|
||||
[a-zA-Z] { yylval = yytext[0]; return CHAR; }
|
||||
[a-zA-Z] { yylval = yytext[0]; return tCHAR; }
|
||||
|
||||
ä { yylval = SDLK_WORLD_68; return CHAR; }
|
||||
ü { yylval = SDLK_WORLD_92; return CHAR; }
|
||||
ö { yylval = SDLK_WORLD_86; return CHAR; }
|
||||
ß { yylval = SDLK_WORLD_63; return CHAR; }
|
||||
ä { yylval = SDLK_WORLD_68; return tCHAR; }
|
||||
ü { yylval = SDLK_WORLD_92; return tCHAR; }
|
||||
ö { yylval = SDLK_WORLD_86; return tCHAR; }
|
||||
ß { yylval = SDLK_WORLD_63; return tCHAR; }
|
||||
|
||||
K[0-9]+ { yylval = atoi(yytext + 1); return CHAR; }
|
||||
K[0-9]+ { yylval = atoi(yytext + 1); return tCHAR; }
|
||||
|
||||
\n return LB;
|
||||
[ \t] ;
|
||||
|
|
|
@ -39,7 +39,7 @@
|
|||
%token SKEY
|
||||
|
||||
%token NUMBER
|
||||
%token CHAR
|
||||
%token tCHAR
|
||||
|
||||
%token SEMI
|
||||
%token EQ
|
||||
|
@ -57,7 +57,7 @@ line : line nl
|
|||
| nl;
|
||||
|
||||
key_val : SKEY
|
||||
| CHAR;
|
||||
| tCHAR;
|
||||
|
||||
key_key : tKEY_UP
|
||||
| tKEY_DOWN
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
|
||||
#include "fbo.h"
|
||||
#include "global.h"
|
||||
#include "taisei_err.h"
|
||||
|
||||
void init_fbo(FBO *fbo) {
|
||||
glGenTextures(1, &fbo->tex);
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
#ifndef FBO_H
|
||||
#define FBO_H
|
||||
|
||||
#include <SDL/SDL_opengl.h>
|
||||
#include <GL/glew.h>
|
||||
|
||||
typedef struct {
|
||||
GLuint fbo;
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
#include "global.h"
|
||||
#include <SDL/SDL.h>
|
||||
#include <time.h>
|
||||
#include <err.h>
|
||||
|
||||
Global global;
|
||||
|
||||
|
|
|
@ -118,7 +118,7 @@ void init_rtt();
|
|||
void game_over();
|
||||
|
||||
void frame_rate();
|
||||
|
||||
void calc_fps(FPSCounter *fps);
|
||||
void set_ortho();
|
||||
|
||||
#endif
|
|
@ -2,8 +2,7 @@
|
|||
* This software is licensed under the terms of the MIT-License
|
||||
* See COPYING for further information.
|
||||
* ---
|
||||
* Copyright (C) 2011, Lukas Weber <laochailan@web.de>
|
||||
* Code by Juergen Kieslich
|
||||
* Copyright (C) 2011, Lukas Weber <laochailan@web.de>, Juergen Kieslich
|
||||
*/
|
||||
|
||||
#include "item.h"
|
||||
|
|
10
src/main.c
10
src/main.c
|
@ -6,8 +6,8 @@
|
|||
*/
|
||||
|
||||
#include <SDL/SDL.h>
|
||||
#include <SDL/SDL_opengl.h>
|
||||
#include <err.h>
|
||||
#include <GL/glew.h>
|
||||
#include "taisei_err.h"
|
||||
|
||||
#include "global.h"
|
||||
#include "stages/stage0.h"
|
||||
|
@ -51,12 +51,16 @@ int main(int argc, char** argv) {
|
|||
errx(-1, "Error initializing SDL: %s", SDL_GetError());
|
||||
|
||||
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
|
||||
SDL_GL_SetAttribute(SDL_GL_SWAP_CONTROL, 0);
|
||||
if((display = SDL_SetVideoMode(SCREEN_W, SCREEN_H, 32, SDL_OPENGL)) == NULL)
|
||||
errx(-1, "Error opening screen: %s", SDL_GetError());
|
||||
|
||||
SDL_WM_SetCaption("TaiseiProject", NULL);
|
||||
|
||||
int err;
|
||||
if((err = glewInit()) != GLEW_OK)
|
||||
errx(-1, "GLEW failed: %s", glewGetErrorString(err));
|
||||
|
||||
|
||||
init_gl();
|
||||
|
||||
if(!alutInit(&argc, argv))
|
||||
|
|
|
@ -55,5 +55,5 @@ void draw_difficulty_menu(MenuData *menu) {
|
|||
}
|
||||
|
||||
int difficulty_menu_loop(MenuData *menu) {
|
||||
menu_loop(menu, NULL, draw_difficulty_menu);
|
||||
return menu_loop(menu, NULL, draw_difficulty_menu);
|
||||
}
|
|
@ -12,6 +12,7 @@
|
|||
#include "charselect.h"
|
||||
|
||||
#include "global.h"
|
||||
#include "stages/stage0.h"
|
||||
|
||||
void quit_menu(void *arg) {
|
||||
MenuData *m = arg;
|
||||
|
|
|
@ -99,6 +99,8 @@ int mari_laser(Projectile *p, int t) {
|
|||
Player *plr = (Player *)REF(p->args[1]);
|
||||
|
||||
p->pos = plr->pos + p->pos - creal(p->pos0)*abs(plr->focus)/30.0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
void marisa_shot(Player *plr) {
|
||||
|
|
|
@ -213,8 +213,6 @@ void DeathShrink(Projectile *p, int t) {
|
|||
}
|
||||
|
||||
int bullet_flare_move(Projectile *p, int t) {
|
||||
int i;
|
||||
|
||||
if(t > 16 || REF(p->args[1]) == NULL) {
|
||||
free_ref(p->args[1]);
|
||||
return ACTION_DESTROY;
|
||||
|
@ -246,4 +244,6 @@ int timeout_linear(Projectile *p, int t) {
|
|||
|
||||
p->angle = carg(p->args[1]);
|
||||
p->pos = p->pos0 + p->args[1]*t;
|
||||
|
||||
return 1;
|
||||
}
|
|
@ -10,7 +10,7 @@
|
|||
#include "list.h"
|
||||
|
||||
#include <assert.h>
|
||||
#include <err.h>
|
||||
#include "taisei_err.h"
|
||||
|
||||
Animation *init_animation(char *filename) {
|
||||
Animation *buf = create_element((void **)&global.animations, sizeof(Animation));
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
#include "audio.h"
|
||||
#include "global.h"
|
||||
#include "list.h"
|
||||
#include <err.h>
|
||||
#include "taisei_err.h"
|
||||
|
||||
Sound *load_sound(char *filename) {
|
||||
ALuint sound;
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
#include "global.h"
|
||||
#include "list.h"
|
||||
#include <stdio.h>
|
||||
#include <err.h>
|
||||
#include "taisei_err.h"
|
||||
|
||||
void print_info_log(GLuint shader) {
|
||||
int len = 0, alen = 0;
|
||||
|
@ -27,7 +27,7 @@ void print_info_log(GLuint shader) {
|
|||
void load_shader(const char *filename) {
|
||||
FILE *file = fopen(filename,"r");
|
||||
if(file == NULL)
|
||||
err(-1, "Error opening '%s'", filename);
|
||||
errx(-1, "Error opening '%s'", filename);
|
||||
|
||||
fseek(file, 0, SEEK_END);
|
||||
int size = ftell(file);
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
#ifndef SHADER_H
|
||||
#define SHADER_H
|
||||
|
||||
#include <SDL/SDL_opengl.h>
|
||||
#include <GL/glew.h>
|
||||
|
||||
#define DELIM "%% -- FRAG"
|
||||
#define DELIM_SIZE 10
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <png.h>
|
||||
#include <err.h>
|
||||
#include "taisei_err.h"
|
||||
#include "audio.h"
|
||||
#include "shader.h"
|
||||
#include "list.h"
|
||||
|
@ -19,7 +19,7 @@
|
|||
void recurse_dir(char *path) {
|
||||
DIR *dir = opendir(path);
|
||||
if(dir == NULL)
|
||||
err(-1, "Couldn't open directory '%s'", path);
|
||||
errx(-1, "Couldn't open directory '%s'", path);
|
||||
struct dirent *dp;
|
||||
|
||||
char buf[512];
|
||||
|
@ -88,7 +88,7 @@ Texture *prefix_get_tex(char *name, char *prefix) {
|
|||
else
|
||||
src = name;
|
||||
|
||||
char *buf = malloc(strlen(src) + strlen(prefix));
|
||||
char *buf = malloc(strlen(src) + strlen(prefix) + 1);
|
||||
strcpy(buf, prefix);
|
||||
strcat(buf, src);
|
||||
|
||||
|
@ -114,7 +114,7 @@ Texture *load_texture(const char *filename) {
|
|||
SDL_Surface *surface = load_png(filename);
|
||||
|
||||
if(surface == NULL)
|
||||
err(-1,"load_texture():\n!- cannot load '%s'", filename);
|
||||
errx(-1,"load_texture():\n!- cannot load '%s'", filename);
|
||||
|
||||
Texture *texture = create_element((void **)&global.textures, sizeof(Texture));
|
||||
load_sdl_surf(surface, texture);
|
||||
|
@ -135,7 +135,7 @@ Texture *load_texture(const char *filename) {
|
|||
SDL_Surface *load_png(const char *filename) {
|
||||
FILE *fp = fopen(filename, "rb");
|
||||
if(!fp)
|
||||
err(-1, "Error loading '%s'", filename);
|
||||
errx(-1, "Error loading '%s'", filename);
|
||||
|
||||
png_structp png_ptr;
|
||||
if(!(png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL)))
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
#define TEXTURE_H
|
||||
|
||||
#include <SDL/SDL.h>
|
||||
#include <SDL/SDL_opengl.h>
|
||||
#include <GL/glew.h>
|
||||
#include <math.h>
|
||||
|
||||
struct Texture;
|
||||
|
|
|
@ -112,8 +112,6 @@ void draw_hud() {
|
|||
draw_text(AL_Left, SCREEN_W, SCREEN_H-20, buf, _fonts.standard);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void stage_draw() {
|
||||
set_ortho();
|
||||
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
|
||||
#include "stage0.h"
|
||||
|
||||
#include <SDL/SDL_opengl.h>
|
||||
#include "../stage.h"
|
||||
#include "../global.h"
|
||||
|
||||
|
|
40
src/taisei_err.c
Normal file
40
src/taisei_err.c
Normal file
|
@ -0,0 +1,40 @@
|
|||
/*
|
||||
* This software is licensed under the terms of the MIT-License
|
||||
* See COPYING for further information.
|
||||
* ---
|
||||
* Copyright (C) 2011, Lukas Weber <laochailan@web.de>
|
||||
*/
|
||||
|
||||
#include "taisei_err.h"
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
// void err(int eval, const char *fmt, ...);
|
||||
void errx(int eval, const char *fmt, ...) {
|
||||
va_list ap;
|
||||
|
||||
char *buf = malloc(11+strlen(fmt));
|
||||
strcpy(buf, "!- ERROR: ");
|
||||
strcat(buf, fmt);
|
||||
|
||||
va_start(ap, fmt);
|
||||
vfprintf(buf, ap);
|
||||
va_end(ap);
|
||||
free(buf);
|
||||
|
||||
exit(eval);
|
||||
}
|
||||
|
||||
// void warn(const char *fmt, ...);
|
||||
void warnx(const char *fmt, ...) {
|
||||
va_list ap;
|
||||
|
||||
char *buf = malloc(11+strlen(fmt));
|
||||
strcpy(buf, "!- WARNING: ");
|
||||
strcat(buf, fmt);
|
||||
|
||||
va_start(ap, fmt);
|
||||
vfprintf(buf, ap);
|
||||
va_end(ap);
|
||||
free(buf);
|
||||
}
|
16
src/taisei_err.h
Normal file
16
src/taisei_err.h
Normal file
|
@ -0,0 +1,16 @@
|
|||
/*
|
||||
* This software is licensed under the terms of the MIT-License
|
||||
* See COPYING for further information.
|
||||
* ---
|
||||
* Copyright (C) 2011, Lukas Weber <laochailan@web.de>
|
||||
*/
|
||||
|
||||
/* replacement for standard err.h, some environments don't have it ... but i like it :/ */
|
||||
|
||||
#include <stdarg.h>
|
||||
|
||||
// void err(int eval, const char *fmt, ...);
|
||||
void errx(int eval, const char *fmt, ...);
|
||||
|
||||
// void warn(const char *fmt, ...);
|
||||
void warnx(const char *fmt, ...);
|
Loading…
Reference in a new issue