From d0acde5d885c4a216fba5b8921454c47ea568650 Mon Sep 17 00:00:00 2001 From: Mark Vejvoda Date: Fri, 18 Nov 2011 08:28:42 +0000 Subject: [PATCH] - fixed freetype-gl on windows compiler - deprecated ancient opengl extension code and replaced it with glew - testing new font renderer on windows (still in progress need to fix newlines) (now need to check the Linux build and possibly make adjustments) --- mk/windoze/g3d_viewer.vcproj | 4 +- mk/windoze/glest_game.vcproj | 12 ++-- mk/windoze/shared_lib.vcproj | 58 ++++++++++++++----- .../graphics/freetype-gl/vertex-buffer.h | 6 ++ .../shared_lib/include/graphics/gl/opengl.h | 1 + .../include/graphics/md5/Md5Model.h | 2 +- .../include/graphics/md5/TextureManager.h | 2 +- .../graphics/md5/{Texture.h => md5Texture.h} | 0 .../shared_lib/include/platform/sdl/gl_wrap.h | 9 ++- .../include/platform/sdl/platform_main.h | 2 + .../graphics/freetype-gl/texture-atlas.c | 5 +- .../graphics/freetype-gl/texture-glyph.c | 1 + .../graphics/freetype-gl/vertex-buffer.c | 14 +++++ .../sources/graphics/gl/texture_gl.cpp | 3 + .../sources/graphics/md5/GlErrors.cpp | 7 ++- .../sources/graphics/md5/Md5Model.cpp | 2 +- .../md5/{Texture.cpp => md5Texture.cpp} | 10 ++-- .../sources/platform/sdl/gl_wrap.cpp | 8 +++ 18 files changed, 111 insertions(+), 35 deletions(-) rename source/shared_lib/include/graphics/md5/{Texture.h => md5Texture.h} (100%) rename source/shared_lib/sources/graphics/md5/{Texture.cpp => md5Texture.cpp} (98%) diff --git a/mk/windoze/g3d_viewer.vcproj b/mk/windoze/g3d_viewer.vcproj index 1484e1ba..2599565a 100644 --- a/mk/windoze/g3d_viewer.vcproj +++ b/mk/windoze/g3d_viewer.vcproj @@ -118,8 +118,8 @@ - - @@ -499,6 +495,10 @@ RelativePath="..\..\source\shared_lib\sources\graphics\md5\Md5Model.cpp" > + + @@ -535,10 +535,6 @@ RelativePath="..\..\source\shared_lib\sources\graphics\shader_manager.cpp" > - - @@ -790,6 +786,14 @@ Filter="h;hpp;hxx;hm;inl;inc;xsd" UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}" > + + + + @@ -822,6 +826,14 @@ RelativePath="..\..\source\shared_lib\include\map\map_preview.h" > + + + + @@ -850,10 +862,30 @@ RelativePath="..\..\source\shared_lib\include\streflop\System.h" > + + + + + + + + + + diff --git a/source/shared_lib/include/graphics/freetype-gl/vertex-buffer.h b/source/shared_lib/include/graphics/freetype-gl/vertex-buffer.h index 63e007e5..8df0b769 100644 --- a/source/shared_lib/include/graphics/freetype-gl/vertex-buffer.h +++ b/source/shared_lib/include/graphics/freetype-gl/vertex-buffer.h @@ -37,8 +37,14 @@ #define WIN32_LEAN_AND_MEAN #include +//#include "gl.h" #include +//#include +//#include "glext.h" +//typedef char GLchar; /* native character */ +//#define GL_BOOL 0x8B56 + #else #include #endif diff --git a/source/shared_lib/include/graphics/gl/opengl.h b/source/shared_lib/include/graphics/gl/opengl.h index 9d06e539..5bd29fc8 100644 --- a/source/shared_lib/include/graphics/gl/opengl.h +++ b/source/shared_lib/include/graphics/gl/opengl.h @@ -12,6 +12,7 @@ #ifndef _SHARED_GRAPHICS_GL_OPENGL_H_ #define _SHARED_GRAPHICS_GL_OPENGL_H_ +#include #include #include #include diff --git a/source/shared_lib/include/graphics/md5/Md5Model.h b/source/shared_lib/include/graphics/md5/Md5Model.h index 18d891f4..fff51698 100644 --- a/source/shared_lib/include/graphics/md5/Md5Model.h +++ b/source/shared_lib/include/graphics/md5/Md5Model.h @@ -33,7 +33,7 @@ #include #include "Mathlib.h" -#include "Texture.h" +#include "md5Texture.h" namespace Shared { namespace Graphics { namespace md5 { diff --git a/source/shared_lib/include/graphics/md5/TextureManager.h b/source/shared_lib/include/graphics/md5/TextureManager.h index e1bffd05..43e7881f 100644 --- a/source/shared_lib/include/graphics/md5/TextureManager.h +++ b/source/shared_lib/include/graphics/md5/TextureManager.h @@ -18,7 +18,7 @@ #define __TEXTUREMANAGER_H__ #include "DataManager.h" -#include "Texture.h" +#include "md5Texture.h" namespace Shared { namespace Graphics { namespace md5 { diff --git a/source/shared_lib/include/graphics/md5/Texture.h b/source/shared_lib/include/graphics/md5/md5Texture.h similarity index 100% rename from source/shared_lib/include/graphics/md5/Texture.h rename to source/shared_lib/include/graphics/md5/md5Texture.h diff --git a/source/shared_lib/include/platform/sdl/gl_wrap.h b/source/shared_lib/include/platform/sdl/gl_wrap.h index 806c9783..af48bb35 100644 --- a/source/shared_lib/include/platform/sdl/gl_wrap.h +++ b/source/shared_lib/include/platform/sdl/gl_wrap.h @@ -15,9 +15,12 @@ #include -#include -#include -#include +#include +//#include "gl.h" + +//#include +//#include +//#include #define GLEST_GLPROC(X, Y) inline X( static a= wglGetProcAddress(a); return a;) diff --git a/source/shared_lib/include/platform/sdl/platform_main.h b/source/shared_lib/include/platform/sdl/platform_main.h index ab8dacd7..fb85514f 100644 --- a/source/shared_lib/include/platform/sdl/platform_main.h +++ b/source/shared_lib/include/platform/sdl/platform_main.h @@ -13,6 +13,8 @@ #include #include +//#include "gl.h" +#include #include "leak_dumper.h" #ifndef WIN32 diff --git a/source/shared_lib/sources/graphics/freetype-gl/texture-atlas.c b/source/shared_lib/sources/graphics/freetype-gl/texture-atlas.c index ef3dec10..6919ace9 100644 --- a/source/shared_lib/sources/graphics/freetype-gl/texture-atlas.c +++ b/source/shared_lib/sources/graphics/freetype-gl/texture-atlas.c @@ -41,8 +41,11 @@ #include #endif +//#include "gl.h" +#include + //#include -#include +//#include //#include #include diff --git a/source/shared_lib/sources/graphics/freetype-gl/texture-glyph.c b/source/shared_lib/sources/graphics/freetype-gl/texture-glyph.c index 4fa60776..96e56a5a 100644 --- a/source/shared_lib/sources/graphics/freetype-gl/texture-glyph.c +++ b/source/shared_lib/sources/graphics/freetype-gl/texture-glyph.c @@ -35,6 +35,7 @@ #define WIN32_LEAN_AND_MEAN #include #include +//#include "gl.h" #else #include diff --git a/source/shared_lib/sources/graphics/freetype-gl/vertex-buffer.c b/source/shared_lib/sources/graphics/freetype-gl/vertex-buffer.c index 658d2e1a..ddc3e727 100644 --- a/source/shared_lib/sources/graphics/freetype-gl/vertex-buffer.c +++ b/source/shared_lib/sources/graphics/freetype-gl/vertex-buffer.c @@ -36,7 +36,21 @@ #include #include "vertex-buffer.h" +#ifdef _WIN32 +char * strndup(const char *old, size_t sz) +{ + size_t len = strnlen (old, sz); + char *t = malloc(len + 1); + + if (t != NULL) { + memcpy (t, old, len); + t[len] = '\0'; + } + return t; +} + +#endif // ---------------------------------------------------------------------------- VertexBuffer * diff --git a/source/shared_lib/sources/graphics/gl/texture_gl.cpp b/source/shared_lib/sources/graphics/gl/texture_gl.cpp index 434792f3..1858fcee 100644 --- a/source/shared_lib/sources/graphics/gl/texture_gl.cpp +++ b/source/shared_lib/sources/graphics/gl/texture_gl.cpp @@ -25,6 +25,8 @@ using namespace std; // Define FBO's (Frame Buffer Objects) for win32 + +/* #ifdef WIN32 #define GL_FRAMEBUFFER_EXT 0x8D40 @@ -63,6 +65,7 @@ PFNGLDELETERENDERBUFFERSEXTPROC glDeleteRenderbuffersEXT = NULL; PFNGLBINDRENDERBUFFEREXTPROC glBindRenderbufferEXT = NULL; #endif +*/ namespace Shared { namespace Graphics { namespace Gl { diff --git a/source/shared_lib/sources/graphics/md5/GlErrors.cpp b/source/shared_lib/sources/graphics/md5/GlErrors.cpp index 16294221..6100833e 100644 --- a/source/shared_lib/sources/graphics/md5/GlErrors.cpp +++ b/source/shared_lib/sources/graphics/md5/GlErrors.cpp @@ -20,8 +20,11 @@ #include #endif // _WIN32 -#include -#include +//#include "gl.h" +#include + +//#include +//#include #include #include "GlErrors.h" diff --git a/source/shared_lib/sources/graphics/md5/Md5Model.cpp b/source/shared_lib/sources/graphics/md5/Md5Model.cpp index cb971393..76d360dc 100644 --- a/source/shared_lib/sources/graphics/md5/Md5Model.cpp +++ b/source/shared_lib/sources/graphics/md5/Md5Model.cpp @@ -26,7 +26,7 @@ #include #include -#include "Texture.h" +#include "md5Texture.h" #include "ArbProgram.h" #include "ShaderManager.h" #include "Md5Model.h" diff --git a/source/shared_lib/sources/graphics/md5/Texture.cpp b/source/shared_lib/sources/graphics/md5/md5Texture.cpp similarity index 98% rename from source/shared_lib/sources/graphics/md5/Texture.cpp rename to source/shared_lib/sources/graphics/md5/md5Texture.cpp index b5948fc7..589ec8d1 100644 --- a/source/shared_lib/sources/graphics/md5/Texture.cpp +++ b/source/shared_lib/sources/graphics/md5/md5Texture.cpp @@ -25,7 +25,7 @@ #include #include "GlErrors.h" -#include "Texture.h" +#include "md5Texture.h" #include "Image.h" namespace Shared { namespace Graphics { namespace md5 { @@ -219,8 +219,8 @@ Texture2D::create (const Image *img, TextureFlags flags) mipWidth, mipHeight, 0, mipSize, img->pixels () + offset); - mipWidth = std::max (mipWidth >> 1, 1); - mipHeight = std::max (mipHeight >> 1, 1); + mipWidth = max (mipWidth >> 1, 1); + mipHeight = max (mipHeight >> 1, 1); offset += mipSize; } @@ -492,8 +492,8 @@ TextureCubeMap::create (const vector &faces, TextureFlags flags) mipWidth, mipHeight, 0, mipSize, img->pixels () + offset); - mipWidth = std::max (mipWidth >> 1, 1); - mipHeight = std::max (mipHeight >> 1, 1); + mipWidth = max (mipWidth >> 1, 1); + mipHeight = max (mipHeight >> 1, 1); offset += mipSize; } diff --git a/source/shared_lib/sources/platform/sdl/gl_wrap.cpp b/source/shared_lib/sources/platform/sdl/gl_wrap.cpp index eb36acd0..f51a5ed1 100644 --- a/source/shared_lib/sources/platform/sdl/gl_wrap.cpp +++ b/source/shared_lib/sources/platform/sdl/gl_wrap.cpp @@ -161,6 +161,14 @@ void PlatformContextGl::init(int colorBits, int depthBits, int stencilBits,bool SDL_WM_GrabInput(SDL_GRAB_OFF); } + + GLuint err = glewInit(); + if (GLEW_OK != err) { + fprintf(stderr, "Error [main]: glewInit failed: %s\n", glewGetErrorString(err)); + //return 1; + throw std::runtime_error((char *)glewGetErrorString(err)); + } + } void PlatformContextGl::end() {