From Thomas Hogarth and Stephan Huber, "attached you'll find part one of iphone-support. It includes
* support for NPOT-textures on IOS * support for FBOs (only renderToTexture for now) on IOS (should work for other OpenGL ES 1/2 targets, too) * FileUtils-support for IOS"
This commit is contained in:
parent
1bd55d732d
commit
d7b161078a
@ -20,7 +20,7 @@
|
||||
#if defined(OSG_GLES1_AVAILABLE)
|
||||
|
||||
#ifdef __APPLE__
|
||||
//if its apple include the target defines so we can check for iphone
|
||||
//if its apple include the target defines so we can check for IOS
|
||||
#include "TargetConditionals.h"
|
||||
#include <OpenGLES/ES1/gl.h>
|
||||
#else
|
||||
@ -30,7 +30,7 @@
|
||||
#elif defined(OSG_GLES2_AVAILABLE)
|
||||
|
||||
#ifdef __APPLE__
|
||||
//if its apple include the target defines so we can check for iphone
|
||||
//if its apple include the target defines so we can check for IOS
|
||||
#include "TargetConditionals.h"
|
||||
#include <OpenGLES/ES2/gl.h>
|
||||
#else
|
||||
|
@ -460,6 +460,11 @@ class OSG_EXPORT GraphicsContext : public Object
|
||||
|
||||
/** Get the the const list of cameras associated with this graphics context.*/
|
||||
const Cameras& getCameras() const { return _cameras; }
|
||||
|
||||
/** set the default FBO-id, this id will be used when the rendering-backend is finished with RTT FBOs */
|
||||
void setDefaultFboId(GLuint i) { _defaultFboId = i; }
|
||||
|
||||
GLuint getDefaultFboId() const { return _defaultFboId; }
|
||||
|
||||
public:
|
||||
|
||||
@ -510,6 +515,8 @@ class OSG_EXPORT GraphicsContext : public Object
|
||||
ref_ptr<SwapCallback> _swapCallback;
|
||||
|
||||
Timer_t _lastClearTick;
|
||||
|
||||
GLuint _defaultFboId;
|
||||
};
|
||||
|
||||
|
||||
|
@ -39,7 +39,15 @@ FBOExtensions* FBOExtensions::instance(unsigned contextID, bool createIfNotInita
|
||||
/**************************************************************************
|
||||
* FBOExtensions
|
||||
**************************************************************************/
|
||||
#define LOAD_FBO_EXT(name) setGLExtensionFuncPtr(name, (#name), ( std::string(#name)+std::string("EXT") ).c_str() )
|
||||
#if defined(OSG_GLES1_AVAILABLE) || defined(OSG_GLES2_AVAILABLE)
|
||||
#if defined(OSG_GLES1_AVAILABLE)
|
||||
#define LOAD_FBO_EXT(name) setGLExtensionFuncPtr(name, (#name), (std::string(#name)+std::string("OES") ).c_str() )
|
||||
#else
|
||||
#define LOAD_FBO_EXT(name) setGLExtensionFuncPtr(name, (#name), std::string(#name).c_str() )
|
||||
#endif
|
||||
#else
|
||||
#define LOAD_FBO_EXT(name) setGLExtensionFuncPtr(name, (#name), (std::string(#name)+std::string("EXT") ).c_str() )
|
||||
#endif
|
||||
|
||||
FBOExtensions::FBOExtensions(unsigned int contextID)
|
||||
: glBindRenderbuffer(0),
|
||||
|
@ -444,7 +444,8 @@ GraphicsContext::GraphicsContext():
|
||||
_clearColor(osg::Vec4(0.0f,0.0f,0.0f,1.0f)),
|
||||
_clearMask(0),
|
||||
_threadOfLastMakeCurrent(0),
|
||||
_lastClearTick(0)
|
||||
_lastClearTick(0),
|
||||
_defaultFboId(0)
|
||||
{
|
||||
setThreadSafeRefUnref(true);
|
||||
_operationsBlock = new RefBlock;
|
||||
@ -456,7 +457,8 @@ GraphicsContext::GraphicsContext(const GraphicsContext&, const osg::CopyOp&):
|
||||
_clearColor(osg::Vec4(0.0f,0.0f,0.0f,1.0f)),
|
||||
_clearMask(0),
|
||||
_threadOfLastMakeCurrent(0),
|
||||
_lastClearTick(0)
|
||||
_lastClearTick(0),
|
||||
_defaultFboId(0)
|
||||
{
|
||||
setThreadSafeRefUnref(true);
|
||||
_operationsBlock = new RefBlock;
|
||||
|
@ -2336,7 +2336,7 @@ Texture::Extensions::Extensions(unsigned int contextID)
|
||||
|
||||
_isClientStorageSupported = isGLExtensionSupported(contextID,"GL_APPLE_client_storage");
|
||||
|
||||
_isNonPowerOfTwoTextureNonMipMappedSupported = builtInSupport || isGLExtensionOrVersionSupported(contextID,"GL_ARB_texture_non_power_of_two", 2.0);
|
||||
_isNonPowerOfTwoTextureNonMipMappedSupported = builtInSupport || isGLExtensionOrVersionSupported(contextID,"GL_ARB_texture_non_power_of_two", 2.0) || isGLExtensionSupported(contextID,"GL_APPLE_texture_2D_limited_npot");
|
||||
|
||||
_isNonPowerOfTwoTextureMipMappedSupported = builtInSupport || _isNonPowerOfTwoTextureNonMipMappedSupported;
|
||||
|
||||
|
@ -47,6 +47,24 @@ typedef char TCHAR;
|
||||
// I'm not sure how we would handle this in raw Darwin
|
||||
// without the AvailablilityMacros.
|
||||
#include <AvailabilityMacros.h>
|
||||
|
||||
//>OSG_IOS
|
||||
//IOS includes
|
||||
#include "TargetConditionals.h"
|
||||
|
||||
#if (TARGET_OS_IPHONE)
|
||||
#include <Availability.h>
|
||||
// workaround a bug which appears when compiling for SDK < 4.0 and for the simulator
|
||||
#ifdef __IPHONE_4_0 && (__IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_4_0)
|
||||
#define stat64 stat
|
||||
#else
|
||||
#if !TARGET_IPHONE_SIMULATOR
|
||||
#define stat64 stat
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
//<OSG_IPHONE
|
||||
|
||||
// 10.5 defines stat64 so we can't use this #define
|
||||
// By default, MAC_OS_X_VERSION_MAX_ALLOWED is set to the latest
|
||||
// system the headers know about. So I will use this as the control
|
||||
@ -827,9 +845,11 @@ osgDB::FileOpResult::Value osgDB::copyFile(const std::string & source, const std
|
||||
}
|
||||
|
||||
#elif defined(__APPLE__)
|
||||
|
||||
// #define COMPILE_COCOA_VERSION
|
||||
#define COMPILE_CARBON_VERSION
|
||||
#if (TARGET_OS_IPHONE)
|
||||
#define COMPILE_COCOA_VERSION
|
||||
#else
|
||||
#define COMPILE_CARBON_VERSION
|
||||
#endif
|
||||
// WARNING: Cocoa version is currently untested.
|
||||
#ifdef COMPILE_COCOA_VERSION
|
||||
#include <Foundation/Foundation.h>
|
||||
|
@ -524,7 +524,8 @@ void RenderStage::runCameraSetUp(osg::RenderInfo& renderInfo)
|
||||
OSG_NOTICE<<"RenderStage::runCameraSetUp(), FBO setup failed, FBO status= 0x"<<std::hex<<status<<std::dec<<std::endl;
|
||||
|
||||
fbo_supported = false;
|
||||
fbo_ext->glBindFramebuffer(GL_FRAMEBUFFER_EXT, 0);
|
||||
GLuint fboId = state.getGraphicsContext() ? state.getGraphicsContext()->getDefaultFboId() : 0;
|
||||
fbo_ext->glBindFramebuffer(GL_FRAMEBUFFER_EXT, fboId);
|
||||
fbo = 0;
|
||||
|
||||
// clean up.
|
||||
@ -1050,7 +1051,8 @@ void RenderStage::drawInner(osg::RenderInfo& renderInfo,RenderLeaf*& previous, b
|
||||
if (getDisableFboAfterRender())
|
||||
{
|
||||
// switch off the frame buffer object
|
||||
fbo_ext->glBindFramebuffer(GL_FRAMEBUFFER_EXT, 0);
|
||||
GLuint fboId = state.getGraphicsContext() ? state.getGraphicsContext()->getDefaultFboId() : 0;
|
||||
fbo_ext->glBindFramebuffer(GL_FRAMEBUFFER_EXT, fboId);
|
||||
}
|
||||
|
||||
doCopyTexture = true;
|
||||
|
Loading…
Reference in New Issue
Block a user