From 0c3bc05fcc1b0d92b11bed9fa2783f1f52d5a264 Mon Sep 17 00:00:00 2001 From: dg <dg@51575b47-30f0-44d4-a5cc-537603b46e54> Date: Thu, 10 Dec 2009 09:02:31 +0000 Subject: [PATCH] mac port git-svn-id: http://svn.net-core.org/repos/t-engine4@111 51575b47-30f0-44d4-a5cc-537603b46e54 --- premake4.lua | 17 +++++++++++++++-- src/core_lua.c | 8 ++++++++ src/display_sdl.c | 4 +++- src/display_sdl.h | 4 ++-- src/main.c | 6 ++++++ src/map.h | 2 +- 6 files changed, 35 insertions(+), 6 deletions(-) diff --git a/premake4.lua b/premake4.lua index 25bef7ef61..b9b764c37b 100644 --- a/premake4.lua +++ b/premake4.lua @@ -10,6 +10,7 @@ solution "TEngine" "src/physfs", "src/physfs/zlib123", "/usr/include/SDL", + "/usr/include/GL", } libdirs { @@ -37,8 +38,19 @@ project "TEngine" defines { [[TENGINE_HOME_PATH='".t-engine"']] } configuration "macosx" - linkoptions { "mac/SDLmain.m", "-framework SDL", "-framework SDL_gfx", "-framework SDL_image", "-framework SDL_ttf", "-framework SDL_mixer", "-framework Cocoa" } - files { "mac/SDL*" } + linkoptions { "-framework SDL", "-framework SDL_gfx", "-framework SDL_image", "-framework SDL_ttf", "-framework SDL_mixer", "-framework Cocoa", "-framework OpenGL" } + files { "src/mac/SDL*" } + links { "IOKit" } + includedirs { + "/System/Library/Frameworks/OpenGL.framework/Headers", + "/Library/Frameworks/SDL.framework/Headers", + "/Library/Frameworks/SDL_net.framework/Headers", + "/Library/Frameworks/SDL_image.framework/Headers", + "/Library/Frameworks/SDL_ttf.framework/Headers", + "/Library/Frameworks/SDL_gfx.framework/Headers", + "/Library/Frameworks/SDL_mixer.framework/Headers" + } + defines { "USE_TENGINE_MAIN" } targetdir "." configuration "not macosx" @@ -68,6 +80,7 @@ project "physfs" files { "src/physfs/platform/windows.c", } configuration "macosx" files { "src/physfs/platform/macosx.c", "src/physfs/platform/posix.c", } + includedirs { "/Library/Frameworks/SDL.framework/Headers" } project "lua" kind "StaticLib" diff --git a/src/core_lua.c b/src/core_lua.c index 90166aaebc..8e049ce4b9 100644 --- a/src/core_lua.c +++ b/src/core_lua.c @@ -410,6 +410,10 @@ static int sdl_new_surface(lua_State *L) 32, rmask, gmask, bmask, amask ); + + if (s == NULL) + printf("ERROR : SDL_CreateRGBSurface : %s\n",SDL_GetError()); + return 1; } @@ -503,6 +507,10 @@ static int sdl_surface_toscreen(lua_State *L) // Jonction entre OpenGL et SDL. glTexImage2D(GL_TEXTURE_2D, 0, nOfColors, (*s)->w, (*s)->h, 0, texture_format, GL_UNSIGNED_BYTE, (*s)->pixels); + GLenum err = glGetError(); + if (err != GL_NO_ERROR) { + printf("glTexImage2D : %s\n",gluErrorString(err)); + } glBegin( GL_QUADS ); /* Draw A Quad */ glTexCoord2f(0,0); glVertex2f(0 + x, 0 + y); diff --git a/src/display_sdl.c b/src/display_sdl.c index 032eed7b9f..133dfe760a 100644 --- a/src/display_sdl.c +++ b/src/display_sdl.c @@ -37,5 +37,7 @@ inline void sdlDrawImage(SDL_Surface *dest, SDL_Surface *image, int x, int y) r.h=image->h; r.x=x; r.y=y; - SDL_BlitSurface(image, NULL, dest, &r); + int errcode = SDL_BlitSurface(image, NULL, dest, &r); + if (errcode) + printf("ERROR! SDL_BlitSurface failed! (%d,%s)\n",errcode,SDL_GetError()); } diff --git a/src/display_sdl.h b/src/display_sdl.h index 6a422e4089..0c78f1efe8 100644 --- a/src/display_sdl.h +++ b/src/display_sdl.h @@ -36,8 +36,8 @@ #include <SDL.h> #include <SDL_framerate.h> -#include <GL/gl.h> -#include <GL/glu.h> +#include <gl.h> +#include <glu.h> #ifdef __cplusplus extern "C" { diff --git a/src/main.c b/src/main.c index f112105a1e..afe2cb4c48 100644 --- a/src/main.c +++ b/src/main.c @@ -356,6 +356,12 @@ int resizeWindow(int width, int height) /** * Program entry point. */ + +// Let some platforms use a different entry point +#ifdef USE_TENGINE_MAIN +#define main tengine_main +#endif + int main(int argc, char *argv[]) { // RNG init diff --git a/src/map.h b/src/map.h index c056ea951a..b651e6b767 100644 --- a/src/map.h +++ b/src/map.h @@ -1,7 +1,7 @@ #ifndef _MAP_H_ #define _MAP_H_ -#include <GL/gl.h> +#include <gl.h> typedef struct { GLuint **grids_terrain; -- GitLab