i got this to compile on mac os x (and run all of the examples), but I couldn't get it to work using code::blocks. i ended up using the mac os x irrlicht xcode project and just added the irrcg source files to it, and fixed any u32/s32 related errors that the trunk svn of irrlicht would cause.
IrrCgExtensionHandler.h changes:
you can include <OpenGL/gl.h> for mac instead of GL/gl.h but when it's in the irrlicht project you don't need any of those gl includes.
I had to comment out everything to do with pGlActiveTextureARB in IrrCgExtensionHandler.h when compiling for mac, but...
I don't know opengl, so i have to ask, is it okay to use glActiveTextureARB(texture) in the IrrCgExtensionHandler.h extGlActiveTexture function ? (instead of pGlActiveTextureARB, when compiling for mac). I read something about this but not sure, though it seems to work fine..
IrrCg.cpp changes:
Also, at least for svn trunk irrlicht, had to alter IrrCg.cpp and remove the setActiveTexture function
all of the demos look the same as my old windows binaries do, though the elephant always complains about missing Elephant.mtl which doesn't exist anyways.
---------------
Code: Select all
Index: include/IrrCgExtensionHandler.h
===================================================================
--- include/IrrCgExtensionHandler.h (revision 7)
+++ include/IrrCgExtensionHandler.h (working copy)
@@ -6,8 +6,12 @@
#define __IRR_CG_EXTENSION_HANDLER_H_INCLUDED__
#ifdef IrrCgOGL
-
+
+#ifdef IrrMacOSX
+#include <OpenGL/gl.h>
+#else
#include <GL/gl.h>
+#endif
#ifdef IrrCgWin32
#include <windows.h>
@@ -23,7 +27,10 @@
class IrrCgExtensionHandler
{
public:
- IrrCgExtensionHandler() : pGlActiveTextureARB(0)
+ IrrCgExtensionHandler()
+ #ifndef IrrMacOSX
+ : pGlActiveTextureARB(0)
+ #endif
{
#ifdef IrrCgWin32
pGlActiveTextureARB = (PFNGLACTIVETEXTUREARBPROC) wglGetProcAddress("glActiveTextureARB");
@@ -37,13 +44,19 @@
~IrrCgExtensionHandler(){};
inline void extGlActiveTexture(GLenum texture)
- {
+ {
+ #ifdef IrrMacOSX
+ glActiveTextureARB(texture);
+ #else
if (pGlActiveTextureARB)
- pGlActiveTextureARB(texture);
+ pGlActiveTextureARB(texture);
+ #endif
}
- private:
- PFNGLACTIVETEXTUREARBPROC pGlActiveTextureARB;
+ private:
+ #ifndef IrrMacOSX
+ PFNGLACTIVETEXTUREARBPROC pGlActiveTextureARB;
+ #endif
};
}
Code: Select all
Index: source/IrrCg.cpp
===================================================================
--- source/IrrCg.cpp (revision 7)
+++ source/IrrCg.cpp (working copy)
@@ -1,21 +1,31 @@
// Copyright (C) 2007-2009 Patryk Nadrowski
// This file is part of the "irrCg".
// For conditions of distribution and use, see copyright notice in License.txt
-
+#include "IrrCompileConfig.h"
// You have to define it, if You compile on Windows. Require Windows PlatformSDK.
+#if defined(_IRR_COMPILE_WITH_WINDOWS_DEVICE_)
#define IrrCgWin32
-
+#endif
// You have to define it, if You compile on Linux.
-// #define IrrCgLinux
+#if defined(_IRR_LINUX_PLATFORM_)
+#define IrrCgLinux
+#endif
+#if defined(_IRR_COMPILE_WITH_OSX_DEVICE_)
+#define IrrMacOSX
+#endif
// You have to define it, if You use Irrlicht Linux Shared Library (*.so)
// #define IrrCgSharedLib
// You have to define it, if You need Cg support for Direct3D program. Require DirectX SDK.
+#if defined(_IRR_COMPILE_WITH_DIRECT3D_9_)
#define IrrCgD3D9
+#endif
// You have to define it, if You need Cg support for OpenGL program.
+#if defined(_IRR_COMPILE_WITH_OPENGL_)
#define IrrCgOGL
+#endif
// Irrlicht Header
#include "irrlicht.h"
@@ -64,47 +74,9 @@
#ifndef IrrCgSharedLib
// Get OpenGL Texture Name. Like standard Irrlicht getOpenGLTextureName().
-#ifdef IrrCgOGL
-GLuint irr::video::COpenGLTexture::getOpenGLTextureName() const
-{
- return TextureName;
-}
#if IRRLICHT_VERSION_MINOR > 5
-// Set OpenGL Active Texture. Like standard Irrlicht OpenGL setActiveTexture().
-bool irr::video::COpenGLDriver::setActiveTexture(u32 stage, const video::ITexture* texture)
-{
- if (stage >= MaxTextureUnits)
- return false;
- if (CurrentTexture[stage]==texture)
- return true;
-
- if (MultiTextureExtension)
- extGlActiveTexture(GL_TEXTURE0_ARB + stage);
-
- CurrentTexture[stage]=texture;
-
- if (!texture)
- {
- glDisable(GL_TEXTURE_2D);
- return true;
- }
- else
- {
- if (texture->getDriverType() != EDT_OPENGL)
- {
- glDisable(GL_TEXTURE_2D);
- printf("Fatal Error: Tried to set a texture not owned by this driver.");
- return false;
- }
-
- glEnable(GL_TEXTURE_2D);
- glBindTexture(GL_TEXTURE_2D,
- static_cast<const COpenGLTexture*>(texture)->getOpenGLTextureName());
- }
- return true;
-}
#else
// Set OpenGL Texture. Like standard Irrlicht OpenGL setTexture().
bool irr::video::COpenGLDriver::setTexture(u32 stage, const video::ITexture* texture)
@@ -152,7 +124,6 @@
}
#endif
-#endif
namespace IrrCg
{
Using those two diffs, you can add the source and header files to the libirrlicht.a target in the MacOSX Xcode project, add the Cg.framework (download from nvidia site, if you have trouble find the gzipped file in the installer app they provide and manually install it)
i'd like some explanation on the functions I removed to make this work for the SVN but don't have time to look myself. but this works for mac it seems when you replace the HelloWorld project with Nadro's Basic Lighting, and copy the cg and media folder contents to their respective places.
i've also got project files for standalone IrrCg static library and a BasicLighting project that uses it and the irrlicht framework for mac os x which compiles and runs as long as there aren't console options to choose from.