From 88f10fe54b94edc206e2bdade4ece382b3da886f Mon Sep 17 00:00:00 2001 From: Sam Hocevar Date: Tue, 10 Apr 2012 18:39:12 +0000 Subject: [PATCH] build: allow to build the Direct3D 9 driver with the mingw compiler. --- configure.ac | 12 ++++++- src/gpu/shader.cpp | 3 ++ src/platform/sdl/sdlapp.cpp | 4 +-- src/platform/xbox/xboxapp.cpp | 5 ++- src/scene.cpp | 60 +++++++++++------------------------ 5 files changed, 38 insertions(+), 46 deletions(-) diff --git a/configure.ac b/configure.ac index f3b48317..7b3ffc63 100644 --- a/configure.ac +++ b/configure.ac @@ -111,6 +111,16 @@ AC_CHECK_LIB(sysmodule_stub, cellSysmoduleLoadModule, AM_CONDITIONAL(USE_MAKE_FSELF, test "${MAKE_FSELF}" != "no") +dnl Are we on a Direct3D 9 platform? +ac_cv_my_have_d3d9="no" +AC_CHECK_HEADERS(d3d9.h, [ac_cv_my_have_d3d9="yes"]) +if test "${ac_cv_my_have_d3d9}" != "no"; then + D3D_LIBS="${D3D_LIBS} -ld3d9 -ld3dx9" + AC_DEFINE(USE_D3D9, 1, Define to 1 to use DirectX 9) +fi +AM_CONDITIONAL(USE_D3D9, test "${ac_cv_my_have_d3d9}" != "no") + + LIBS_save="$LIBS" LIBS="$LIBS -Wl,-framework -Wl,OpenGL" AC_MSG_CHECKING(for -framework OpenGL) @@ -331,7 +341,7 @@ AM_CONDITIONAL(USE_GTKGL, test "${ac_cv_my_have_gtkgl}" != "no") dnl How to use the Lol Engine inside this tree LOL_CFLAGS="$LOL_CFLAGS -I \$(top_srcdir)/src" LOL_CFLAGS="$LOL_CFLAGS $SDL_CFLAGS $GL_CFLAGS $EGL_CFLAGS $LIBPNG_CFLAGS" -LOL_LIBS="$LOL_LIBS $SDL_LIBS $GL_LIBS $EGL_LIBS $LIBPNG_LIBS" +LOL_LIBS="$LOL_LIBS $SDL_LIBS $GL_LIBS $EGL_LIBS $LIBPNG_LIBS $D3D_LIBS" AC_SUBST(MATH_LIBS) AC_SUBST(LOL_CFLAGS) diff --git a/src/gpu/shader.cpp b/src/gpu/shader.cpp index a1feaae6..1e0954d6 100644 --- a/src/gpu/shader.cpp +++ b/src/gpu/shader.cpp @@ -20,6 +20,9 @@ # define WIN32_LEAN_AND_MEAN # include # if defined USE_D3D9 +# include + using std::min; + using std::max; # include # include # endif diff --git a/src/platform/sdl/sdlapp.cpp b/src/platform/sdl/sdlapp.cpp index 551d82ef..67c9a8af 100644 --- a/src/platform/sdl/sdlapp.cpp +++ b/src/platform/sdl/sdlapp.cpp @@ -25,8 +25,9 @@ #include "platform/sdl/sdlapp.h" #include "platform/sdl/sdlinput.h" -#if defined USE_D3D9 +#if defined USE_SDL && defined USE_D3D9 HWND g_hwnd = NULL; +extern IDirect3DDevice9 *g_d3ddevice; #endif namespace lol @@ -101,7 +102,6 @@ void SdlApp::Run() while (!Ticker::Finished()) { #if defined USE_SDL && defined USE_D3D9 - extern IDirect3DDevice9 *g_d3ddevice; g_d3ddevice->BeginScene(); #endif /* Tick the renderer, show the frame and clamp to desired framerate. */ diff --git a/src/platform/xbox/xboxapp.cpp b/src/platform/xbox/xboxapp.cpp index cd7d7f4b..8460f51b 100644 --- a/src/platform/xbox/xboxapp.cpp +++ b/src/platform/xbox/xboxapp.cpp @@ -20,6 +20,10 @@ #include "lolgl.h" #include "xboxapp.h" +#if defined _XBOX +extern D3DDevice *g_d3ddevice; +#endif + namespace lol { @@ -62,7 +66,6 @@ void XboxApp::Run() Ticker::TickDraw(); #if defined _XBOX - extern D3DDevice *g_d3ddevice; g_d3ddevice->Present(NULL, NULL, NULL, NULL); #endif } diff --git a/src/scene.cpp b/src/scene.cpp index 06adeaac..93f81fd6 100644 --- a/src/scene.cpp +++ b/src/scene.cpp @@ -61,11 +61,15 @@ private: float angle; #if defined USE_D3D9 || defined _XBOX -# define STR0(x) #x -# define STR(x) STR0(x) -# pragma message(__FILE__ "(" STR(__LINE__) "): warning: Scene not implemented") -# undef STR -# undef STR0 +# if defined __GNUC__ +# warning Scene not implemented +# else +# define STR0(x) #x +# define STR(x) STR0(x) +# pragma message(__FILE__ "(" STR(__LINE__) "): warning: Scene not implemented") +# undef STR +# undef STR0 +# endif #else #if defined HAVE_GL_2X && !defined __APPLE__ GLuint vao; @@ -91,29 +95,21 @@ Scene::Scene(float angle) data->angle = angle; #if defined USE_D3D9 || defined _XBOX -# define STR0(x) #x -# define STR(x) STR0(x) -# pragma message(__FILE__ "(" STR(__LINE__) "): warning: Scene::Scene() not implemented") -# undef STR -# undef STR0 + /* TODO */ #else data->bufs = 0; data->nbufs = 0; -#endif -#if defined HAVE_GL_2X && !defined __APPLE__ +# if defined HAVE_GL_2X && !defined __APPLE__ glGenVertexArrays(1, &data->vao); +# endif #endif } Scene::~Scene() { #if defined USE_D3D9 || defined _XBOX -# define STR0(x) #x -# define STR(x) STR0(x) -# pragma message(__FILE__ "(" STR(__LINE__) "): warning: Scene::~Scene() not implemented") -# undef STR -# undef STR0 + /* TODO */ #else /* FIXME: this must be done while the GL context is still active. * Change the code architecture to make sure of that. */ @@ -344,11 +340,7 @@ void Scene::Render() // XXX: rename to Blit() stdshader->SetUniform(uni_mat, data->model_matrix); #if defined USE_D3D9 || defined _XBOX -# define STR0(x) #x -# define STR(x) STR0(x) -# pragma message(__FILE__ "(" STR(__LINE__) "): warning: Scene::Render() not implemented") -# undef STR -# undef STR0 + /* TODO */ #elif !defined __CELLOS_LV2__ uni_tex = stdshader->GetUniformLocation("in_Texture"); glUniform1i(uni_tex, 0); @@ -359,11 +351,7 @@ void Scene::Render() // XXX: rename to Blit() #endif #if defined USE_D3D9 || defined _XBOX -# define STR0(x) #x -# define STR(x) STR0(x) -# pragma message(__FILE__ "(" STR(__LINE__) "): warning: Scene::Render() not implemented") -# undef STR -# undef STR0 + /* TODO */ #else #if !defined HAVE_GLES_2X glEnable(GL_TEXTURE_2D); @@ -381,11 +369,7 @@ void Scene::Render() // XXX: rename to Blit() for (int buf = 0, i = 0, n; i < data->ntiles; i = n, buf += 2) { #if defined USE_D3D9 || defined _XBOX -# define STR0(x) #x -# define STR(x) STR0(x) -# pragma message(__FILE__ "(" STR(__LINE__) "): warning: Scene::Render() not implemented") -# undef STR -# undef STR0 + /* TODO */ #else /* Generate new vertex / texture coord buffers if necessary */ if (buf + 2 > data->nbufs) @@ -423,11 +407,7 @@ void Scene::Render() // XXX: rename to Blit() glBindVertexArray(data->vao); #endif #if defined USE_D3D9 || defined _XBOX -# define STR0(x) #x -# define STR(x) STR0(x) -# pragma message(__FILE__ "(" STR(__LINE__) "): warning: Scene::Render() not implemented") -# undef STR -# undef STR0 + /* TODO */ #else #if !defined __CELLOS_LV2__ // Use cgGLEnableClientState etc. glEnableVertexAttribArray(attr_pos); @@ -474,11 +454,7 @@ void Scene::Render() // XXX: rename to Blit() data->ntiles = 0; #if defined USE_D3D9 || defined _XBOX -# define STR0(x) #x -# define STR(x) STR0(x) -# pragma message(__FILE__ "(" STR(__LINE__) "): warning: Scene::Render() not implemented") -# undef STR -# undef STR0 + /* TODO */ #else #if !defined HAVE_GLES_2X glDisable(GL_TEXTURE_2D);