- Fixed compilation issues on Android.
- Fixed compilation issues when OpenGL ES1 driver is enabled. (there are still rendering issues related to multitexturing visible in a few examples). Following features are still unavailable in ogl-es branch since rev 5181: * Support for iOS (If you need one of those features please use rev 5180) git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/branches/ogl-es@5204 dfc29bdd-3216-0410-991c-e03cc46cb475master
parent
ed78a4e3d1
commit
a660cd1d38
|
@ -197,7 +197,7 @@ define out. */
|
|||
//! Define _IRR_COMPILE_WITH_OGLES1_ to compile the Irrlicht engine with OpenGL-ES 1.x.
|
||||
/** If you do not wish the engine to be compiled with OpenGL-ES 1.x, comment
|
||||
this define out. */
|
||||
// #define _IRR_COMPILE_WITH_OGLES1_
|
||||
#define _IRR_COMPILE_WITH_OGLES1_
|
||||
#ifdef NO_IRR_COMPILE_WITH_OGLES1_
|
||||
#undef _IRR_COMPILE_WITH_OGLES1_
|
||||
#endif
|
||||
|
|
|
@ -520,7 +520,7 @@ void CIrrDeviceAndroid::createDriver()
|
|||
case video::EDT_SOFTWARE:
|
||||
case video::EDT_BURNINGSVIDEO:
|
||||
case video::EDT_OPENGL:
|
||||
case video::EDT_DIRECT3D8:
|
||||
case video::DEPRECATED_EDT_DIRECT3D8_NO_LONGER_EXISTS:
|
||||
case video::EDT_DIRECT3D9:
|
||||
os::Printer::log("This driver is not available in Android. Try OpenGL ES 1.0 or ES 2.0.", ELL_ERROR);
|
||||
break;
|
||||
|
|
|
@ -37,6 +37,7 @@ LOCAL_SRC_FILES := \
|
|||
CAnimatedMeshSceneNode.cpp \
|
||||
CAttributes.cpp \
|
||||
CB3DMeshFileLoader.cpp \
|
||||
CB3DMeshWriter.cpp \
|
||||
CBillboardSceneNode.cpp \
|
||||
CBoneSceneNode.cpp \
|
||||
CBSPMeshFileLoader.cpp \
|
||||
|
@ -47,11 +48,6 @@ LOCAL_SRC_FILES := \
|
|||
CColorConverter.cpp \
|
||||
CCSMLoader.cpp \
|
||||
CCubeSceneNode.cpp \
|
||||
CD3D8Driver.cpp \
|
||||
CD3D8NormalMapRenderer.cpp \
|
||||
CD3D8ParallaxMapRenderer.cpp \
|
||||
CD3D8ShaderMaterialRenderer.cpp \
|
||||
CD3D8Texture.cpp \
|
||||
CD3D9Driver.cpp \
|
||||
CD3D9HLSLMaterialRenderer.cpp \
|
||||
CD3D9NormalMapRenderer.cpp \
|
||||
|
@ -123,7 +119,6 @@ LOCAL_SRC_FILES := \
|
|||
CIrrDeviceSDL.cpp \
|
||||
CIrrDeviceStub.cpp \
|
||||
CIrrDeviceWin32.cpp \
|
||||
CIrrDeviceWinCE.cpp \
|
||||
CIrrMeshFileLoader.cpp \
|
||||
CIrrMeshWriter.cpp \
|
||||
CLightSceneNode.cpp \
|
||||
|
|
|
@ -25,30 +25,22 @@
|
|||
#include "EProfileIDs.h"
|
||||
#include "IProfiler.h"
|
||||
|
||||
#if defined(_IRR_COMPILE_WITH_IPHONE_DEVICE_)
|
||||
#include <OpenGLES/ES2/gl.h>
|
||||
#include <OpenGLES/ES2/glext.h>
|
||||
#else
|
||||
#include <EGL/egl.h>
|
||||
#include <GLES2/gl2.h>
|
||||
#ifdef _IRR_COMPILE_WITH_ANDROID_DEVICE_
|
||||
#include "android_native_app_glue.h"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
namespace irr
|
||||
{
|
||||
namespace video
|
||||
{
|
||||
|
||||
COGLES2Driver::COGLES2Driver(const SIrrlichtCreationParameters& params,
|
||||
io::IFileSystem* io
|
||||
COGLES2Driver::COGLES2Driver(const SIrrlichtCreationParameters& params, io::IFileSystem* io
|
||||
#if defined(_IRR_COMPILE_WITH_X11_DEVICE_) || defined(_IRR_WINDOWS_API_) || defined(_IRR_COMPILE_WITH_ANDROID_DEVICE_) || defined(_IRR_COMPILE_WITH_FB_DEVICE_)
|
||||
, IContextManager* contextManager
|
||||
#elif defined(_IRR_COMPILE_WITH_IPHONE_DEVICE_)
|
||||
, CIrrDeviceIPhone* device
|
||||
#endif
|
||||
) : CNullDriver(io, params.WindowSize), COGLES2ExtensionHandler(),
|
||||
) : CNullDriver(io, params.WindowSize), COGLES2ExtensionHandler(),
|
||||
CacheHandler(0), MaterialRenderer2D(0), CurrentRenderMode(ERM_NONE), ResetRenderStates(true),
|
||||
Transformation3DChanged(true), AntiAlias(params.AntiAlias), OGLES2ShaderPath(params.OGLES2ShaderPath),
|
||||
CurrentRendertargetSize(0, 0), ColorFormat(ECF_R8G8B8), Params(params)
|
||||
|
@ -141,8 +133,7 @@ COGLES2Driver::~COGLES2Driver()
|
|||
deleteMaterialRenders();
|
||||
|
||||
CacheHandler->getTextureCache().clear();
|
||||
// I get a blue screen on my laptop, when I do not delete the
|
||||
// textures manually before releasing the dc. Oh how I love this.
|
||||
|
||||
removeAllRenderTargets();
|
||||
deleteAllTextures();
|
||||
removeAllOcclusionQueries();
|
||||
|
@ -216,13 +207,13 @@ COGLES2Driver::~COGLES2Driver()
|
|||
|
||||
UserClipPlane.reallocate(0);
|
||||
|
||||
for (s32 i = 0; i < ETS_COUNT; ++i)
|
||||
setTransform(static_cast<E_TRANSFORMATION_STATE>(i), core::IdentityMatrix);
|
||||
|
||||
setAmbientLight(SColorf(0.0f, 0.0f, 0.0f, 0.0f));
|
||||
glClearDepthf(1.0f);
|
||||
|
||||
//TODO : OpenGL ES 2.0 Port : GL_PERSPECTIVE_CORRECTION_HINT
|
||||
//glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_FASTEST);
|
||||
glHint(GL_GENERATE_MIPMAP_HINT, GL_FASTEST);
|
||||
glDepthFunc(GL_LEQUAL);
|
||||
glHint(GL_GENERATE_MIPMAP_HINT, GL_NICEST);
|
||||
glFrontFace(GL_CW);
|
||||
|
||||
// create material renderers
|
||||
|
@ -2044,17 +2035,17 @@ COGLES2Driver::~COGLES2Driver()
|
|||
{
|
||||
IRR_PROFILE(CProfileScope p1(EPID_ES2_SET_RENDERSTATE_2D);)
|
||||
|
||||
if (CurrentRenderMode != ERM_2D)
|
||||
{
|
||||
// unset last 3d material
|
||||
if (CurrentRenderMode == ERM_3D)
|
||||
if (CurrentRenderMode != ERM_2D)
|
||||
{
|
||||
if (static_cast<u32>(LastMaterial.MaterialType) < MaterialRenderers.size())
|
||||
MaterialRenderers[LastMaterial.MaterialType].Renderer->OnUnsetMaterial();
|
||||
}
|
||||
// unset last 3d material
|
||||
if (CurrentRenderMode == ERM_3D)
|
||||
{
|
||||
if (static_cast<u32>(LastMaterial.MaterialType) < MaterialRenderers.size())
|
||||
MaterialRenderers[LastMaterial.MaterialType].Renderer->OnUnsetMaterial();
|
||||
}
|
||||
|
||||
CurrentRenderMode = ERM_2D;
|
||||
}
|
||||
CurrentRenderMode = ERM_2D;
|
||||
}
|
||||
|
||||
MaterialRenderer2D->OnSetMaterial(Material, LastMaterial, true, 0);
|
||||
LastMaterial = Material;
|
||||
|
@ -2070,6 +2061,17 @@ COGLES2Driver::~COGLES2Driver()
|
|||
else
|
||||
CacheHandler->setBlend(false);
|
||||
|
||||
Material.setTexture(0, const_cast<COGLES2Texture*>(CacheHandler->getTextureCache().get(0)));
|
||||
setTransform(ETS_TEXTURE_0, core::IdentityMatrix);
|
||||
|
||||
if (texture)
|
||||
{
|
||||
if (OverrideMaterial2DEnabled)
|
||||
setTextureRenderStates(OverrideMaterial2D, false);
|
||||
else
|
||||
setTextureRenderStates(InitMaterial2D, false);
|
||||
}
|
||||
|
||||
MaterialRenderer2D->OnRender(this, video::EVT_STANDARD);
|
||||
}
|
||||
|
||||
|
@ -2665,32 +2667,30 @@ COGLES2Driver::~COGLES2Driver()
|
|||
|
||||
GLenum COGLES2Driver::getGLBlend(E_BLEND_FACTOR factor) const
|
||||
{
|
||||
GLenum r = 0;
|
||||
switch (factor)
|
||||
static GLenum const blendTable[] =
|
||||
{
|
||||
case EBF_ZERO: r = GL_ZERO; break;
|
||||
case EBF_ONE: r = GL_ONE; break;
|
||||
case EBF_DST_COLOR: r = GL_DST_COLOR; break;
|
||||
case EBF_ONE_MINUS_DST_COLOR: r = GL_ONE_MINUS_DST_COLOR; break;
|
||||
case EBF_SRC_COLOR: r = GL_SRC_COLOR; break;
|
||||
case EBF_ONE_MINUS_SRC_COLOR: r = GL_ONE_MINUS_SRC_COLOR; break;
|
||||
case EBF_SRC_ALPHA: r = GL_SRC_ALPHA; break;
|
||||
case EBF_ONE_MINUS_SRC_ALPHA: r = GL_ONE_MINUS_SRC_ALPHA; break;
|
||||
case EBF_DST_ALPHA: r = GL_DST_ALPHA; break;
|
||||
case EBF_ONE_MINUS_DST_ALPHA: r = GL_ONE_MINUS_DST_ALPHA; break;
|
||||
case EBF_SRC_ALPHA_SATURATE: r = GL_SRC_ALPHA_SATURATE; break;
|
||||
}
|
||||
return r;
|
||||
GL_ZERO,
|
||||
GL_ONE,
|
||||
GL_DST_COLOR,
|
||||
GL_ONE_MINUS_DST_COLOR,
|
||||
GL_SRC_COLOR,
|
||||
GL_ONE_MINUS_SRC_COLOR,
|
||||
GL_SRC_ALPHA,
|
||||
GL_ONE_MINUS_SRC_ALPHA,
|
||||
GL_DST_ALPHA,
|
||||
GL_ONE_MINUS_DST_ALPHA,
|
||||
GL_SRC_ALPHA_SATURATE
|
||||
};
|
||||
|
||||
return blendTable[factor];
|
||||
}
|
||||
|
||||
GLenum COGLES2Driver::getZBufferBits() const
|
||||
{
|
||||
GLenum bits = 0;
|
||||
|
||||
switch (Params.ZBufferBits)
|
||||
{
|
||||
case 16:
|
||||
bits = GL_DEPTH_COMPONENT16;
|
||||
break;
|
||||
case 24:
|
||||
#if defined(GL_OES_depth24)
|
||||
if (queryOpenGLFeature(COGLES2ExtensionHandler::IRR_OES_depth24))
|
||||
|
@ -2708,9 +2708,10 @@ COGLES2Driver::~COGLES2Driver()
|
|||
bits = GL_DEPTH_COMPONENT16;
|
||||
break;
|
||||
default:
|
||||
bits = GL_DEPTH_COMPONENT;
|
||||
bits = GL_DEPTH_COMPONENT16;
|
||||
break;
|
||||
}
|
||||
|
||||
return bits;
|
||||
}
|
||||
|
||||
|
|
|
@ -50,8 +50,7 @@ namespace video
|
|||
|
||||
public:
|
||||
//! constructor
|
||||
COGLES2Driver(const SIrrlichtCreationParameters& params,
|
||||
io::IFileSystem* io
|
||||
COGLES2Driver(const SIrrlichtCreationParameters& params, io::IFileSystem* io
|
||||
#if defined(_IRR_COMPILE_WITH_X11_DEVICE_) || defined(_IRR_WINDOWS_API_) || defined(_IRR_COMPILE_WITH_ANDROID_DEVICE_) || defined(_IRR_COMPILE_WITH_FB_DEVICE_)
|
||||
, IContextManager* contextManager
|
||||
#elif defined(_IRR_COMPILE_WITH_IPHONE_DEVICE_)
|
||||
|
|
|
@ -162,23 +162,28 @@ namespace video
|
|||
MaxTextureSize(1), MaxTextureLODBias(0.f),
|
||||
StencilBuffer(false)
|
||||
{
|
||||
for (u32 i=0; i<IRR_OGLES2_Feature_Count; ++i)
|
||||
for (u32 i = 0; i < IRR_OGLES2_Feature_Count; ++i)
|
||||
FeatureAvailable[i] = false;
|
||||
|
||||
DimAliasedLine[0] = 1.f;
|
||||
DimAliasedLine[1] = 1.f;
|
||||
DimAliasedPoint[0] = 1.f;
|
||||
DimAliasedPoint[1] = 1.f;
|
||||
}
|
||||
|
||||
|
||||
void COGLES2ExtensionHandler::dump() const
|
||||
{
|
||||
for (u32 i=0; i<IRR_OGLES2_Feature_Count; ++i)
|
||||
for (u32 i = 0; i < IRR_OGLES2_Feature_Count; ++i)
|
||||
os::Printer::log(OGLES2FeatureStrings[i], FeatureAvailable[i] ? " true" : " false");
|
||||
}
|
||||
|
||||
|
||||
void COGLES2ExtensionHandler::initExtensions()
|
||||
{
|
||||
const core::stringc stringVer(glGetString(GL_VERSION));
|
||||
const f32 ogl_ver = core::fast_atof(stringVer.c_str() + 10);
|
||||
Version = static_cast<u16>(core::floor32(ogl_ver) * 100 + core::round32(core::fract(ogl_ver) * 10.0f));
|
||||
const f32 ogl_ver = core::fast_atof(reinterpret_cast<const c8*>(glGetString(GL_VERSION)));
|
||||
Version = static_cast<u16>(core::floor32(ogl_ver) * 100 + core::round32(core::fract(ogl_ver)*10.0f));
|
||||
|
||||
core::stringc extensions = glGetString(GL_EXTENSIONS);
|
||||
os::Printer::log(extensions.c_str());
|
||||
|
||||
|
@ -253,4 +258,3 @@ namespace video
|
|||
|
||||
|
||||
#endif // _IRR_COMPILE_WITH_OGLES2_
|
||||
|
||||
|
|
|
@ -170,6 +170,8 @@ namespace video
|
|||
|
||||
COGLES2ExtensionHandler();
|
||||
|
||||
void dump() const;
|
||||
|
||||
void initExtensions();
|
||||
|
||||
const COGLCoreFeature& getFeature() const;
|
||||
|
@ -233,8 +235,6 @@ namespace video
|
|||
return FeatureAvailable[feature];
|
||||
}
|
||||
|
||||
void dump() const;
|
||||
|
||||
inline void irrGlActiveTexture(GLenum texture)
|
||||
{
|
||||
glActiveTexture(texture);
|
||||
|
@ -282,31 +282,6 @@ namespace video
|
|||
glFramebufferTexture2D(target, attachment, textarget, texture, level);
|
||||
}
|
||||
|
||||
inline void irrGlBindRenderbuffer(GLenum target, GLuint renderbuffer)
|
||||
{
|
||||
glBindRenderbuffer(target, renderbuffer);
|
||||
}
|
||||
|
||||
inline void irrGlDeleteRenderbuffers(GLsizei n, const GLuint *renderbuffers)
|
||||
{
|
||||
glDeleteRenderbuffers(n, renderbuffers);
|
||||
}
|
||||
|
||||
inline void irrGlGenRenderbuffers(GLsizei n, GLuint *renderbuffers)
|
||||
{
|
||||
glGenRenderbuffers(n, renderbuffers);
|
||||
}
|
||||
|
||||
inline void irrGlRenderbufferStorage(GLenum target, GLenum internalformat, GLsizei width, GLsizei height)
|
||||
{
|
||||
glRenderbufferStorage(target, internalformat, width, height);
|
||||
}
|
||||
|
||||
inline void irrGlFramebufferRenderbuffer(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer)
|
||||
{
|
||||
glFramebufferRenderbuffer(target, attachment, renderbuffertarget, renderbuffer);
|
||||
}
|
||||
|
||||
inline void irrGlGenerateMipmap(GLenum target)
|
||||
{
|
||||
glGenerateMipmap(target);
|
||||
|
@ -370,9 +345,7 @@ namespace video
|
|||
u32 MaxIndices;
|
||||
u32 MaxTextureSize;
|
||||
f32 MaxTextureLODBias;
|
||||
//! Minimal and maximal supported thickness for lines without smoothing
|
||||
GLfloat DimAliasedLine[2];
|
||||
//! Minimal and maximal supported thickness for points without smoothing
|
||||
GLfloat DimAliasedPoint[2];
|
||||
bool StencilBuffer;
|
||||
bool FeatureAvailable[IRR_OGLES2_Feature_Count];
|
||||
|
|
|
@ -9,96 +9,55 @@
|
|||
|
||||
#ifdef _IRR_COMPILE_WITH_OGLES1_
|
||||
|
||||
#if defined(_IRR_WINDOWS_API_)
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <windows.h>
|
||||
#if defined(_IRR_OPENGL_USE_EXTPOINTER_)
|
||||
#define GL_GLEXT_LEGACY 1
|
||||
#endif
|
||||
#include <GL/gl.h>
|
||||
#if defined(_IRR_OPENGL_USE_EXTPOINTER_)
|
||||
#include "glext.h"
|
||||
#endif
|
||||
#include "wglext.h"
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma comment(lib, "OpenGL32.lib")
|
||||
#endif
|
||||
|
||||
#elif defined(_IRR_COMPILE_WITH_OSX_DEVICE_)
|
||||
#if defined(_IRR_OPENGL_USE_EXTPOINTER_)
|
||||
#define GL_GLEXT_LEGACY 1
|
||||
#endif
|
||||
#include <OpenGL/gl.h>
|
||||
#if defined(_IRR_OPENGL_USE_EXTPOINTER_)
|
||||
#include "glext.h"
|
||||
#endif
|
||||
#elif defined(_IRR_COMPILE_WITH_SDL_DEVICE_) && !defined(_IRR_COMPILE_WITH_X11_DEVICE_)
|
||||
#if defined(_IRR_OPENGL_USE_EXTPOINTER_)
|
||||
#define GL_GLEXT_LEGACY 1
|
||||
#define GLX_GLXEXT_LEGACY 1
|
||||
#else
|
||||
#define GL_GLEXT_PROTOTYPES 1
|
||||
#define GLX_GLXEXT_PROTOTYPES 1
|
||||
#endif
|
||||
#define NO_SDL_GLEXT
|
||||
#include <SDL/SDL_video.h>
|
||||
#include <SDL/SDL_opengl.h>
|
||||
#include "glext.h"
|
||||
#if defined(_IRR_COMPILE_WITH_IPHONE_DEVICE_)
|
||||
#include <OpenGLES/ES1/gl.h>
|
||||
#include <OpenGLES/ES1/glext.h>
|
||||
#elif defined(_IRR_COMPILE_WITH_ANDROID_DEVICE_)
|
||||
#include <GLES/gl.h>
|
||||
#include <GLES/glext.h>
|
||||
#include <EGL/eglplatform.h>
|
||||
#else
|
||||
#if defined(_IRR_OPENGL_USE_EXTPOINTER_)
|
||||
#define GL_GLEXT_LEGACY 1
|
||||
#define GLX_GLXEXT_LEGACY 1
|
||||
#else
|
||||
#define GL_GLEXT_PROTOTYPES 1
|
||||
#define GLX_GLXEXT_PROTOTYPES 1
|
||||
#endif
|
||||
#include <GL/gl.h>
|
||||
#include <GL/glx.h>
|
||||
#if defined(_IRR_OPENGL_USE_EXTPOINTER_)
|
||||
#include "glext.h"
|
||||
#undef GLX_ARB_get_proc_address
|
||||
#include "glxext.h"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef GL_ARB_shader_objects
|
||||
typedef char GLcharARB;
|
||||
typedef unsigned int GLhandleARB;
|
||||
#endif
|
||||
|
||||
#ifndef GL_VERSION_2_0
|
||||
#include <GLES/gl.h>
|
||||
#include <EGL/eglplatform.h>
|
||||
typedef char GLchar;
|
||||
#if defined(_IRR_OGLES1_USE_EXTPOINTER_)
|
||||
#include "gles-ext.h"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef GL_BGRA
|
||||
#define GL_BGRA 0x80E1;
|
||||
#endif
|
||||
|
||||
// Blending definitions.
|
||||
|
||||
#if !defined(GL_VERSION_1_4)
|
||||
#if defined(GL_EXT_blend_subtract) || defined(GL_EXT_blend_minmax) || defined(GL_EXT_blend_logic_op)
|
||||
#define GL_FUNC_ADD GL_FUNC_ADD_EXT
|
||||
#if defined(GL_OES_blend_subtract)
|
||||
#define GL_FUNC_ADD GL_FUNC_ADD_OES
|
||||
#else
|
||||
#define GL_FUNC_ADD 0
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// FBO definitions.
|
||||
|
||||
#if !defined(GL_VERSION_3_0) && !defined(GL_ARB_framebuffer_object)
|
||||
#ifdef GL_EXT_framebuffer_object
|
||||
#define GL_FRAMEBUFFER GL_FRAMEBUFFER_EXT
|
||||
#define GL_COLOR_ATTACHMENT0 GL_COLOR_ATTACHMENT0_EXT
|
||||
#define GL_DEPTH_ATTACHMENT GL_DEPTH_ATTACHMENT_EXT
|
||||
#define GL_STENCIL_ATTACHMENT GL_STENCIL_ATTACHMENT_EXT
|
||||
#define GL_FRAMEBUFFER_COMPLETE GL_FRAMEBUFFER_COMPLETE_EXT
|
||||
#define GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT
|
||||
#define GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT
|
||||
#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT
|
||||
#define GL_FRAMEBUFFER_INCOMPLETE_FORMATS GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT
|
||||
#define GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT
|
||||
#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT
|
||||
#define GL_FRAMEBUFFER_UNSUPPORTED GL_FRAMEBUFFER_UNSUPPORTED_EXT
|
||||
#ifdef GL_OES_framebuffer_object
|
||||
#define GL_NONE GL_NONE_OES
|
||||
#define GL_FRAMEBUFFER GL_FRAMEBUFFER_OES
|
||||
#define GL_DEPTH_COMPONENT16 GL_DEPTH_COMPONENT16_OES
|
||||
#define GL_COLOR_ATTACHMENT0 GL_COLOR_ATTACHMENT0_OES
|
||||
#define GL_DEPTH_ATTACHMENT GL_DEPTH_ATTACHMENT_OES
|
||||
#define GL_STENCIL_ATTACHMENT GL_STENCIL_ATTACHMENT_OES
|
||||
#define GL_FRAMEBUFFER_COMPLETE GL_FRAMEBUFFER_COMPLETE_OES
|
||||
#define GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER 1
|
||||
#define GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER 2
|
||||
#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_OES
|
||||
#define GL_FRAMEBUFFER_INCOMPLETE_FORMATS GL_FRAMEBUFFER_INCOMPLETE_FORMATS_OES
|
||||
#define GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_OES
|
||||
#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_OES
|
||||
#define GL_FRAMEBUFFER_UNSUPPORTED GL_FRAMEBUFFER_UNSUPPORTED_OES
|
||||
#else
|
||||
#define GL_NONE 0
|
||||
#define GL_FRAMEBUFFER 0
|
||||
#define GL_DEPTH_COMPONENT16 0
|
||||
#define GL_COLOR_ATTACHMENT0 0
|
||||
#define GL_DEPTH_ATTACHMENT 0
|
||||
#define GL_STENCIL_ATTACHMENT 0
|
||||
|
@ -106,44 +65,37 @@ typedef char GLchar;
|
|||
#define GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER 1
|
||||
#define GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER 2
|
||||
#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT 3
|
||||
#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT 4
|
||||
#define GL_FRAMEBUFFER_UNSUPPORTED 5
|
||||
#endif
|
||||
#define GL_FRAMEBUFFER_INCOMPLETE_FORMATS 4
|
||||
#define GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS 5
|
||||
#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT 6
|
||||
#define GL_FRAMEBUFFER_UNSUPPORTED 7
|
||||
#endif
|
||||
|
||||
#ifdef GL_EXT_framebuffer_object
|
||||
#define GL_FRAMEBUFFER_INCOMPLETE_FORMATS GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT
|
||||
#define GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT
|
||||
#else
|
||||
#define GL_FRAMEBUFFER_INCOMPLETE_FORMATS 6
|
||||
#define GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS 7
|
||||
#endif
|
||||
|
||||
// MipMaps definitions.
|
||||
|
||||
#if !defined(GL_VERSION_1_4)
|
||||
#ifdef GL_SGIS_generate_mipmap
|
||||
#define GL_GENERATE_MIPMAP GL_GENERATE_MIPMAP_SGIS
|
||||
#define GL_GENERATE_MIPMAP_HINT GL_GENERATE_MIPMAP_HINT_SGIS
|
||||
#else
|
||||
#define GL_GENERATE_MIPMAP 0
|
||||
#define GL_GENERATE_MIPMAP_HINT 0
|
||||
#endif
|
||||
#endif
|
||||
#define GL_DEPTH_COMPONENT 0x1902
|
||||
|
||||
// Texture definitions.
|
||||
|
||||
#if !defined(GL_VERSION_1_3)
|
||||
#ifdef GL_ARB_multitexture
|
||||
#define GL_TEXTURE0 GL_TEXTURE0_ARB
|
||||
#ifdef GL_OES_texture_cube_map
|
||||
#define GL_TEXTURE_CUBE_MAP GL_TEXTURE_CUBE_MAP_OES
|
||||
#define GL_TEXTURE_CUBE_MAP_POSITIVE_X GL_TEXTURE_CUBE_MAP_POSITIVE_X_OES
|
||||
#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X GL_TEXTURE_CUBE_MAP_NEGATIVE_X_OES
|
||||
#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y GL_TEXTURE_CUBE_MAP_POSITIVE_Y_OES
|
||||
#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_OES
|
||||
#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z GL_TEXTURE_CUBE_MAP_POSITIVE_Z_OES
|
||||
#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_OES
|
||||
#else
|
||||
#define GL_TEXTURE0 0
|
||||
#endif
|
||||
#define GL_TEXTURE_CUBE_MAP 0
|
||||
#define GL_TEXTURE_CUBE_MAP_POSITIVE_X 0
|
||||
#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X 0
|
||||
#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y 0
|
||||
#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y 0
|
||||
#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z 0
|
||||
#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z 0
|
||||
#endif
|
||||
|
||||
// Irrlicht's OpenGL version.
|
||||
|
||||
#define IRR_OPENGL_VERSION 14
|
||||
#define IRR_OPENGL_VERSION 15
|
||||
|
||||
namespace irr
|
||||
{
|
||||
|
@ -163,10 +115,10 @@ namespace video
|
|||
template <class TOGLDriver, class TOGLTexture>
|
||||
class COGLCoreCacheHandler;
|
||||
|
||||
class COpenGLDriver;
|
||||
typedef COGLCoreTexture<COpenGLDriver> COpenGLTexture;
|
||||
typedef COGLCoreRenderTarget<COpenGLDriver, COpenGLTexture> COpenGLRenderTarget;
|
||||
class COpenGLCacheHandler;
|
||||
class COGLES1Driver;
|
||||
typedef COGLCoreTexture<COGLES1Driver> COGLES1Texture;
|
||||
typedef COGLCoreRenderTarget<COGLES1Driver, COGLES1Texture> COGLES1RenderTarget;
|
||||
typedef COGLCoreCacheHandler<COGLES1Driver, COGLES1Texture> COGLES1CacheHandler;
|
||||
|
||||
}
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -2,8 +2,8 @@
|
|||
// This file is part of the "Irrlicht Engine".
|
||||
// For conditions of distribution and use, see copyright notice in Irrlicht.h
|
||||
|
||||
#ifndef __C_OGLES_DRIVER_H_INCLUDED__
|
||||
#define __C_OGLES_DRIVER_H_INCLUDED__
|
||||
#ifndef __C_OGLES1_DRIVER_H_INCLUDED__
|
||||
#define __C_OGLES1_DRIVER_H_INCLUDED__
|
||||
|
||||
#include "IrrCompileConfig.h"
|
||||
|
||||
|
@ -15,45 +15,49 @@
|
|||
#include "IMaterialRendererServices.h"
|
||||
#include "EDriverFeatures.h"
|
||||
#include "fast_atof.h"
|
||||
#include "COGLESExtensionHandler.h"
|
||||
#include "IContextManager.h"
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma comment(lib, "libgles_cm.lib")
|
||||
#if defined(_IRR_WINDOWS_API_)
|
||||
// include windows headers for HWND
|
||||
#ifndef WIN32_LEAN_AND_MEAN
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#endif
|
||||
#include <windows.h>
|
||||
#elif defined(_IRR_COMPILE_WITH_IPHONE_DEVICE_)
|
||||
#include "iOS/CIrrDeviceiOS.h"
|
||||
#endif
|
||||
|
||||
#include "COGLESExtensionHandler.h"
|
||||
#ifdef _MSC_VER
|
||||
#pragma comment(lib, "libGLES_CM.lib")
|
||||
#endif
|
||||
|
||||
namespace irr
|
||||
{
|
||||
namespace video
|
||||
{
|
||||
class COGLES1CallBridge;
|
||||
class COGLES1Texture;
|
||||
|
||||
class COGLES1Driver : public CNullDriver, public IMaterialRendererServices, public COGLES1ExtensionHandler
|
||||
{
|
||||
friend class COGLES1Texture;
|
||||
friend COGLES1CacheHandler;
|
||||
friend COGLES1Texture;
|
||||
|
||||
public:
|
||||
//! constructor
|
||||
COGLES1Driver(const SIrrlichtCreationParameters& params,
|
||||
io::IFileSystem* io
|
||||
COGLES1Driver(const SIrrlichtCreationParameters& params, io::IFileSystem* io
|
||||
#if defined(_IRR_COMPILE_WITH_X11_DEVICE_) || defined(_IRR_WINDOWS_API_) || defined(_IRR_COMPILE_WITH_ANDROID_DEVICE_) || defined(_IRR_COMPILE_WITH_FB_DEVICE_)
|
||||
, IContextManager* contextManager
|
||||
, IContextManager* contextManager
|
||||
#elif defined(_IRR_COMPILE_WITH_IPHONE_DEVICE_)
|
||||
, CIrrDeviceIPhone* device
|
||||
, CIrrDeviceIPhone* device
|
||||
#endif
|
||||
);
|
||||
);
|
||||
|
||||
//! destructor
|
||||
virtual ~COGLES1Driver();
|
||||
|
||||
//! clears the zbuffer
|
||||
virtual bool beginScene(bool backBuffer=true, bool zBuffer=true,
|
||||
SColor color=SColor(255,0,0,0),
|
||||
const SExposedVideoData& videoData=SExposedVideoData(),
|
||||
core::rect<s32>* sourceRect=0) _IRR_OVERRIDE_;
|
||||
virtual bool beginScene(u16 clearFlag, SColor clearColor = SColor(255, 0, 0, 0), f32 clearDepth = 1.f, u8 clearStencil = 0,
|
||||
const SExposedVideoData& videoData = SExposedVideoData(), core::rect<s32>* sourceRect = 0) _IRR_OVERRIDE_;
|
||||
|
||||
//! presents the rendered scene on the screen, returns false if failed
|
||||
virtual bool endScene() _IRR_OVERRIDE_;
|
||||
|
||||
//! sets transformation
|
||||
|
@ -87,6 +91,8 @@ namespace video
|
|||
//! Draw hardware buffer
|
||||
virtual void drawHardwareBuffer(SHWBufferLink *HWBuffer) _IRR_OVERRIDE_;
|
||||
|
||||
virtual IRenderTarget* addRenderTarget() _IRR_OVERRIDE_;
|
||||
|
||||
//! draws a vertex primitive list
|
||||
virtual void drawVertexPrimitiveList(const void* vertices, u32 vertexCount,
|
||||
const void* indexList, u32 primitiveCount,
|
||||
|
@ -104,10 +110,15 @@ namespace video
|
|||
//! Sets a material.
|
||||
virtual void setMaterial(const SMaterial& material) _IRR_OVERRIDE_;
|
||||
|
||||
//! draws an 2d image, using a color (if color is other then Color(255,255,255,255)) and the alpha channel of the texture if wanted.
|
||||
virtual void draw2DImage(const video::ITexture* texture, const core::position2d<s32>& destPos,
|
||||
const core::rect<s32>& sourceRect, const core::rect<s32>* clipRect = 0,
|
||||
SColor color=SColor(255,255,255,255), bool useAlphaChannelOfTexture=false) _IRR_OVERRIDE_;
|
||||
SColor color = SColor(255, 255, 255, 255), bool useAlphaChannelOfTexture = false) _IRR_OVERRIDE_;
|
||||
|
||||
virtual void draw2DImage(const video::ITexture* texture, const core::rect<s32>& destRect,
|
||||
const core::rect<s32>& sourceRect, const core::rect<s32>* clipRect = 0,
|
||||
const video::SColor* const colors = 0, bool useAlphaChannelOfTexture = false) _IRR_OVERRIDE_;
|
||||
|
||||
virtual void draw2DImage(const video::ITexture* texture, bool flip);
|
||||
|
||||
//! draws a set of 2d images
|
||||
virtual void draw2DImageBatch(const video::ITexture* texture,
|
||||
|
@ -126,11 +137,6 @@ namespace video
|
|||
SColor color=SColor(255,255,255,255),
|
||||
bool useAlphaChannelOfTexture=false) _IRR_OVERRIDE_;
|
||||
|
||||
//! Draws a part of the texture into the rectangle.
|
||||
virtual void draw2DImage(const video::ITexture* texture, const core::rect<s32>& destRect,
|
||||
const core::rect<s32>& sourceRect, const core::rect<s32>* clipRect = 0,
|
||||
const video::SColor* const colors=0, bool useAlphaChannelOfTexture=false) _IRR_OVERRIDE_;
|
||||
|
||||
//! draw an 2d rectangle
|
||||
virtual void draw2DRectangle(SColor color, const core::rect<s32>& pos,
|
||||
const core::rect<s32>* clip = 0) _IRR_OVERRIDE_;
|
||||
|
@ -206,6 +212,9 @@ namespace video
|
|||
virtual void setBasicRenderStates(const SMaterial& material, const SMaterial& lastmaterial,
|
||||
bool resetAllRenderstates) _IRR_OVERRIDE_;
|
||||
|
||||
//! Compare in SMaterial doesn't check texture parameters, so we should call this on each OnRender call.
|
||||
virtual void setTextureRenderStates(const SMaterial& material, bool resetAllRenderstates);
|
||||
|
||||
//! Get a vertex shader constant index.
|
||||
virtual s32 getVertexShaderConstantID(const c8* name) _IRR_OVERRIDE_;
|
||||
|
||||
|
@ -230,12 +239,6 @@ namespace video
|
|||
//! Sets a pixel shader constant.
|
||||
virtual void setPixelShaderConstant(const f32* data, s32 startRegister, s32 constantAmount=1) _IRR_OVERRIDE_;
|
||||
|
||||
//! sets the current Texture
|
||||
bool setActiveTexture(u32 stage, const video::ITexture* texture);
|
||||
|
||||
//! disables all textures beginning with fromStage.
|
||||
bool disableTextures(u32 fromStage=0);
|
||||
|
||||
//! Adds a new material renderer to the VideoDriver
|
||||
virtual s32 addShaderMaterial(const c8* vertexShaderProgram, const c8* pixelShaderProgram,
|
||||
IShaderConstantSetCallBack* callback, E_MATERIAL_TYPE baseMaterial, s32 userData) _IRR_OVERRIDE_;
|
||||
|
@ -258,12 +261,12 @@ namespace video
|
|||
virtual u32 getMaximalPrimitiveCount() const;
|
||||
|
||||
virtual ITexture* addRenderTargetTexture(const core::dimension2d<u32>& size,
|
||||
const io::path& name, const ECOLOR_FORMAT format = ECF_UNKNOWN) _IRR_OVERRIDE_;
|
||||
virtual bool setRenderTarget(video::ITexture* texture, bool clearBackBuffer,
|
||||
bool clearZBuffer, SColor color) _IRR_OVERRIDE_;
|
||||
const io::path& name, const ECOLOR_FORMAT format = ECF_UNKNOWN) _IRR_OVERRIDE_;
|
||||
|
||||
//! Clears the ZBuffer.
|
||||
virtual void clearZBuffer() _IRR_OVERRIDE_;
|
||||
virtual bool setRenderTarget(IRenderTarget* target, u16 clearFlag, SColor clearColor = SColor(255, 0, 0, 0),
|
||||
f32 clearDepth = 1.f, u8 clearStencil = 0) _IRR_OVERRIDE_;
|
||||
|
||||
virtual void clearBuffers(u16 flag, SColor color = SColor(255, 0, 0, 0), f32 depth = 1.f, u8 stencil = 0) _IRR_OVERRIDE_;
|
||||
|
||||
//! Returns an image created from the last rendered frame.
|
||||
virtual IImage* createScreenShot(video::ECOLOR_FORMAT format=video::ECF_UNKNOWN, video::E_RENDER_TARGET target=video::ERT_FRAME_BUFFER) _IRR_OVERRIDE_;
|
||||
|
@ -291,77 +294,15 @@ namespace video
|
|||
//! Convert E_BLEND_FACTOR to OpenGL equivalent
|
||||
GLenum getGLBlend(E_BLEND_FACTOR factor) const;
|
||||
|
||||
//! Get bridge calls.
|
||||
COGLES1CallBridge* getBridgeCalls() const;
|
||||
//! Get ZBuffer bits.
|
||||
GLenum getZBufferBits() const;
|
||||
|
||||
void getColorFormatParameters(ECOLOR_FORMAT format, GLint& internalFormat, GLenum& pixelFormat,
|
||||
GLenum& pixelType, void(**converter)(const void*, s32, void*));
|
||||
|
||||
COGLES1CacheHandler* getCacheHandler() const;
|
||||
|
||||
private:
|
||||
|
||||
class STextureStageCache
|
||||
{
|
||||
public:
|
||||
STextureStageCache()
|
||||
{
|
||||
for (u32 i = 0; i < MATERIAL_MAX_TEXTURES; ++i)
|
||||
CurrentTexture[i] = 0;
|
||||
}
|
||||
|
||||
~STextureStageCache()
|
||||
{
|
||||
clear();
|
||||
}
|
||||
|
||||
void set(u32 stage, const ITexture* tex)
|
||||
{
|
||||
if (stage < MATERIAL_MAX_TEXTURES)
|
||||
{
|
||||
const ITexture* oldTexture = CurrentTexture[stage];
|
||||
|
||||
if (tex)
|
||||
tex->grab();
|
||||
|
||||
CurrentTexture[stage] = tex;
|
||||
|
||||
if (oldTexture)
|
||||
oldTexture->drop();
|
||||
}
|
||||
}
|
||||
|
||||
const ITexture* operator[](int stage) const
|
||||
{
|
||||
if ((u32)stage < MATERIAL_MAX_TEXTURES)
|
||||
return CurrentTexture[stage];
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
void remove(ITexture* tex)
|
||||
{
|
||||
for (s32 i = MATERIAL_MAX_TEXTURES-1; i>= 0; --i)
|
||||
{
|
||||
if (CurrentTexture[i] == tex)
|
||||
{
|
||||
tex->drop();
|
||||
CurrentTexture[i] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void clear()
|
||||
{
|
||||
for (u32 i = 0; i < MATERIAL_MAX_TEXTURES; ++i)
|
||||
{
|
||||
if (CurrentTexture[i])
|
||||
{
|
||||
CurrentTexture[i]->drop();
|
||||
CurrentTexture[i] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
const ITexture* CurrentTexture[MATERIAL_MAX_TEXTURES];
|
||||
};
|
||||
|
||||
void uploadClipPlane(u32 index);
|
||||
|
||||
//! inits the opengl-es driver
|
||||
|
@ -372,9 +313,8 @@ namespace video
|
|||
virtual ITexture* createDeviceDependentTextureCubemap(const io::path& name, const core::array<IImage*>& image) _IRR_OVERRIDE_;
|
||||
|
||||
//! creates a transposed matrix in supplied GLfloat array to pass to OGLES1
|
||||
inline void createGLMatrix(GLfloat gl_matrix[16], const core::matrix4& m);
|
||||
|
||||
inline void createGLTextureMatrix(GLfloat gl_matrix[16], const core::matrix4& m);
|
||||
inline void getGLMatrix(GLfloat gl_matrix[16], const core::matrix4& m);
|
||||
inline void getGLTextureMatrix(GLfloat gl_matrix[16], const core::matrix4& m);
|
||||
|
||||
//! Set GL pipeline to desired texture wrap modes of the material
|
||||
void setWrapMode(const SMaterial& material);
|
||||
|
@ -398,6 +338,8 @@ namespace video
|
|||
//! \param[in] lightIndex: the index of the requesting light
|
||||
void assignHardwareLight(u32 lightIndex);
|
||||
|
||||
COGLES1CacheHandler* CacheHandler;
|
||||
|
||||
core::stringw Name;
|
||||
core::matrix4 Matrices[ETS_COUNT];
|
||||
core::array<u8> ColorBuffer;
|
||||
|
@ -417,9 +359,6 @@ namespace video
|
|||
u8 AntiAlias;
|
||||
|
||||
SMaterial Material, LastMaterial;
|
||||
COGLES1Texture* RenderTargetTexture;
|
||||
STextureStageCache CurrentTexture;
|
||||
core::array<ITexture*> DepthTextures;
|
||||
core::array<core::plane3df> UserClipPlane;
|
||||
core::array<bool> UserClipPlaneEnabled;
|
||||
|
||||
|
@ -432,6 +371,8 @@ namespace video
|
|||
//! Color buffer format
|
||||
ECOLOR_FORMAT ColorFormat;
|
||||
|
||||
SIrrlichtCreationParameters Params;
|
||||
|
||||
//! All the lights that have been requested; a hardware limited
|
||||
//! number of them will be used at once.
|
||||
struct RequestedLight
|
||||
|
@ -445,51 +386,19 @@ namespace video
|
|||
};
|
||||
core::array<RequestedLight> RequestedLights;
|
||||
|
||||
COGLES1CallBridge* BridgeCalls;
|
||||
|
||||
#if defined(_IRR_COMPILE_WITH_IPHONE_DEVICE_)
|
||||
CIrrDeviceIPhone* Device;
|
||||
GLuint ViewFramebuffer;
|
||||
GLuint ViewRenderbuffer;
|
||||
GLuint ViewDepthRenderbuffer;
|
||||
#elif defined(_IRR_COMPILE_WITH_X11_DEVICE_) || defined(_IRR_WINDOWS_API_) || defined(_IRR_COMPILE_WITH_ANDROID_DEVICE_) || defined(_IRR_COMPILE_WITH_FB_DEVICE_)
|
||||
IContextManager* ContextManager;
|
||||
IContextManager* ContextManager;
|
||||
#endif
|
||||
};
|
||||
|
||||
//! This bridge between Irrlicht pseudo OpenGL ES1.x calls
|
||||
//! and true OpenGL ES1.x calls.
|
||||
|
||||
class COGLES1CallBridge
|
||||
{
|
||||
public:
|
||||
COGLES1CallBridge(COGLES1Driver* driver);
|
||||
|
||||
// Blending calls.
|
||||
|
||||
void setBlendEquation(GLenum mode);
|
||||
|
||||
void setBlendFunc(GLenum source, GLenum destination);
|
||||
|
||||
void setBlendFuncSeparate(GLenum sourceRGB, GLenum destinationRGB, GLenum sourceAlpha, GLenum destinationAlpha);
|
||||
|
||||
void setBlend(bool enable);
|
||||
|
||||
private:
|
||||
COGLES1Driver* Driver;
|
||||
|
||||
GLenum BlendEquation;
|
||||
GLenum BlendSourceRGB;
|
||||
GLenum BlendDestinationRGB;
|
||||
GLenum BlendSourceAlpha;
|
||||
GLenum BlendDestinationAlpha;
|
||||
bool Blend;
|
||||
};
|
||||
|
||||
} // end namespace video
|
||||
} // end namespace irr
|
||||
|
||||
|
||||
#endif // _IRR_COMPILE_WITH_OPENGL_
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
|
@ -3,21 +3,28 @@
|
|||
// This file is part of the "Irrlicht Engine".
|
||||
// For conditions of distribution and use, see copyright notice in Irrlicht.h
|
||||
|
||||
#include "IrrCompileConfig.h"
|
||||
#include "COGLESExtensionHandler.h"
|
||||
|
||||
#ifdef _IRR_COMPILE_WITH_OGLES1_
|
||||
|
||||
#include "COGLESExtensionHandler.h"
|
||||
#include "COGLESDriver.h"
|
||||
#include "fast_atof.h"
|
||||
#include "irrString.h"
|
||||
#include "SMaterial.h"
|
||||
#include "fast_atof.h"
|
||||
|
||||
#if defined(_IRR_OGLES1_USE_EXTPOINTER_)
|
||||
#if defined(_IRR_COMPILE_WITH_ANDROID_DEVICE_) || defined(_IRR_COMPILE_WITH_FB_DEVICE_) || defined(_IRR_COMPILE_WITH_WINDOWS_DEVICE_)
|
||||
#include <EGL/egl.h>
|
||||
#else
|
||||
#include <GLES/egl.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
namespace irr
|
||||
{
|
||||
namespace video
|
||||
{
|
||||
namespace video
|
||||
{
|
||||
|
||||
static const char* const OGLESFeatureStrings[] =
|
||||
static const char* const OGLES1FeatureStrings[COGLES1ExtensionHandler::IRR_OGLES1_Feature_Count] =
|
||||
{
|
||||
"GL_AMD_compressed_3DC_texture",
|
||||
"GL_AMD_compressed_ATC_texture",
|
||||
|
@ -123,161 +130,134 @@ namespace video
|
|||
"GL_VIV_shader_binary"
|
||||
};
|
||||
|
||||
|
||||
COGLES1ExtensionHandler::COGLES1ExtensionHandler() :
|
||||
Version(0), MaxTextureUnits(0), MaxLights(0),
|
||||
MaxAnisotropy(1), MaxUserClipPlanes(0), MaxAuxBuffers(0),
|
||||
MaxMultipleRenderTargets(1), MaxIndices(65535), MaxTextureSize(1),
|
||||
MaxTextureLODBias(0.f), CommonProfile(false),
|
||||
MultiTextureExtension(false), MultiSamplingExtension(false),
|
||||
StencilBuffer(false)
|
||||
COGLES1ExtensionHandler::COGLES1ExtensionHandler() :
|
||||
Version(0), MaxUserClipPlanes(0), MaxLights(0), MaxAnisotropy(1), MaxIndices(0xffff),
|
||||
MaxTextureSize(1), MaxTextureLODBias(0.f), StencilBuffer(false)
|
||||
#if defined(_IRR_OGLES1_USE_EXTPOINTER_)
|
||||
,pGlDrawTexiOES(0), pGlDrawTexfOES(0),
|
||||
pGlDrawTexivOES(0), pGlDrawTexfvOES(0),
|
||||
pGlBlendEquationOES(0), pGlBlendFuncSeparateOES(0),
|
||||
pGlBindRenderbufferOES(0), pGlDeleteRenderbuffersOES(0),
|
||||
pGlGenRenderbuffersOES(0), pGlRenderbufferStorageOES(0),
|
||||
pGlBindFramebufferOES(0), pGlDeleteFramebuffersOES(0),
|
||||
pGlGenFramebuffersOES(0), pGlCheckFramebufferStatusOES(0),
|
||||
pGlFramebufferRenderbufferOES(0), pGlFramebufferTexture2DOES(0),
|
||||
pGlGenerateMipMapOES(0)
|
||||
, pGlBlendEquationOES(0), pGlBlendFuncSeparateOES(0),
|
||||
pGlBindFramebufferOES(0), pGlDeleteFramebuffersOES(0),
|
||||
pGlGenFramebuffersOES(0), pGlCheckFramebufferStatusOES(0),
|
||||
pGlFramebufferTexture2DOES(0), pGlGenerateMipmapOES(0)
|
||||
#endif
|
||||
{
|
||||
for (u32 i = 0; i < IRR_OGLES1_Feature_Count; ++i)
|
||||
FeatureAvailable[i] = false;
|
||||
|
||||
{
|
||||
for (u32 i=0; i<IRR_OGLES_Feature_Count; ++i)
|
||||
FeatureAvailable[i]=false;
|
||||
DimAliasedLine[0]=1.f;
|
||||
DimAliasedLine[1]=1.f;
|
||||
DimAliasedPoint[0]=1.f;
|
||||
DimAliasedPoint[1]=1.f;
|
||||
DimSmoothedLine[0]=1.f;
|
||||
DimSmoothedLine[1]=1.f;
|
||||
DimSmoothedPoint[0]=1.f;
|
||||
DimSmoothedPoint[1]=1.f;
|
||||
}
|
||||
DimAliasedLine[0] = 1.f;
|
||||
DimAliasedLine[1] = 1.f;
|
||||
DimAliasedPoint[0] = 1.f;
|
||||
DimAliasedPoint[1] = 1.f;
|
||||
}
|
||||
|
||||
|
||||
void COGLES1ExtensionHandler::dump() const
|
||||
{
|
||||
for (u32 i=0; i<IRR_OGLES_Feature_Count; ++i)
|
||||
os::Printer::log(OGLESFeatureStrings[i], FeatureAvailable[i]?" true":" false");
|
||||
}
|
||||
void COGLES1ExtensionHandler::dump() const
|
||||
{
|
||||
for (u32 i = 0; i < IRR_OGLES1_Feature_Count; ++i)
|
||||
os::Printer::log(OGLES1FeatureStrings[i], FeatureAvailable[i] ? " true" : " false");
|
||||
}
|
||||
|
||||
|
||||
void COGLES1ExtensionHandler::initExtensions(COGLES1Driver* driver, bool withStencil)
|
||||
{
|
||||
const core::stringc stringVer(glGetString(GL_VERSION));
|
||||
CommonProfile = (stringVer[11]=='M');
|
||||
const f32 ogl_ver = core::fast_atof(stringVer.c_str()+13);
|
||||
Version = static_cast<u16>(core::floor32(ogl_ver)*100+core::round32(core::fract(ogl_ver)*10.0f));
|
||||
core::stringc extensions = glGetString(GL_EXTENSIONS);
|
||||
os::Printer::log(extensions.c_str());
|
||||
void COGLES1ExtensionHandler::initExtensions()
|
||||
{
|
||||
const f32 ogl_ver = core::fast_atof(reinterpret_cast<const c8*>(glGetString(GL_VERSION)));
|
||||
Version = static_cast<u16>(core::floor32(ogl_ver) * 100 + core::round32(core::fract(ogl_ver)*10.0f));
|
||||
if (Version >= 100)
|
||||
os::Printer::log("OpenGL ES driver version is 1.1.", ELL_INFORMATION);
|
||||
else
|
||||
os::Printer::log("OpenGL ES driver version is 1.0.", ELL_WARNING);
|
||||
|
||||
// typo in the simulator (note the postfixed s)
|
||||
if (extensions.find("GL_IMG_user_clip_planes"))
|
||||
core::stringc extensions = glGetString(GL_EXTENSIONS);
|
||||
os::Printer::log(extensions.c_str());
|
||||
|
||||
// typo in the simulator (note the postfixed s)
|
||||
if (extensions.find("GL_IMG_user_clip_planes"))
|
||||
FeatureAvailable[IRR_IMG_user_clip_plane] = true;
|
||||
|
||||
{
|
||||
const u32 size = extensions.size()+1;
|
||||
c8* str = new c8[size];
|
||||
strncpy(str, extensions.c_str(), extensions.size());
|
||||
str[extensions.size()]=' ';
|
||||
c8* p = str;
|
||||
|
||||
for (u32 i=0; i<size; ++i)
|
||||
{
|
||||
if (str[i] == ' ')
|
||||
{
|
||||
str[i] = 0;
|
||||
if (*p)
|
||||
for (u32 j=0; j<IRR_OGLES_Feature_Count; ++j)
|
||||
{
|
||||
if (!strcmp(OGLESFeatureStrings[j], p))
|
||||
{
|
||||
FeatureAvailable[j] = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
const u32 size = extensions.size() + 1;
|
||||
c8* str = new c8[size];
|
||||
strncpy(str, extensions.c_str(), extensions.size());
|
||||
str[extensions.size()] = ' ';
|
||||
c8* p = str;
|
||||
|
||||
p = p + strlen(p) + 1;
|
||||
for (u32 i = 0; i<size; ++i)
|
||||
{
|
||||
if (str[i] == ' ')
|
||||
{
|
||||
str[i] = 0;
|
||||
if (*p)
|
||||
for (u32 j = 0; j<IRR_OGLES1_Feature_Count; ++j)
|
||||
{
|
||||
if (!strcmp(OGLES1FeatureStrings[j], p))
|
||||
{
|
||||
FeatureAvailable[j] = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
p = p + strlen(p) + 1;
|
||||
}
|
||||
}
|
||||
|
||||
delete[] str;
|
||||
}
|
||||
|
||||
delete [] str;
|
||||
}
|
||||
GLint val = 0;
|
||||
|
||||
if (Version > 100 || FeatureAvailable[IRR_IMG_user_clip_plane])
|
||||
{
|
||||
glGetIntegerv(GL_MAX_CLIP_PLANES, &val);
|
||||
MaxUserClipPlanes = static_cast<u8>(val);
|
||||
}
|
||||
|
||||
glGetIntegerv(GL_MAX_LIGHTS, &val);
|
||||
MaxLights = static_cast<u8>(val);
|
||||
|
||||
glGetIntegerv(GL_MAX_TEXTURE_UNITS, &val);
|
||||
Feature.TextureUnit = static_cast<u8>(val);
|
||||
|
||||
GLint val=0;
|
||||
glGetIntegerv(GL_MAX_TEXTURE_UNITS, &val);
|
||||
MaxSupportedTextures = core::min_(MATERIAL_MAX_TEXTURES, static_cast<u32>(val));
|
||||
MultiTextureExtension = true;
|
||||
glGetIntegerv(GL_MAX_LIGHTS, &val);
|
||||
MaxLights = static_cast<u8>(val);
|
||||
#ifdef GL_EXT_texture_filter_anisotropic
|
||||
if (FeatureAvailable[IRR_EXT_texture_filter_anisotropic])
|
||||
{
|
||||
glGetIntegerv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &val);
|
||||
MaxAnisotropy = static_cast<u8>(val);
|
||||
}
|
||||
if (FeatureAvailable[IRR_EXT_texture_filter_anisotropic])
|
||||
{
|
||||
glGetIntegerv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &val);
|
||||
MaxAnisotropy = static_cast<u8>(val);
|
||||
}
|
||||
#endif
|
||||
#ifdef GL_MAX_ELEMENTS_INDICES
|
||||
glGetIntegerv(GL_MAX_ELEMENTS_INDICES, &val);
|
||||
MaxIndices=val;
|
||||
glGetIntegerv(GL_MAX_ELEMENTS_INDICES, &val);
|
||||
MaxIndices = val;
|
||||
#endif
|
||||
glGetIntegerv(GL_MAX_TEXTURE_SIZE, &val);
|
||||
MaxTextureSize=static_cast<u32>(val);
|
||||
glGetIntegerv(GL_MAX_TEXTURE_SIZE, &val);
|
||||
MaxTextureSize = static_cast<u32>(val);
|
||||
#ifdef GL_EXT_texture_lod_bias
|
||||
if (FeatureAvailable[IRR_EXT_texture_lod_bias])
|
||||
glGetFloatv(GL_MAX_TEXTURE_LOD_BIAS_EXT, &MaxTextureLODBias);
|
||||
if (FeatureAvailable[IRR_EXT_texture_lod_bias])
|
||||
glGetFloatv(GL_MAX_TEXTURE_LOD_BIAS_EXT, &MaxTextureLODBias);
|
||||
#endif
|
||||
if ((Version>100) || FeatureAvailable[IRR_IMG_user_clip_plane])
|
||||
{
|
||||
glGetIntegerv(GL_MAX_CLIP_PLANES, &val);
|
||||
MaxUserClipPlanes = static_cast<u8>(val);
|
||||
}
|
||||
glGetFloatv(GL_ALIASED_LINE_WIDTH_RANGE, DimAliasedLine);
|
||||
glGetFloatv(GL_ALIASED_POINT_SIZE_RANGE, DimAliasedPoint);
|
||||
glGetFloatv(GL_SMOOTH_LINE_WIDTH_RANGE, DimSmoothedLine);
|
||||
glGetFloatv(GL_SMOOTH_POINT_SIZE_RANGE, DimSmoothedPoint);
|
||||
glGetFloatv(GL_ALIASED_LINE_WIDTH_RANGE, DimAliasedLine);
|
||||
glGetFloatv(GL_ALIASED_POINT_SIZE_RANGE, DimAliasedPoint);
|
||||
|
||||
MaxTextureUnits = core::min_(MaxSupportedTextures, static_cast<u8>(MATERIAL_MAX_TEXTURES));
|
||||
Feature.TextureUnit = core::min_(Feature.TextureUnit, static_cast<u8>(MATERIAL_MAX_TEXTURES));
|
||||
Feature.ColorAttachment = 1;
|
||||
|
||||
#if defined(_IRR_OGLES1_USE_EXTPOINTER_)
|
||||
#if defined(_IRR_COMPILE_WITH_X11_DEVICE_) || defined(_IRR_WINDOWS_API_) || defined(_IRR_COMPILE_WITH_ANDROID_DEVICE_)
|
||||
if (FeatureAvailable[IRR_OES_draw_texture])
|
||||
{
|
||||
pGlDrawTexiOES = (PFNGLDRAWTEXIOES) eglGetProcAddress("glDrawTexiOES");
|
||||
pGlDrawTexfOES = (PFNGLDRAWTEXFOES) eglGetProcAddress("glDrawTexfOES");
|
||||
pGlDrawTexivOES = (PFNGLDRAWTEXIVOES) eglGetProcAddress("glDrawTexivOES");
|
||||
pGlDrawTexfvOES = (PFNGLDRAWTEXFVOES) eglGetProcAddress("glDrawTexfvOES");
|
||||
}
|
||||
if (FeatureAvailable[IRR_OES_blend_subtract])
|
||||
{
|
||||
pGlBlendEquationOES = (PFNGLBLENDEQUATIONOESPROC) eglGetProcAddress("glBlendEquationOES");
|
||||
}
|
||||
if (FeatureAvailable[IRR_OES_blend_func_separate])
|
||||
{
|
||||
pGlBlendFuncSeparateOES = (PFNGLBLENDFUNCSEPARATEOESPROC) eglGetProcAddress("glBlendFuncSeparateOES");
|
||||
}
|
||||
if (FeatureAvailable[IRR_OES_framebuffer_object])
|
||||
{
|
||||
pGlBindRenderbufferOES = (PFNGLBINDRENDERBUFFEROES) eglGetProcAddress("glBindRenderbufferOES");
|
||||
pGlDeleteRenderbuffersOES = (PFNGLDELETERENDERBUFFERSOES) eglGetProcAddress("glDeletedRenderbuffersOES");
|
||||
pGlGenRenderbuffersOES = (PFNGLGENRENDERBUFFERSOES) eglGetProcAddress("glGenRenderbuffersOES");
|
||||
pGlRenderbufferStorageOES = (PFNGLRENDERBUFFERSTORAGEOES) eglGetProcAddress("glRenderbufferStorageOES");
|
||||
pGlBindFramebufferOES = (PFNGLBINDFRAMEBUFFEROES) eglGetProcAddress("glBindFramebufferOES");
|
||||
pGlDeleteFramebuffersOES = (PFNGLDELETEFRAMEBUFFERSOES) eglGetProcAddress("glDeleteFramebuffersOES");
|
||||
pGlGenFramebuffersOES = (PFNGLGENFRAMEBUFFERSOES) eglGetProcAddress("glGenFramebuffersOES");
|
||||
pGlCheckFramebufferStatusOES = (PFNGLCHECKFRAMEBUFFERSTATUSOES) eglGetProcAddress("glCheckFramebufferStatusOES");
|
||||
pGlFramebufferRenderbufferOES = (PFNGLFRAMEBUFFERRENDERBUFFEROES) eglGetProcAddress("glFramebufferRenderbufferOES");
|
||||
pGlFramebufferTexture2DOES = (PFNGLFRAMEBUFFERTEXTURE2DOES) eglGetProcAddress("glFramebufferTexture2DOES");
|
||||
pGlGenerateMipMapOES = (PFNGLGENERATEMIPMAPOES) eglGetProcAddress("glGenerateMipMapOES");
|
||||
}
|
||||
pGlBlendEquationOES = (PFNGLBLENDEQUATIONOESPROC)eglGetProcAddress("glBlendEquationOES");
|
||||
pGlBlendFuncSeparateOES = (PFNGLBLENDFUNCSEPARATEOESPROC)eglGetProcAddress("glBlendFuncSeparateOES");
|
||||
pGlBindFramebufferOES = (PFNGLBINDFRAMEBUFFEROESPROC)eglGetProcAddress("glBindFramebufferOES");
|
||||
pGlDeleteFramebuffersOES = (PFNGLDELETEFRAMEBUFFERSOESPROC)eglGetProcAddress("glDeleteFramebuffersOES");
|
||||
pGlGenFramebuffersOES = (PFNGLGENFRAMEBUFFERSOESPROC)eglGetProcAddress("glGenFramebuffersOES");
|
||||
pGlCheckFramebufferStatusOES = (PFNGLCHECKFRAMEBUFFERSTATUSOESPROC)eglGetProcAddress("glCheckFramebufferStatusOES");
|
||||
pGlFramebufferTexture2DOES = (PFNGLFRAMEBUFFERTEXTURE2DOESPROC)eglGetProcAddress("glFramebufferTexture2DOES");
|
||||
pGlGenerateMipmapOES = (PFNGLGENERATEMIPMAPOESPROC)eglGetProcAddress("glGenerateMipmapOES");
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
const COGLCoreFeature& COGLES1ExtensionHandler::getFeature() const
|
||||
{
|
||||
return Feature;
|
||||
}
|
||||
|
||||
} // end namespace video
|
||||
} // end namespace irr
|
||||
|
||||
|
||||
#endif // _IRR_COMPILE_WITH_OGLES1_
|
||||
#endif // _IRR_COMPILE_WITH_OGLES2_
|
||||
|
|
|
@ -10,38 +10,23 @@
|
|||
|
||||
#ifdef _IRR_COMPILE_WITH_OGLES1_
|
||||
|
||||
#if defined(_IRR_COMPILE_WITH_X11_DEVICE_) || defined(_IRR_WINDOWS_API_) || defined(_IRR_COMPILE_WITH_ANDROID_DEVICE_)
|
||||
#include "CEGLManager.h"
|
||||
#elif defined(_IRR_COMPILE_WITH_IPHONE_DEVICE_)
|
||||
#include "iOS/CIrrDeviceiOS.h"
|
||||
#endif
|
||||
|
||||
#if defined(_IRR_COMPILE_WITH_IPHONE_DEVICE_)
|
||||
#include <OpenGLES/ES1/gl.h>
|
||||
#include <OpenGLES/ES1/glext.h>
|
||||
#elif defined(_IRR_COMPILE_WITH_ANDROID_DEVICE_)
|
||||
#include <GLES/gl.h>
|
||||
#include <GLES/glext.h>
|
||||
#else
|
||||
#include <GLES/gl.h>
|
||||
typedef char GLchar;
|
||||
#if defined(_IRR_OGLES1_USE_EXTPOINTER_)
|
||||
#include "gles-ext.h"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include "os.h"
|
||||
#include "EDriverFeatures.h"
|
||||
#include "irrTypes.h"
|
||||
#include "os.h"
|
||||
|
||||
#include "COGLESCommon.h"
|
||||
|
||||
#include "COGLCoreFeature.h"
|
||||
|
||||
namespace irr
|
||||
{
|
||||
namespace video
|
||||
{
|
||||
class COGLES1Driver;
|
||||
|
||||
class COGLES1ExtensionHandler
|
||||
{
|
||||
public:
|
||||
enum EOGLESFeatures
|
||||
enum EOGLES1Features
|
||||
{
|
||||
IRR_AMD_compressed_3DC_texture = 0, //39
|
||||
IRR_AMD_compressed_ATC_texture, //40
|
||||
|
@ -146,151 +131,115 @@ namespace video
|
|||
IRR_SUN_multi_draw_arrays, // 70
|
||||
IRR_VIV_shader_binary, // 86
|
||||
|
||||
IRR_OGLES_Feature_Count
|
||||
IRR_OGLES1_Feature_Count
|
||||
};
|
||||
|
||||
//! queries the features of the driver, returns true if feature is available
|
||||
bool queryOpenGLFeature(EOGLESFeatures feature) const
|
||||
{
|
||||
return FeatureAvailable[feature];
|
||||
}
|
||||
|
||||
u16 Version;
|
||||
u8 MaxTextureUnits;
|
||||
u8 MaxSupportedTextures;
|
||||
u8 MaxLights;
|
||||
u8 MaxAnisotropy;
|
||||
u8 MaxUserClipPlanes;
|
||||
u8 MaxAuxBuffers;
|
||||
u8 MaxMultipleRenderTargets;
|
||||
u32 MaxIndices;
|
||||
u32 MaxTextureSize;
|
||||
f32 MaxTextureLODBias;
|
||||
//! Minimal and maximal supported thickness for lines without smoothing
|
||||
GLfloat DimAliasedLine[2];
|
||||
//! Minimal and maximal supported thickness for points without smoothing
|
||||
GLfloat DimAliasedPoint[2];
|
||||
//! Minimal and maximal supported thickness for lines with smoothing
|
||||
GLfloat DimSmoothedLine[2];
|
||||
//! Minimal and maximal supported thickness for points with smoothing
|
||||
GLfloat DimSmoothedPoint[2];
|
||||
bool CommonProfile;
|
||||
bool MultiTextureExtension;
|
||||
bool MultiSamplingExtension;
|
||||
bool StencilBuffer;
|
||||
|
||||
protected:
|
||||
bool FeatureAvailable[IRR_OGLES_Feature_Count];
|
||||
|
||||
COGLES1ExtensionHandler();
|
||||
|
||||
void dump() const;
|
||||
|
||||
void initExtensions();
|
||||
|
||||
const COGLCoreFeature& getFeature() const;
|
||||
|
||||
bool queryFeature(video::E_VIDEO_DRIVER_FEATURE feature) const
|
||||
{
|
||||
switch (feature)
|
||||
{
|
||||
case EVDF_RENDER_TO_TARGET:
|
||||
case EVDF_HARDWARE_TL:
|
||||
return true;
|
||||
case EVDF_MULTITEXTURE:
|
||||
return MultiTextureExtension;
|
||||
case EVDF_BILINEAR_FILTER:
|
||||
case EVDF_MIP_MAP:
|
||||
return true;
|
||||
case EVDF_MIP_MAP_AUTO_UPDATE:
|
||||
return Version>100; // Supported in version 1.1
|
||||
case EVDF_STENCIL_BUFFER:
|
||||
return StencilBuffer;
|
||||
case EVDF_BLEND_OPERATIONS:
|
||||
return FeatureAvailable[IRR_OES_blend_subtract];
|
||||
case EVDF_BLEND_SEPARATE:
|
||||
return FeatureAvailable[IRR_OES_blend_func_separate];
|
||||
case EVDF_FRAMEBUFFER_OBJECT:
|
||||
return FeatureAvailable[IRR_OES_framebuffer_object];
|
||||
case EVDF_TEXTURE_NSQUARE:
|
||||
return true; // non-square is always supported
|
||||
case EVDF_TEXTURE_NPOT:
|
||||
return FeatureAvailable[IRR_APPLE_texture_2D_limited_npot];
|
||||
case EVDF_TEXTURE_COMPRESSED_DXT:
|
||||
return false; // NV Tegra need improvements here
|
||||
case EVDF_TEXTURE_COMPRESSED_PVRTC:
|
||||
return FeatureAvailable[IRR_IMG_texture_compression_pvrtc];
|
||||
case EVDF_TEXTURE_COMPRESSED_PVRTC2:
|
||||
return false;
|
||||
case EVDF_TEXTURE_COMPRESSED_ETC1:
|
||||
return FeatureAvailable[IRR_OES_compressed_ETC1_RGB8_texture];
|
||||
case EVDF_TEXTURE_COMPRESSED_ETC2:
|
||||
return false;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
case EVDF_RENDER_TO_TARGET:
|
||||
case EVDF_HARDWARE_TL:
|
||||
case EVDF_MULTITEXTURE:
|
||||
case EVDF_BILINEAR_FILTER:
|
||||
case EVDF_MIP_MAP:
|
||||
case EVDF_TEXTURE_NSQUARE:
|
||||
case EVDF_STENCIL_BUFFER:
|
||||
case EVDF_ALPHA_TO_COVERAGE:
|
||||
case EVDF_COLOR_MASK:
|
||||
case EVDF_POLYGON_OFFSET:
|
||||
case EVDF_TEXTURE_MATRIX:
|
||||
return true;
|
||||
case EVDF_TEXTURE_NPOT:
|
||||
return FeatureAvailable[IRR_APPLE_texture_2D_limited_npot] || FeatureAvailable[IRR_OES_texture_npot];
|
||||
case EVDF_MIP_MAP_AUTO_UPDATE:
|
||||
return Version>100;
|
||||
case EVDF_BLEND_OPERATIONS:
|
||||
return FeatureAvailable[IRR_OES_blend_subtract];
|
||||
case EVDF_BLEND_SEPARATE:
|
||||
return FeatureAvailable[IRR_OES_blend_func_separate];
|
||||
case EVDF_FRAMEBUFFER_OBJECT:
|
||||
return FeatureAvailable[IRR_OES_framebuffer_object];
|
||||
case EVDF_VERTEX_BUFFER_OBJECT:
|
||||
return Version>100;
|
||||
case EVDF_TEXTURE_COMPRESSED_DXT:
|
||||
return false; // NV Tegra need improvements here
|
||||
case EVDF_TEXTURE_COMPRESSED_PVRTC:
|
||||
return FeatureAvailable[IRR_IMG_texture_compression_pvrtc];
|
||||
case EVDF_TEXTURE_COMPRESSED_ETC1:
|
||||
return FeatureAvailable[IRR_OES_compressed_ETC1_RGB8_texture];
|
||||
case EVDF_TEXTURE_CUBEMAP:
|
||||
return FeatureAvailable[IRR_OES_texture_cube_map];
|
||||
default:
|
||||
return true;
|
||||
};
|
||||
}
|
||||
|
||||
void dump() const;
|
||||
|
||||
void initExtensions(COGLES1Driver* driver, bool withStencil);
|
||||
|
||||
public:
|
||||
void extGlBlendEquation(GLenum mode)
|
||||
bool queryOpenGLFeature(EOGLES1Features feature) const
|
||||
{
|
||||
#ifdef _IRR_OGLES1_USE_EXTPOINTER_
|
||||
if (pGlBlendEquationOES)
|
||||
pGlBlendEquationOES(mode);
|
||||
#elif defined(GL_OES_blend_subtract)
|
||||
glBlendEquationOES(mode);
|
||||
#else
|
||||
os::Printer::log("glBlendEquation not supported", ELL_ERROR);
|
||||
#endif
|
||||
return FeatureAvailable[feature];
|
||||
}
|
||||
|
||||
void extGlBlendFuncSeparate(GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha)
|
||||
inline void irrGlActiveTexture(GLenum texture)
|
||||
{
|
||||
#ifdef _IRR_OGLES1_USE_EXTPOINTER_
|
||||
if (pGlBlendFuncSeparateOES)
|
||||
pGlBlendFuncSeparateOES(srcRGB, dstRGB, srcAlpha, dstAlpha);
|
||||
#elif defined(GL_OES_blend_func_separate)
|
||||
glBlendFuncSeparateOES(srcRGB, dstRGB, srcAlpha, dstAlpha);
|
||||
#else
|
||||
os::Printer::log("glBlendFuncSeparate not supported", ELL_ERROR);
|
||||
#endif
|
||||
glActiveTexture(texture);
|
||||
}
|
||||
|
||||
void extGlBindFramebuffer(GLenum target, GLuint framebuffer)
|
||||
inline void irrGlCompressedTexImage2D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border,
|
||||
GLsizei imageSize, const void* data)
|
||||
{
|
||||
glCompressedTexImage2D(target, level, internalformat, width, height, border, imageSize, data);
|
||||
}
|
||||
|
||||
inline void irrGlCompressedTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height,
|
||||
GLenum format, GLsizei imageSize, const void* data)
|
||||
{
|
||||
glCompressedTexSubImage2D(target, level, xoffset, yoffset, width, height, format, imageSize, data);
|
||||
}
|
||||
|
||||
inline void irrGlUseProgram(GLuint prog)
|
||||
{
|
||||
}
|
||||
|
||||
inline void irrGlBindFramebuffer(GLenum target, GLuint framebuffer)
|
||||
{
|
||||
#ifdef _IRR_OGLES1_USE_EXTPOINTER_
|
||||
if (pGlBindFramebufferOES)
|
||||
pGlBindFramebufferOES(target, framebuffer);
|
||||
#elif defined(GL_OES_framebuffer_object)
|
||||
glBindFramebufferOES(target, framebuffer);
|
||||
#else
|
||||
os::Printer::log("glBindFramebuffer not supported", ELL_ERROR);
|
||||
#endif
|
||||
}
|
||||
|
||||
void extGlDeleteFramebuffers(GLsizei n, const GLuint *framebuffers)
|
||||
inline void irrGlDeleteFramebuffers(GLsizei n, const GLuint *framebuffers)
|
||||
{
|
||||
#ifdef _IRR_OGLES1_USE_EXTPOINTER_
|
||||
if (pGlDeleteFramebuffersOES)
|
||||
pGlDeleteFramebuffersOES(n, framebuffers);
|
||||
#elif defined(GL_OES_framebuffer_object)
|
||||
glDeleteFramebuffersOES(n, framebuffers);
|
||||
#else
|
||||
os::Printer::log("glDeleteFramebuffers not supported", ELL_ERROR);
|
||||
#endif
|
||||
}
|
||||
|
||||
void extGlGenFramebuffers(GLsizei n, GLuint *framebuffers)
|
||||
inline void irrGlGenFramebuffers(GLsizei n, GLuint *framebuffers)
|
||||
{
|
||||
#ifdef _IRR_OGLES1_USE_EXTPOINTER_
|
||||
if (pGlGenFramebuffersOES)
|
||||
pGlGenFramebuffersOES(n, framebuffers);
|
||||
#elif defined(GL_OES_framebuffer_object)
|
||||
glGenFramebuffersOES(n, framebuffers);
|
||||
#else
|
||||
os::Printer::log("glGenFramebuffers not supported", ELL_ERROR);
|
||||
#endif
|
||||
}
|
||||
|
||||
GLenum extGlCheckFramebufferStatus(GLenum target)
|
||||
inline GLenum irrGlCheckFramebufferStatus(GLenum target)
|
||||
{
|
||||
#ifdef _IRR_OGLES1_USE_EXTPOINTER_
|
||||
if (pGlCheckFramebufferStatusOES)
|
||||
|
@ -300,217 +249,121 @@ namespace video
|
|||
#elif defined(GL_OES_framebuffer_object)
|
||||
return glCheckFramebufferStatusOES(target);
|
||||
#else
|
||||
os::Printer::log("glCheckFramebufferStatus not supported", ELL_ERROR);
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
void extGlFramebufferTexture2D(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level)
|
||||
inline void irrGlFramebufferTexture2D(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level)
|
||||
{
|
||||
#ifdef _IRR_OGLES1_USE_EXTPOINTER_
|
||||
if (pGlFramebufferTexture2DOES)
|
||||
pGlFramebufferTexture2DOES(target, attachment, textarget, texture, level);
|
||||
#elif defined(GL_OES_framebuffer_object)
|
||||
glFramebufferTexture2DOES(target, attachment, textarget, texture, level);
|
||||
#else
|
||||
os::Printer::log("glFramebufferTexture2D not supported", ELL_ERROR);
|
||||
#endif
|
||||
}
|
||||
|
||||
void extGlBindRenderbuffer(GLenum target, GLuint renderbuffer)
|
||||
inline void irrGlGenerateMipmap(GLenum target)
|
||||
{
|
||||
#ifdef _IRR_OGLES1_USE_EXTPOINTER_
|
||||
if (pGlBindRenderbufferOES)
|
||||
pGlBindRenderbufferOES(target, renderbuffer);
|
||||
if (pGlGenerateMipmapOES)
|
||||
pGlGenerateMipmapOES(target);
|
||||
#elif defined(GL_OES_framebuffer_object)
|
||||
glBindRenderbufferOES(target, renderbuffer);
|
||||
#else
|
||||
os::Printer::log("glBindRenderbuffer not supported", ELL_ERROR);
|
||||
glGenerateMipmap(target);
|
||||
#endif
|
||||
}
|
||||
|
||||
void extGlDeleteRenderbuffers(GLsizei n, const GLuint *renderbuffers)
|
||||
inline void irrGlActiveStencilFace(GLenum face)
|
||||
{
|
||||
}
|
||||
|
||||
inline void irrGlDrawBuffer(GLenum mode)
|
||||
{
|
||||
}
|
||||
|
||||
inline void irrGlDrawBuffers(GLsizei n, const GLenum *bufs)
|
||||
{
|
||||
}
|
||||
|
||||
inline void irrGlBlendFuncSeparate(GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha)
|
||||
{
|
||||
#ifdef _IRR_OGLES1_USE_EXTPOINTER_
|
||||
if (pGlDeleteRenderbuffersOES)
|
||||
pGlDeleteRenderbuffersOES(n, renderbuffers);
|
||||
#elif defined(GL_OES_framebuffer_object)
|
||||
glDeleteRenderbuffersOES(n, renderbuffers);
|
||||
#else
|
||||
os::Printer::log("glDeleteRenderbuffers not supported", ELL_ERROR);
|
||||
if (pGlBlendFuncSeparateOES)
|
||||
pGlBlendFuncSeparateOES(srcRGB, dstRGB, srcAlpha, dstAlpha);
|
||||
#elif defined(GL_OES_blend_func_separate)
|
||||
glBlendFuncSeparateOES(srcRGB, dstRGB, srcAlpha, dstAlpha);
|
||||
#endif
|
||||
}
|
||||
|
||||
void extGlGenRenderbuffers(GLsizei n, GLuint *renderbuffers)
|
||||
inline void irrGlBlendEquation(GLenum mode)
|
||||
{
|
||||
#ifdef _IRR_OGLES1_USE_EXTPOINTER_
|
||||
if (pGlGenRenderbuffersOES)
|
||||
pGlGenRenderbuffersOES(n, renderbuffers);
|
||||
#elif defined(GL_OES_framebuffer_object)
|
||||
glGenRenderbuffersOES(n, renderbuffers);
|
||||
#else
|
||||
os::Printer::log("glGenRenderbuffers not supported", ELL_ERROR);
|
||||
if (pGlBlendEquationOES)
|
||||
pGlBlendEquationOES(mode);
|
||||
#elif defined(GL_OES_blend_subtract)
|
||||
glBlendEquationOES(mode);
|
||||
#endif
|
||||
}
|
||||
|
||||
void extGlRenderbufferStorage(GLenum target, GLenum internalformat, GLsizei width, GLsizei height)
|
||||
inline void irrGlEnableIndexed(GLenum target, GLuint index)
|
||||
{
|
||||
#ifdef _IRR_OGLES1_USE_EXTPOINTER_
|
||||
if (pGlRenderbufferStorageOES)
|
||||
pGlRenderbufferStorageOES(target, internalformat, width, height);
|
||||
#elif defined(GL_OES_framebuffer_object)
|
||||
glRenderbufferStorageOES(target, internalformat, width, height);
|
||||
#else
|
||||
os::Printer::log("glRenderbufferStorage not supported", ELL_ERROR);
|
||||
#endif
|
||||
}
|
||||
|
||||
void extGlFramebufferRenderbuffer(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer)
|
||||
inline void irrGlDisableIndexed(GLenum target, GLuint index)
|
||||
{
|
||||
#ifdef _IRR_OGLES1_USE_EXTPOINTER_
|
||||
if (pGlFramebufferRenderbufferOES)
|
||||
pGlFramebufferRenderbufferOES(target, attachment, renderbuffertarget, renderbuffer);
|
||||
#elif defined(GL_OES_framebuffer_object)
|
||||
glFramebufferRenderbufferOES(target, attachment, renderbuffertarget, renderbuffer);
|
||||
#else
|
||||
os::Printer::log("glFramebufferRenderbuffer not supported", ELL_ERROR);
|
||||
#endif
|
||||
}
|
||||
|
||||
void extGlDrawTex(GLfloat X, GLfloat Y, GLfloat Z, GLfloat W, GLfloat H)
|
||||
inline void irrGlColorMaskIndexed(GLuint buf, GLboolean r, GLboolean g, GLboolean b, GLboolean a)
|
||||
{
|
||||
}
|
||||
|
||||
inline void irrGlBlendFuncIndexed(GLuint buf, GLenum src, GLenum dst)
|
||||
{
|
||||
}
|
||||
|
||||
inline void irrGlBlendFuncSeparateIndexed(GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha)
|
||||
{
|
||||
}
|
||||
|
||||
inline void irrGlBlendEquationIndexed(GLuint buf, GLenum mode)
|
||||
{
|
||||
}
|
||||
|
||||
inline void irrGlBlendEquationSeparateIndexed(GLuint buf, GLenum modeRGB, GLenum modeAlpha)
|
||||
{
|
||||
}
|
||||
|
||||
protected:
|
||||
COGLCoreFeature Feature;
|
||||
|
||||
u16 Version;
|
||||
u8 MaxUserClipPlanes;
|
||||
u8 MaxLights;
|
||||
u8 MaxAnisotropy;
|
||||
u32 MaxIndices;
|
||||
u32 MaxTextureSize;
|
||||
f32 MaxTextureLODBias;
|
||||
//! Minimal and maximal supported thickness for lines without smoothing
|
||||
GLfloat DimAliasedLine[2];
|
||||
//! Minimal and maximal supported thickness for points without smoothing
|
||||
GLfloat DimAliasedPoint[2];
|
||||
bool StencilBuffer;
|
||||
bool FeatureAvailable[IRR_OGLES1_Feature_Count];
|
||||
|
||||
#if defined(_IRR_OGLES1_USE_EXTPOINTER_)
|
||||
if (pGlDrawTexfOES)
|
||||
pGlDrawTexfOES(X, Y, Z, W, H);
|
||||
#elif defined(GL_OES_draw_texture)
|
||||
glDrawTexfOES(X, Y, Z, W, H);
|
||||
#else
|
||||
os::Printer::log("glDrawTexture not supported", ELL_ERROR);
|
||||
#endif
|
||||
}
|
||||
|
||||
void extGlDrawTex(GLint X, GLint Y, GLint Z, GLint W, GLint H)
|
||||
{
|
||||
#if defined(_IRR_OGLES1_USE_EXTPOINTER_)
|
||||
if (pGlDrawTexiOES)
|
||||
pGlDrawTexiOES(X, Y, Z, W, H);
|
||||
#elif defined(GL_OES_draw_texture)
|
||||
glDrawTexiOES(X, Y, Z, W, H);
|
||||
#else
|
||||
os::Printer::log("glDrawTexture not supported", ELL_ERROR);
|
||||
#endif
|
||||
}
|
||||
|
||||
void extGlDrawTex(GLfloat* coords)
|
||||
{
|
||||
#if defined(_IRR_OGLES1_USE_EXTPOINTER_)
|
||||
if (pGlDrawTexfvOES)
|
||||
pGlDrawTexfvOES(coords);
|
||||
#elif defined(GL_OES_draw_texture)
|
||||
glDrawTexfvOES(coords);
|
||||
#else
|
||||
os::Printer::log("glDrawTexture not supported", ELL_ERROR);
|
||||
#endif
|
||||
}
|
||||
|
||||
void extGlDrawTex(GLint* coords)
|
||||
{
|
||||
#if defined(_IRR_OGLES1_USE_EXTPOINTER_)
|
||||
if (pGlDrawTexivOES)
|
||||
pGlDrawTexivOES(coords);
|
||||
#elif defined(GL_OES_draw_texture)
|
||||
glDrawTexivOES(coords);
|
||||
#else
|
||||
os::Printer::log("glDrawTexture not supported", ELL_ERROR);
|
||||
#endif
|
||||
}
|
||||
|
||||
// we need to implement some methods which have been extensions in the original OpenGL driver
|
||||
void extGlActiveTexture(GLenum texture)
|
||||
{
|
||||
glActiveTexture(texture);
|
||||
}
|
||||
void extGlClientActiveTexture(GLenum texture)
|
||||
{
|
||||
glClientActiveTexture(texture);
|
||||
}
|
||||
void extGlGenBuffers(GLsizei n, GLuint *buffers)
|
||||
{
|
||||
glGenBuffers(n, buffers);
|
||||
}
|
||||
void extGlBindBuffer(GLenum target, GLuint buffer)
|
||||
{
|
||||
glBindBuffer(target, buffer);
|
||||
}
|
||||
void extGlBufferData(GLenum target, GLsizeiptr size, const GLvoid *data, GLenum usage)
|
||||
{
|
||||
glBufferData(target, size, data, usage);
|
||||
}
|
||||
void extGlBufferSubData(GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid *data)
|
||||
{
|
||||
glBufferSubData(target, offset, size, data);
|
||||
}
|
||||
void extGlDeleteBuffers(GLsizei n, const GLuint *buffers)
|
||||
{
|
||||
glDeleteBuffers(n, buffers);
|
||||
}
|
||||
void extGlPointParameterf(GLint loc, GLfloat f)
|
||||
{
|
||||
glPointParameterf(loc, f);
|
||||
}
|
||||
void extGlPointParameterfv(GLint loc, const GLfloat *v)
|
||||
{
|
||||
glPointParameterfv(loc, v);
|
||||
}
|
||||
|
||||
// private:
|
||||
#if defined(_IRR_OGLES1_USE_EXTPOINTER_)
|
||||
typedef void (GL_APIENTRYP PFNGLDRAWTEXIOES) (GLint x, GLint y, GLint z, GLint width, GLint height);
|
||||
typedef void (GL_APIENTRYP PFNGLDRAWTEXIVOES) (const GLint* coords);
|
||||
typedef void (GL_APIENTRYP PFNGLDRAWTEXFOES) (GLfloat x, GLfloat y, GLfloat z, GLfloat width, GLfloat height);
|
||||
typedef void (GL_APIENTRYP PFNGLDRAWTEXFVOES) (const GLfloat* coords);
|
||||
typedef void (GL_APIENTRYP PFNGLBLENDEQUATIONOESPROC) (GLenum mode);
|
||||
typedef void (GL_APIENTRYP PFNGLBLENDFUNCSEPARATEOESPROC) (GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha);
|
||||
typedef GLboolean (GL_APIENTRYP PFNGLISRENDERBUFFEROES) (GLuint renderbuffer);
|
||||
typedef void (GL_APIENTRYP PFNGLBINDRENDERBUFFEROES) (GLenum target, GLuint renderbuffer);
|
||||
typedef void (GL_APIENTRYP PFNGLDELETERENDERBUFFERSOES) (GLsizei n, const GLuint* renderbuffers);
|
||||
typedef void (GL_APIENTRYP PFNGLGENRENDERBUFFERSOES) (GLsizei n, GLuint* renderbuffers);
|
||||
typedef void (GL_APIENTRYP PFNGLRENDERBUFFERSTORAGEOES) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height);
|
||||
typedef void (GL_APIENTRYP PFNGLGETRENDERBUFFERPARAMETERIVOES) (GLenum target, GLenum pname, GLint* params);
|
||||
typedef GLboolean (GL_APIENTRYP PFNGLISFRAMEBUFFEROES) (GLuint framebuffer);
|
||||
typedef void (GL_APIENTRYP PFNGLBINDFRAMEBUFFEROES) (GLenum target, GLuint framebuffer);
|
||||
typedef void (GL_APIENTRYP PFNGLDELETEFRAMEBUFFERSOES) (GLsizei n, const GLuint* framebuffers);
|
||||
typedef void (GL_APIENTRYP PFNGLGENFRAMEBUFFERSOES) (GLsizei n, GLuint* framebuffers);
|
||||
typedef GLenum (GL_APIENTRYP PFNGLCHECKFRAMEBUFFERSTATUSOES) (GLenum target);
|
||||
typedef void (GL_APIENTRYP PFNGLFRAMEBUFFERRENDERBUFFEROES) (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer);
|
||||
typedef void (GL_APIENTRYP PFNGLFRAMEBUFFERTEXTURE2DOES) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level);
|
||||
typedef void (GL_APIENTRYP PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVOES) (GLenum target, GLenum attachment, GLenum pname, GLint* params);
|
||||
typedef void (GL_APIENTRYP PFNGLGENERATEMIPMAPOES) (GLenum target);
|
||||
|
||||
PFNGLDRAWTEXIOES pGlDrawTexiOES;
|
||||
PFNGLDRAWTEXFOES pGlDrawTexfOES;
|
||||
PFNGLDRAWTEXIVOES pGlDrawTexivOES;
|
||||
PFNGLDRAWTEXFVOES pGlDrawTexfvOES;
|
||||
PFNGLBLENDEQUATIONOESPROC pGlBlendEquationOES;
|
||||
PFNGLBLENDFUNCSEPARATEOESPROC pGlBlendFuncSeparateOES;
|
||||
PFNGLBINDRENDERBUFFEROES pGlBindRenderbufferOES;
|
||||
PFNGLDELETERENDERBUFFERSOES pGlDeleteRenderbuffersOES;
|
||||
PFNGLGENRENDERBUFFERSOES pGlGenRenderbuffersOES;
|
||||
PFNGLRENDERBUFFERSTORAGEOES pGlRenderbufferStorageOES;
|
||||
PFNGLBINDFRAMEBUFFEROES pGlBindFramebufferOES;
|
||||
PFNGLDELETEFRAMEBUFFERSOES pGlDeleteFramebuffersOES;
|
||||
PFNGLGENFRAMEBUFFERSOES pGlGenFramebuffersOES;
|
||||
PFNGLCHECKFRAMEBUFFERSTATUSOES pGlCheckFramebufferStatusOES;
|
||||
PFNGLFRAMEBUFFERRENDERBUFFEROES pGlFramebufferRenderbufferOES;
|
||||
PFNGLFRAMEBUFFERTEXTURE2DOES pGlFramebufferTexture2DOES;
|
||||
PFNGLGENERATEMIPMAPOES pGlGenerateMipMapOES;
|
||||
PFNGLBINDFRAMEBUFFEROESPROC pGlBindFramebufferOES;
|
||||
PFNGLDELETEFRAMEBUFFERSOESPROC pGlDeleteFramebuffersOES;
|
||||
PFNGLGENFRAMEBUFFERSOESPROC pGlGenFramebuffersOES;
|
||||
PFNGLCHECKFRAMEBUFFERSTATUSOESPROC pGlCheckFramebufferStatusOES;
|
||||
PFNGLFRAMEBUFFERTEXTURE2DOESPROC pGlFramebufferTexture2DOES;
|
||||
PFNGLGENERATEMIPMAPOESPROC pGlGenerateMipmapOES;
|
||||
#endif
|
||||
};
|
||||
|
||||
} // end namespace video
|
||||
} // end namespace irr
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#endif // _IRR_COMPILE_WITH_OGLES1_
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
|
@ -43,8 +43,6 @@ public:
|
|||
virtual void OnSetMaterial(const SMaterial& material, const SMaterial& lastMaterial,
|
||||
bool resetAllRenderstates, IMaterialRendererServices* services)
|
||||
{
|
||||
Driver->disableTextures(1);
|
||||
Driver->setActiveTexture(0, material.getTexture(0));
|
||||
Driver->setBasicRenderStates(material, lastMaterial, resetAllRenderstates);
|
||||
|
||||
if (resetAllRenderstates || (material.MaterialType != lastMaterial.MaterialType))
|
||||
|
@ -68,8 +66,6 @@ public:
|
|||
virtual void OnSetMaterial(const SMaterial& material, const SMaterial& lastMaterial,
|
||||
bool resetAllRenderstates, IMaterialRendererServices* services)
|
||||
{
|
||||
Driver->disableTextures(1);
|
||||
Driver->setActiveTexture(0, material.getTexture(0));
|
||||
Driver->setBasicRenderStates(material, lastMaterial, resetAllRenderstates);
|
||||
|
||||
// if (material.MaterialType != lastMaterial.MaterialType ||
|
||||
|
@ -81,16 +77,16 @@ public:
|
|||
u32 alphaSource;
|
||||
unpack_textureBlendFuncSeparate(srcRGBFact, dstRGBFact, srcAlphaFact, dstAlphaFact, modulate, alphaSource, material.MaterialTypeParam);
|
||||
|
||||
Driver->getBridgeCalls()->setBlend(true);
|
||||
Driver->getCacheHandler()->setBlend(true);
|
||||
|
||||
if (Driver->queryFeature(EVDF_BLEND_SEPARATE))
|
||||
{
|
||||
Driver->getBridgeCalls()->setBlendFuncSeparate(Driver->getGLBlend(srcRGBFact), Driver->getGLBlend(dstRGBFact),
|
||||
Driver->getCacheHandler()->setBlendFuncSeparate(Driver->getGLBlend(srcRGBFact), Driver->getGLBlend(dstRGBFact),
|
||||
Driver->getGLBlend(srcAlphaFact), Driver->getGLBlend(dstAlphaFact));
|
||||
}
|
||||
else
|
||||
{
|
||||
Driver->getBridgeCalls()->setBlendFunc(Driver->getGLBlend(srcRGBFact), Driver->getGLBlend(dstRGBFact));
|
||||
Driver->getCacheHandler()->setBlendFunc(Driver->getGLBlend(srcRGBFact), Driver->getGLBlend(dstRGBFact));
|
||||
}
|
||||
|
||||
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE);
|
||||
|
@ -120,7 +116,7 @@ public:
|
|||
glTexEnvf(GL_TEXTURE_ENV, GL_RGB_SCALE, 1.f );
|
||||
glTexEnvf(GL_TEXTURE_ENV, GL_SRC1_RGB, GL_PREVIOUS);
|
||||
|
||||
Driver->getBridgeCalls()->setBlend(false);
|
||||
Driver->getCacheHandler()->setBlend(false);
|
||||
glDisable(GL_ALPHA_TEST);
|
||||
}
|
||||
|
||||
|
@ -166,16 +162,13 @@ public:
|
|||
virtual void OnSetMaterial(const SMaterial& material, const SMaterial& lastMaterial,
|
||||
bool resetAllRenderstates, IMaterialRendererServices* services)
|
||||
{
|
||||
Driver->disableTextures(2);
|
||||
Driver->setActiveTexture(1, material.getTexture(1));
|
||||
Driver->setActiveTexture(0, material.getTexture(0));
|
||||
Driver->setBasicRenderStates(material, lastMaterial, resetAllRenderstates);
|
||||
|
||||
if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates)
|
||||
{
|
||||
if (Driver->queryFeature(EVDF_MULTITEXTURE))
|
||||
{
|
||||
Driver->extGlActiveTexture(GL_TEXTURE1);
|
||||
Driver->getCacheHandler()->setActiveTexture(GL_TEXTURE1);
|
||||
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE);
|
||||
glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_ALPHA, GL_REPLACE);
|
||||
glTexEnvf(GL_TEXTURE_ENV, GL_SRC0_ALPHA, GL_PRIMARY_COLOR);
|
||||
|
@ -192,10 +185,10 @@ public:
|
|||
{
|
||||
if (Driver->queryFeature(EVDF_MULTITEXTURE))
|
||||
{
|
||||
Driver->extGlActiveTexture(GL_TEXTURE1);
|
||||
Driver->getCacheHandler()->setActiveTexture(GL_TEXTURE1);
|
||||
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
|
||||
glTexEnvf(GL_TEXTURE_ENV, GL_OPERAND2_RGB, GL_SRC_COLOR);
|
||||
Driver->extGlActiveTexture(GL_TEXTURE0);
|
||||
Driver->getCacheHandler()->setActiveTexture(GL_TEXTURE0);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -212,12 +205,10 @@ public:
|
|||
virtual void OnSetMaterial(const SMaterial& material, const SMaterial& lastMaterial,
|
||||
bool resetAllRenderstates, IMaterialRendererServices* services)
|
||||
{
|
||||
Driver->disableTextures(1);
|
||||
Driver->setActiveTexture(0, material.getTexture(0));
|
||||
Driver->setBasicRenderStates(material, lastMaterial, resetAllRenderstates);
|
||||
|
||||
Driver->getBridgeCalls()->setBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_COLOR);
|
||||
Driver->getBridgeCalls()->setBlend(true);
|
||||
Driver->getCacheHandler()->setBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_COLOR);
|
||||
Driver->getCacheHandler()->setBlend(true);
|
||||
|
||||
if ((material.MaterialType != lastMaterial.MaterialType) || resetAllRenderstates)
|
||||
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
|
||||
|
@ -225,7 +216,7 @@ public:
|
|||
|
||||
virtual void OnUnsetMaterial()
|
||||
{
|
||||
Driver->getBridgeCalls()->setBlend(false);
|
||||
Driver->getCacheHandler()->setBlend(false);
|
||||
}
|
||||
|
||||
//! Returns if the material is transparent.
|
||||
|
@ -247,12 +238,10 @@ public:
|
|||
virtual void OnSetMaterial(const SMaterial& material, const SMaterial& lastMaterial,
|
||||
bool resetAllRenderstates, IMaterialRendererServices* services)
|
||||
{
|
||||
Driver->disableTextures(1);
|
||||
Driver->setActiveTexture(0, material.getTexture(0));
|
||||
Driver->setBasicRenderStates(material, lastMaterial, resetAllRenderstates);
|
||||
|
||||
Driver->getBridgeCalls()->setBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
|
||||
Driver->getBridgeCalls()->setBlend(true);
|
||||
Driver->getCacheHandler()->setBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
|
||||
Driver->getCacheHandler()->setBlend(true);
|
||||
|
||||
if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates)
|
||||
{
|
||||
|
@ -278,7 +267,7 @@ public:
|
|||
glTexEnvf(GL_TEXTURE_ENV, GL_SRC0_RGB, GL_TEXTURE );
|
||||
glTexEnvf(GL_TEXTURE_ENV, GL_SRC1_RGB, GL_PREVIOUS);
|
||||
|
||||
Driver->getBridgeCalls()->setBlend(false);
|
||||
Driver->getCacheHandler()->setBlend(false);
|
||||
}
|
||||
|
||||
//! Returns if the material is transparent.
|
||||
|
@ -300,12 +289,10 @@ public:
|
|||
virtual void OnSetMaterial(const SMaterial& material, const SMaterial& lastMaterial,
|
||||
bool resetAllRenderstates, IMaterialRendererServices* services)
|
||||
{
|
||||
Driver->disableTextures(1);
|
||||
Driver->setActiveTexture(0, material.getTexture(0));
|
||||
Driver->setBasicRenderStates(material, lastMaterial, resetAllRenderstates);
|
||||
|
||||
Driver->getBridgeCalls()->setBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
Driver->getBridgeCalls()->setBlend(true);
|
||||
Driver->getCacheHandler()->setBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
Driver->getCacheHandler()->setBlend(true);
|
||||
|
||||
if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates
|
||||
|| material.MaterialTypeParam != lastMaterial.MaterialTypeParam )
|
||||
|
@ -327,7 +314,7 @@ public:
|
|||
virtual void OnUnsetMaterial()
|
||||
{
|
||||
glDisable(GL_ALPHA_TEST);
|
||||
Driver->getBridgeCalls()->setBlend(false);
|
||||
Driver->getCacheHandler()->setBlend(false);
|
||||
}
|
||||
|
||||
//! Returns if the material is transparent.
|
||||
|
@ -350,8 +337,6 @@ public:
|
|||
virtual void OnSetMaterial(const SMaterial& material, const SMaterial& lastMaterial,
|
||||
bool resetAllRenderstates, IMaterialRendererServices* services)
|
||||
{
|
||||
Driver->disableTextures(1);
|
||||
Driver->setActiveTexture(0, material.getTexture(0));
|
||||
Driver->setBasicRenderStates(material, lastMaterial, resetAllRenderstates);
|
||||
|
||||
if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates)
|
||||
|
@ -386,9 +371,6 @@ public:
|
|||
virtual void OnSetMaterial(const SMaterial& material, const SMaterial& lastMaterial,
|
||||
bool resetAllRenderstates, IMaterialRendererServices* services)
|
||||
{
|
||||
Driver->disableTextures(2);
|
||||
Driver->setActiveTexture(1, material.getTexture(1));
|
||||
Driver->setActiveTexture(0, material.getTexture(0));
|
||||
Driver->setBasicRenderStates(material, lastMaterial, resetAllRenderstates);
|
||||
|
||||
if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates)
|
||||
|
@ -415,7 +397,7 @@ public:
|
|||
{
|
||||
// lightmap
|
||||
|
||||
Driver->extGlActiveTexture(GL_TEXTURE1);
|
||||
Driver->getCacheHandler()->setActiveTexture(GL_TEXTURE1);
|
||||
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE);
|
||||
|
||||
if (material.MaterialType == EMT_LIGHTMAP_ADD)
|
||||
|
@ -451,50 +433,43 @@ public:
|
|||
{
|
||||
if (Driver->queryFeature(EVDF_MULTITEXTURE))
|
||||
{
|
||||
Driver->extGlActiveTexture(GL_TEXTURE1);
|
||||
Driver->getCacheHandler()->setActiveTexture(GL_TEXTURE1);
|
||||
glTexEnvf(GL_TEXTURE_ENV, GL_RGB_SCALE, 1.f );
|
||||
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
|
||||
Driver->extGlActiveTexture(GL_TEXTURE0);
|
||||
Driver->getCacheHandler()->setActiveTexture(GL_TEXTURE0);
|
||||
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
//! detail map material renderer
|
||||
class COGLES1MaterialRenderer_DETAIL_MAP : public COGLES1MaterialRenderer
|
||||
{
|
||||
public:
|
||||
|
||||
COGLES1MaterialRenderer_DETAIL_MAP(video::COGLES1Driver* d)
|
||||
: COGLES1MaterialRenderer(d) {}
|
||||
COGLES1MaterialRenderer_DETAIL_MAP(video::COGLES1Driver* d) : COGLES1MaterialRenderer(d)
|
||||
{
|
||||
}
|
||||
|
||||
virtual void OnSetMaterial(const SMaterial& material, const SMaterial& lastMaterial,
|
||||
bool resetAllRenderstates, IMaterialRendererServices* services)
|
||||
bool resetAllRenderstates, IMaterialRendererServices* services) _IRR_OVERRIDE_
|
||||
{
|
||||
Driver->disableTextures(2);
|
||||
Driver->setActiveTexture(1, material.getTexture(1));
|
||||
Driver->setActiveTexture(0, material.getTexture(0));
|
||||
Driver->setBasicRenderStates(material, lastMaterial, resetAllRenderstates);
|
||||
|
||||
if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates)
|
||||
{
|
||||
// diffuse map
|
||||
|
||||
if (Driver->queryFeature(EVDF_MULTITEXTURE))
|
||||
{
|
||||
// detail map
|
||||
Driver->extGlActiveTexture(GL_TEXTURE1);
|
||||
|
||||
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE);
|
||||
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_ADD_SIGNED);
|
||||
glTexEnvi(GL_TEXTURE_ENV,GL_SRC0_RGB,GL_PREVIOUS);
|
||||
glTexEnvi(GL_TEXTURE_ENV,GL_SRC1_RGB, GL_TEXTURE);
|
||||
Driver->extGlActiveTexture(GL_TEXTURE0);
|
||||
}
|
||||
Driver->getCacheHandler()->setActiveTexture(GL_TEXTURE1);
|
||||
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE);
|
||||
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_ADD_SIGNED);
|
||||
glTexEnvi(GL_TEXTURE_ENV, GL_SRC0_RGB, GL_PREVIOUS);
|
||||
glTexEnvi(GL_TEXTURE_ENV, GL_SRC1_RGB, GL_TEXTURE);
|
||||
}
|
||||
}
|
||||
|
||||
virtual void OnUnsetMaterial() _IRR_OVERRIDE_
|
||||
{
|
||||
Driver->getCacheHandler()->setActiveTexture(GL_TEXTURE1);
|
||||
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
|
||||
Driver->getCacheHandler()->setActiveTexture(GL_TEXTURE0);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
@ -509,8 +484,6 @@ public:
|
|||
virtual void OnSetMaterial(const SMaterial& material, const SMaterial& lastMaterial,
|
||||
bool resetAllRenderstates, IMaterialRendererServices* services)
|
||||
{
|
||||
Driver->disableTextures(1);
|
||||
Driver->setActiveTexture(0, material.getTexture(0));
|
||||
Driver->setBasicRenderStates(material, lastMaterial, resetAllRenderstates);
|
||||
|
||||
if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates)
|
||||
|
@ -542,16 +515,13 @@ public:
|
|||
virtual void OnSetMaterial(const SMaterial& material, const SMaterial& lastMaterial,
|
||||
bool resetAllRenderstates, IMaterialRendererServices* services)
|
||||
{
|
||||
Driver->disableTextures(2);
|
||||
Driver->setActiveTexture(1, material.getTexture(1));
|
||||
Driver->setActiveTexture(0, material.getTexture(0));
|
||||
Driver->setBasicRenderStates(material, lastMaterial, resetAllRenderstates);
|
||||
|
||||
if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates)
|
||||
{
|
||||
if (Driver->queryFeature(EVDF_MULTITEXTURE))
|
||||
{
|
||||
Driver->extGlActiveTexture(GL_TEXTURE1);
|
||||
Driver->getCacheHandler()->setActiveTexture(GL_TEXTURE1);
|
||||
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE);
|
||||
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_MODULATE);
|
||||
glTexEnvi(GL_TEXTURE_ENV, GL_SRC0_RGB, GL_PREVIOUS);
|
||||
|
@ -569,14 +539,14 @@ public:
|
|||
{
|
||||
if (Driver->queryFeature(EVDF_MULTITEXTURE))
|
||||
{
|
||||
Driver->extGlActiveTexture(GL_TEXTURE1);
|
||||
Driver->getCacheHandler()->setActiveTexture(GL_TEXTURE1);
|
||||
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
|
||||
}
|
||||
// glDisable(GL_TEXTURE_GEN_S);
|
||||
// glDisable(GL_TEXTURE_GEN_T);
|
||||
if (Driver->queryFeature(EVDF_MULTITEXTURE))
|
||||
{
|
||||
Driver->extGlActiveTexture(GL_TEXTURE0);
|
||||
Driver->getCacheHandler()->setActiveTexture(GL_TEXTURE0);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -593,19 +563,16 @@ public:
|
|||
virtual void OnSetMaterial(const SMaterial& material, const SMaterial& lastMaterial,
|
||||
bool resetAllRenderstates, IMaterialRendererServices* services)
|
||||
{
|
||||
Driver->disableTextures(2);
|
||||
Driver->setActiveTexture(1, material.getTexture(1));
|
||||
Driver->setActiveTexture(0, material.getTexture(0));
|
||||
Driver->setBasicRenderStates(material, lastMaterial, resetAllRenderstates);
|
||||
|
||||
Driver->getBridgeCalls()->setBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_COLOR);
|
||||
Driver->getBridgeCalls()->setBlend(true);
|
||||
Driver->getCacheHandler()->setBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_COLOR);
|
||||
Driver->getCacheHandler()->setBlend(true);
|
||||
|
||||
if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates)
|
||||
{
|
||||
if (Driver->queryFeature(EVDF_MULTITEXTURE))
|
||||
{
|
||||
Driver->extGlActiveTexture(GL_TEXTURE1);
|
||||
Driver->getCacheHandler()->setActiveTexture(GL_TEXTURE1);
|
||||
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE);
|
||||
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_MODULATE);
|
||||
glTexEnvi(GL_TEXTURE_ENV, GL_SRC0_RGB, GL_PREVIOUS);
|
||||
|
@ -622,16 +589,16 @@ public:
|
|||
{
|
||||
if (Driver->queryFeature(EVDF_MULTITEXTURE))
|
||||
{
|
||||
Driver->extGlActiveTexture(GL_TEXTURE1);
|
||||
Driver->getCacheHandler()->setActiveTexture(GL_TEXTURE1);
|
||||
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
|
||||
}
|
||||
// glDisable(GL_TEXTURE_GEN_S);
|
||||
// glDisable(GL_TEXTURE_GEN_T);
|
||||
if (Driver->queryFeature(EVDF_MULTITEXTURE))
|
||||
{
|
||||
Driver->extGlActiveTexture(GL_TEXTURE0);
|
||||
Driver->getCacheHandler()->setActiveTexture(GL_TEXTURE0);
|
||||
}
|
||||
Driver->getBridgeCalls()->setBlend(false);
|
||||
Driver->getCacheHandler()->setBlend(false);
|
||||
}
|
||||
|
||||
//! Returns if the material is transparent.
|
||||
|
|
Loading…
Reference in New Issue