Remove GLESv1 renderer because it's not used
This commit is contained in:
parent
17a0e4fbd8
commit
f2d21d2353
@ -133,9 +133,6 @@ source/Irrlicht/COGLES2NormalMapRenderer.cpp
|
||||
source/Irrlicht/COGLES2ParallaxMapRenderer.cpp
|
||||
source/Irrlicht/COGLES2Renderer2D.cpp
|
||||
source/Irrlicht/COGLES2Texture.cpp
|
||||
source/Irrlicht/COGLESDriver.cpp
|
||||
source/Irrlicht/COGLESExtensionHandler.cpp
|
||||
source/Irrlicht/COGLESTexture.cpp
|
||||
source/Irrlicht/COpenGLDriver.cpp
|
||||
source/Irrlicht/COpenGLExtensionHandler.cpp
|
||||
source/Irrlicht/COpenGLParallaxMapRenderer.cpp
|
||||
@ -271,10 +268,6 @@ source/Irrlicht/COGLES2NormalMapRenderer.h
|
||||
source/Irrlicht/COGLES2ParallaxMapRenderer.h
|
||||
source/Irrlicht/COGLES2Renderer2D.h
|
||||
source/Irrlicht/COGLES2Texture.h
|
||||
source/Irrlicht/COGLESDriver.h
|
||||
source/Irrlicht/COGLESExtensionHandler.h
|
||||
source/Irrlicht/COGLESMaterialRenderer.h
|
||||
source/Irrlicht/COGLESTexture.h
|
||||
source/Irrlicht/COpenGLDriver.h
|
||||
source/Irrlicht/COpenGLExtensionHandler.h
|
||||
source/Irrlicht/COpenGLMaterialRenderer.h
|
||||
|
@ -100,7 +100,6 @@
|
||||
#if defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) || defined(__IPHONE_OS_VERSION_MIN_REQUIRED)
|
||||
#define _IRR_IPHONE_PLATFORM_
|
||||
#define _IRR_COMPILE_WITH_IPHONE_DEVICE_
|
||||
#define _IRR_COMPILE_WITH_OGLES1_
|
||||
#define _IRR_COMPILE_WITH_OGLES2_
|
||||
#else
|
||||
#define _IRR_COMPILE_WITH_OSX_DEVICE_
|
||||
@ -114,7 +113,6 @@
|
||||
|
||||
#if defined(_IRR_ANDROID_PLATFORM_)
|
||||
#define _IRR_COMPILE_WITH_ANDROID_DEVICE_
|
||||
#define _IRR_COMPILE_WITH_OGLES1_
|
||||
#define _IRR_COMPILE_WITH_OGLES2_
|
||||
#define _IRR_COMPILE_ANDROID_ASSET_READER_
|
||||
#endif
|
||||
@ -181,18 +179,6 @@ define out. */
|
||||
#undef _IRR_COMPILE_WITH_OPENGL_
|
||||
#endif
|
||||
|
||||
//! 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.
|
||||
You should only use this define if you really need the OpenGL-ES driver, and
|
||||
it should be usually the only HW accelerated one. OpenGL is currently disabled
|
||||
if using this driver, to avoid problems with the ogl-es emulators.
|
||||
*/
|
||||
// #define _IRR_COMPILE_WITH_OGLES1_
|
||||
#ifdef NO_IRR_COMPILE_WITH_OGLES1_
|
||||
#undef _IRR_COMPILE_WITH_OGLES1_
|
||||
#endif
|
||||
|
||||
//! Define _IRR_COMPILE_WITH_OGLES2_ to compile the Irrlicht engine with OpenGL-ES 2.x.
|
||||
/** If you do not wish the engine to be compiled with OpenGL-ES 2.x, comment
|
||||
this define out.
|
||||
@ -232,17 +218,6 @@ define out. */
|
||||
#endif
|
||||
#endif
|
||||
|
||||
//! Define _IRR_OGLES1_USE_EXTPOINTER_ if the OpenGL-ES 1.x driver should use extensions via function pointers.
|
||||
/** This should usually be enabled, but also depends on the specific
|
||||
architecture. You can simply uncomment the define and recompile.
|
||||
The iPhone does not have extension pointers, so disable it there always.
|
||||
*/
|
||||
#ifdef _IRR_COMPILE_WITH_OGLES1_
|
||||
#if !defined(_IRR_IPHONE_PLATFORM_)
|
||||
#define _IRR_OGLES1_USE_EXTPOINTER_
|
||||
#endif
|
||||
#endif
|
||||
|
||||
//! Define _IRR_OGLES2_USE_EXTPOINTER_ if the OpenGL-ES 2.x driver should use extensions via function pointers.
|
||||
/** This should usually be enabled, but also depends on the specific
|
||||
architecture. You can simply uncomment the define and recompile.
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,417 +0,0 @@
|
||||
// Copyright (C) 2002-2008 Nikolaus Gebhardt
|
||||
// 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__
|
||||
|
||||
#include "IrrCompileConfig.h"
|
||||
|
||||
#if defined(_IRR_COMPILE_WITH_OSX_DEVICE_)
|
||||
#include "MacOSX/CIrrDeviceMacOSX.h"
|
||||
#elif defined(_IRR_COMPILE_WITH_IPHONE_DEVICE_)
|
||||
#include "iOS/CIrrDeviceiOS.h"
|
||||
#endif
|
||||
|
||||
#include "SIrrCreationParameters.h"
|
||||
|
||||
#ifdef _IRR_COMPILE_WITH_OGLES1_
|
||||
|
||||
#include "CNullDriver.h"
|
||||
#include "IMaterialRendererServices.h"
|
||||
#include "EDriverFeatures.h"
|
||||
#include "fast_atof.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 <EGL/egl.h>
|
||||
#include <GLES/gl.h>
|
||||
#include "android_native_app_glue.h"
|
||||
#else
|
||||
#include <GLES/egl.h>
|
||||
#include <GLES/gl.h>
|
||||
#endif
|
||||
#ifdef _MSC_VER
|
||||
#pragma comment(lib, "libgles_cm.lib")
|
||||
#endif
|
||||
#include "COGLESExtensionHandler.h"
|
||||
|
||||
namespace irr
|
||||
{
|
||||
namespace video
|
||||
{
|
||||
class COGLES1Texture;
|
||||
|
||||
class COGLES1Driver : public CNullDriver, public IMaterialRendererServices, public COGLES1ExtensionHandler
|
||||
{
|
||||
friend class COGLES1Texture;
|
||||
public:
|
||||
#if defined(_IRR_COMPILE_WITH_X11_DEVICE_) || defined(_IRR_COMPILE_WITH_SDL_DEVICE_) || defined(_IRR_WINDOWS_API_) || defined(_IRR_COMPILE_WITH_ANDROID_DEVICE_)
|
||||
COGLES1Driver(const SIrrlichtCreationParameters& params,
|
||||
const SExposedVideoData& data,
|
||||
io::IFileSystem* io);
|
||||
#endif
|
||||
|
||||
#ifdef _IRR_COMPILE_WITH_OSX_DEVICE_
|
||||
COGLES1Driver(const SIrrlichtCreationParameters& params,
|
||||
io::IFileSystem* io, CIrrDeviceMacOSX *device);
|
||||
#endif
|
||||
|
||||
#if defined(_IRR_COMPILE_WITH_IPHONE_DEVICE_)
|
||||
COGLES1Driver(const SIrrlichtCreationParameters& params,
|
||||
const SExposedVideoData& data,
|
||||
io::IFileSystem* io, 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);
|
||||
|
||||
//! presents the rendered scene on the screen, returns false if failed
|
||||
virtual bool endScene();
|
||||
|
||||
//! sets transformation
|
||||
virtual void setTransform(E_TRANSFORMATION_STATE state, const core::matrix4& mat);
|
||||
|
||||
|
||||
struct SHWBufferLink_opengl : public SHWBufferLink
|
||||
{
|
||||
SHWBufferLink_opengl(const scene::IMeshBuffer *_MeshBuffer): SHWBufferLink(_MeshBuffer), vbo_verticesID(0),vbo_indicesID(0){}
|
||||
|
||||
GLuint vbo_verticesID; //tmp
|
||||
GLuint vbo_indicesID; //tmp
|
||||
|
||||
GLuint vbo_verticesSize; //tmp
|
||||
GLuint vbo_indicesSize; //tmp
|
||||
|
||||
};
|
||||
|
||||
bool updateVertexHardwareBuffer(SHWBufferLink_opengl *HWBuffer);
|
||||
bool updateIndexHardwareBuffer(SHWBufferLink_opengl *HWBuffer);
|
||||
|
||||
//! updates hardware buffer if needed
|
||||
virtual bool updateHardwareBuffer(SHWBufferLink *HWBuffer);
|
||||
|
||||
//! Create hardware buffer from mesh
|
||||
virtual SHWBufferLink *createHardwareBuffer(const scene::IMeshBuffer* mb);
|
||||
|
||||
//! Delete hardware buffer (only some drivers can)
|
||||
virtual void deleteHardwareBuffer(SHWBufferLink *HWBuffer);
|
||||
|
||||
//! Draw hardware buffer
|
||||
virtual void drawHardwareBuffer(SHWBufferLink *HWBuffer);
|
||||
|
||||
//! draws a vertex primitive list
|
||||
virtual void drawVertexPrimitiveList(const void* vertices, u32 vertexCount,
|
||||
const void* indexList, u32 primitiveCount,
|
||||
E_VERTEX_TYPE vType, scene::E_PRIMITIVE_TYPE pType, E_INDEX_TYPE iType);
|
||||
|
||||
void drawVertexPrimitiveList2d3d(const void* vertices, u32 vertexCount, const void* indexList, u32 primitiveCount, E_VERTEX_TYPE vType, scene::E_PRIMITIVE_TYPE pType, E_INDEX_TYPE iType=EIT_16BIT, bool threed=true);
|
||||
|
||||
//! queries the features of the driver, returns true if feature is available
|
||||
virtual bool queryFeature(E_VIDEO_DRIVER_FEATURE feature) const
|
||||
{
|
||||
// return FeatureEnabled[feature] && COGLES1ExtensionHandler::queryFeature(feature);
|
||||
return COGLES1ExtensionHandler::queryFeature(feature);
|
||||
}
|
||||
|
||||
//! Sets a material.
|
||||
virtual void setMaterial(const SMaterial& material);
|
||||
|
||||
//! 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);
|
||||
|
||||
//! draws a set of 2d images
|
||||
virtual void draw2DImage(const video::ITexture* texture,
|
||||
const core::position2d<s32>& pos,
|
||||
const core::array<core::rect<s32> >& sourceRects,
|
||||
const core::array<s32>& indices,
|
||||
const core::rect<s32>* clipRect=0,
|
||||
SColor color=SColor(255,255,255,255),
|
||||
bool useAlphaChannelOfTexture=false);
|
||||
|
||||
//! draws a set of 2d images, using a color and the alpha channel of the texture if desired.
|
||||
virtual void draw2DImageBatch(const video::ITexture* texture,
|
||||
const core::array<core::position2d<s32> >& positions,
|
||||
const core::array<core::rect<s32> >& sourceRects,
|
||||
const core::rect<s32>* clipRect=0,
|
||||
SColor color=SColor(255,255,255,255),
|
||||
bool useAlphaChannelOfTexture=false);
|
||||
|
||||
//! 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);
|
||||
|
||||
//! draw an 2d rectangle
|
||||
virtual void draw2DRectangle(SColor color, const core::rect<s32>& pos,
|
||||
const core::rect<s32>* clip = 0);
|
||||
|
||||
//!Draws an 2d rectangle with a gradient.
|
||||
virtual void draw2DRectangle(const core::rect<s32>& pos,
|
||||
SColor colorLeftUp, SColor colorRightUp, SColor colorLeftDown, SColor colorRightDown,
|
||||
const core::rect<s32>* clip = 0);
|
||||
|
||||
//! Draws a 2d line.
|
||||
virtual void draw2DLine(const core::position2d<s32>& start,
|
||||
const core::position2d<s32>& end,
|
||||
SColor color=SColor(255,255,255,255));
|
||||
|
||||
//! Draws a single pixel
|
||||
virtual void drawPixel(u32 x, u32 y, const SColor & color);
|
||||
|
||||
//! Draws a 3d line.
|
||||
virtual void draw3DLine(const core::vector3df& start,
|
||||
const core::vector3df& end,
|
||||
SColor color = SColor(255,255,255,255));
|
||||
|
||||
//! Returns the name of the video driver.
|
||||
virtual const wchar_t* getName() const;
|
||||
|
||||
//! deletes all dynamic lights there are
|
||||
virtual void deleteAllDynamicLights();
|
||||
|
||||
//! adds a dynamic light
|
||||
virtual s32 addDynamicLight(const SLight& light);
|
||||
|
||||
//! Turns a dynamic light on or off
|
||||
//! \param lightIndex: the index returned by addDynamicLight
|
||||
//! \param turnOn: true to turn the light on, false to turn it off
|
||||
virtual void turnLightOn(s32 lightIndex, bool turnOn);
|
||||
|
||||
//! returns the maximal amount of dynamic lights the device can handle
|
||||
virtual u32 getMaximalDynamicLightAmount() const;
|
||||
|
||||
//! Sets the dynamic ambient light color.
|
||||
virtual void setAmbientLight(const SColorf& color);
|
||||
|
||||
//! Draws a shadow volume into the stencil buffer.
|
||||
virtual void drawStencilShadowVolume(const core::vector3df* triangles, s32 count, bool zfail);
|
||||
|
||||
//! Fills the stencil shadow with color.
|
||||
virtual void drawStencilShadow(bool clearStencilBuffer=false,
|
||||
video::SColor leftUpEdge = video::SColor(0,0,0,0),
|
||||
video::SColor rightUpEdge = video::SColor(0,0,0,0),
|
||||
video::SColor leftDownEdge = video::SColor(0,0,0,0),
|
||||
video::SColor rightDownEdge = video::SColor(0,0,0,0));
|
||||
|
||||
//! sets a viewport
|
||||
virtual void setViewPort(const core::rect<s32>& area);
|
||||
|
||||
//! Sets the fog mode.
|
||||
virtual void setFog(SColor color, E_FOG_TYPE fogType, f32 start,
|
||||
f32 end, f32 density, bool pixelFog, bool rangeFog);
|
||||
|
||||
//! Only used internally by the engine
|
||||
virtual void OnResize(const core::dimension2d<u32>& size);
|
||||
|
||||
//! Returns type of video driver
|
||||
virtual E_DRIVER_TYPE getDriverType() const;
|
||||
|
||||
//! get color format of the current color buffer
|
||||
virtual ECOLOR_FORMAT getColorFormat() const;
|
||||
|
||||
//! Returns the transformation set by setTransform
|
||||
virtual const core::matrix4& getTransform(E_TRANSFORMATION_STATE state) const;
|
||||
|
||||
//! Can be called by an IMaterialRenderer to make its work easier.
|
||||
virtual void setBasicRenderStates(const SMaterial& material, const SMaterial& lastmaterial,
|
||||
bool resetAllRenderstates);
|
||||
|
||||
//! Get a vertex shader constant index.
|
||||
virtual s32 getVertexShaderConstantID(const c8* name);
|
||||
|
||||
//! Get a pixel shader constant index.
|
||||
virtual s32 getPixelShaderConstantID(const c8* name);
|
||||
|
||||
//! Sets a constant for the vertex shader based on an index.
|
||||
virtual bool setVertexShaderConstant(s32 index, const f32* floats, int count);
|
||||
|
||||
//! Int interface for the above.
|
||||
virtual bool setVertexShaderConstant(s32 index, const s32* ints, int count);
|
||||
|
||||
//! Sets a constant for the pixel shader based on an index.
|
||||
virtual bool setPixelShaderConstant(s32 index, const f32* floats, int count);
|
||||
|
||||
//! Int interface for the above.
|
||||
virtual bool setPixelShaderConstant(s32 index, const s32* ints, int count);
|
||||
|
||||
//! Sets a vertex shader constant.
|
||||
virtual void setVertexShaderConstant(const f32* data, s32 startRegister, s32 constantAmount=1);
|
||||
|
||||
//! Sets a pixel shader constant.
|
||||
virtual void setPixelShaderConstant(const f32* data, s32 startRegister, s32 constantAmount=1);
|
||||
|
||||
//! 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);
|
||||
|
||||
//! Adds a new material renderer to the VideoDriver
|
||||
virtual s32 addHighLevelShaderMaterial(const c8* vertexShaderProgram, const c8* vertexShaderEntryPointName,
|
||||
E_VERTEX_SHADER_TYPE vsCompileTarget, const c8* pixelShaderProgram, const c8* pixelShaderEntryPointName,
|
||||
E_PIXEL_SHADER_TYPE psCompileTarget, IShaderConstantSetCallBack* callback, E_MATERIAL_TYPE baseMaterial,
|
||||
s32 userData);
|
||||
|
||||
//! Returns pointer to the IGPUProgrammingServices interface.
|
||||
virtual IGPUProgrammingServices* getGPUProgrammingServices();
|
||||
|
||||
//! Returns a pointer to the IVideoDriver interface.
|
||||
virtual IVideoDriver* getVideoDriver();
|
||||
|
||||
//! Returns the maximum amount of primitives
|
||||
virtual u32 getMaximalPrimitiveCount() const;
|
||||
|
||||
virtual ITexture* addRenderTargetTexture(const core::dimension2d<u32>& size,
|
||||
const io::path& name, const ECOLOR_FORMAT format = ECF_UNKNOWN);
|
||||
virtual bool setRenderTarget(video::ITexture* texture, bool clearBackBuffer,
|
||||
bool clearZBuffer, SColor color);
|
||||
|
||||
//! Clears the ZBuffer.
|
||||
virtual void clearZBuffer();
|
||||
|
||||
//! 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);
|
||||
|
||||
//! checks if an OpenGL error has happend and prints it
|
||||
bool testGLError();
|
||||
|
||||
//! checks if an OGLES1 error has happend and prints it
|
||||
bool testEGLError();
|
||||
|
||||
//! Set/unset a clipping plane.
|
||||
virtual bool setClipPlane(u32 index, const core::plane3df& plane, bool enable=false);
|
||||
|
||||
//! Enable/disable a clipping plane.
|
||||
virtual void enableClipPlane(u32 index, bool enable);
|
||||
|
||||
//! Returns the graphics card vendor name.
|
||||
virtual core::stringc getVendorInfo() {return vendorName;};
|
||||
|
||||
//! Get the maximal texture size for this driver
|
||||
core::dimension2du getMaxTextureSize() const;
|
||||
|
||||
ITexture* createDepthTexture(ITexture* texture, bool shared=true);
|
||||
void removeDepthTexture(ITexture* texture);
|
||||
|
||||
private:
|
||||
|
||||
void uploadClipPlane(u32 index);
|
||||
|
||||
//! inits the opengl-es driver
|
||||
bool genericDriverInit(const core::dimension2d<u32>& screenSize, bool stencilBuffer);
|
||||
|
||||
//! returns a device dependent texture from a software surface (IImage)
|
||||
virtual video::ITexture* createDeviceDependentTexture(IImage* surface, const io::path& name, void* mipmapData=0);
|
||||
|
||||
//! 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);
|
||||
|
||||
//! Set GL pipeline to desired texture wrap modes of the material
|
||||
void setWrapMode(const SMaterial& material);
|
||||
|
||||
//! Get OpenGL wrap enum from Irrlicht enum
|
||||
GLint getTextureWrapMode(u8 clamp) const;
|
||||
|
||||
//! sets the needed renderstates
|
||||
void setRenderStates3DMode();
|
||||
|
||||
//! sets the needed renderstates
|
||||
void setRenderStates2DMode(bool alpha, bool texture, bool alphaChannel);
|
||||
|
||||
// returns the current size of the screen or rendertarget
|
||||
virtual const core::dimension2d<u32>& getCurrentRenderTargetSize() const;
|
||||
|
||||
void createMaterialRenderers();
|
||||
|
||||
//! Assign a hardware light to the specified requested light, if any
|
||||
//! free hardware lights exist.
|
||||
//! \param[in] lightIndex: the index of the requesting light
|
||||
void assignHardwareLight(u32 lightIndex);
|
||||
|
||||
core::stringw Name;
|
||||
core::matrix4 Matrices[ETS_COUNT];
|
||||
core::array<u8> ColorBuffer;
|
||||
|
||||
//! enumeration for rendering modes such as 2d and 3d for minizing the switching of renderStates.
|
||||
enum E_RENDER_MODE
|
||||
{
|
||||
ERM_NONE = 0, // no render state has been set yet.
|
||||
ERM_2D, // 2d drawing rendermode
|
||||
ERM_3D // 3d rendering mode
|
||||
};
|
||||
|
||||
E_RENDER_MODE CurrentRenderMode;
|
||||
//! bool to make all renderstates reset if set to true.
|
||||
bool ResetRenderStates;
|
||||
bool Transformation3DChanged;
|
||||
u8 AntiAlias;
|
||||
|
||||
SMaterial Material, LastMaterial;
|
||||
COGLES1Texture* RenderTargetTexture;
|
||||
const ITexture* CurrentTexture[MATERIAL_MAX_TEXTURES];
|
||||
core::array<ITexture*> DepthTextures;
|
||||
core::array<core::plane3df> UserClipPlane;
|
||||
core::array<bool> UserClipPlaneEnabled;
|
||||
|
||||
core::dimension2d<u32> CurrentRendertargetSize;
|
||||
|
||||
core::stringc vendorName;
|
||||
|
||||
core::matrix4 TextureFlipMatrix;
|
||||
|
||||
//! Color buffer format
|
||||
ECOLOR_FORMAT ColorFormat;
|
||||
|
||||
//! All the lights that have been requested; a hardware limited
|
||||
//! number of them will be used at once.
|
||||
struct RequestedLight
|
||||
{
|
||||
RequestedLight(SLight const & lightData)
|
||||
: LightData(lightData), HardwareLightIndex(-1), DesireToBeOn(true) { }
|
||||
|
||||
SLight LightData;
|
||||
s32 HardwareLightIndex; // GL_LIGHT0 - GL_LIGHT7
|
||||
bool DesireToBeOn;
|
||||
};
|
||||
core::array<RequestedLight> RequestedLights;
|
||||
|
||||
#ifdef _IRR_COMPILE_WITH_WINDOWS_DEVICE_
|
||||
HDC HDc;
|
||||
#endif
|
||||
#if defined(_IRR_COMPILE_WITH_IPHONE_DEVICE_)
|
||||
CIrrDeviceIPhone* Device;
|
||||
GLuint ViewFramebuffer;
|
||||
GLuint ViewRenderbuffer;
|
||||
GLuint ViewDepthRenderbuffer;
|
||||
#else
|
||||
NativeWindowType EglWindow;
|
||||
EGLDisplay EglDisplay;
|
||||
EGLSurface EglSurface;
|
||||
EGLContext EglContext;
|
||||
#endif
|
||||
};
|
||||
|
||||
} // end namespace video
|
||||
} // end namespace irr
|
||||
|
||||
|
||||
#endif // _IRR_COMPILE_WITH_OPENGL_
|
||||
#endif
|
||||
|
@ -1,281 +0,0 @@
|
||||
// Copyright (C) 2008 Christian Stehno
|
||||
// Heavily based on the OpenGL driver implemented by Nikolaus Gebhardt
|
||||
// This file is part of the "Irrlicht Engine".
|
||||
// For conditions of distribution and use, see copyright notice in Irrlicht.h
|
||||
|
||||
#include "IrrCompileConfig.h"
|
||||
|
||||
#ifdef _IRR_COMPILE_WITH_OGLES1_
|
||||
|
||||
#include "COGLESExtensionHandler.h"
|
||||
#include "COGLESDriver.h"
|
||||
#include "fast_atof.h"
|
||||
#include "irrString.h"
|
||||
|
||||
namespace irr
|
||||
{
|
||||
namespace video
|
||||
{
|
||||
|
||||
static const char* const OGLESFeatureStrings[] =
|
||||
{
|
||||
"GL_AMD_compressed_3DC_texture",
|
||||
"GL_AMD_compressed_ATC_texture",
|
||||
"GL_AMD_performance_monitor",
|
||||
"GL_AMD_program_binary_Z400",
|
||||
"GL_ANGLE_framebuffer_blit",
|
||||
"GL_ANGLE_framebuffer_multisample",
|
||||
"GL_APPLE_copy_texture_levels",
|
||||
"GL_APPLE_framebuffer_multisample",
|
||||
"GL_APPLE_rgb_422",
|
||||
"GL_APPLE_sync",
|
||||
"GL_APPLE_texture_2D_limited_npot",
|
||||
"GL_APPLE_texture_format_BGRA8888",
|
||||
"GL_APPLE_texture_max_level",
|
||||
"GL_ARB_texture_env_combine",
|
||||
"GL_ARB_texture_env_dot3",
|
||||
"GL_ARM_mali_shader_binary",
|
||||
"GL_ARM_rgba8",
|
||||
"GL_DMP_shader_binary",
|
||||
"GL_EXT_blend_minmax",
|
||||
"GL_EXT_discard_framebuffer",
|
||||
"GL_EXT_frag_depth",
|
||||
"GL_EXT_map_buffer_range",
|
||||
"GL_EXT_multi_draw_arrays",
|
||||
"GL_EXT_multisampled_render_to_texture",
|
||||
"GL_EXT_read_format_bgra",
|
||||
"GL_EXT_robustness",
|
||||
"GL_EXT_shader_texture_lod",
|
||||
"GL_EXT_sRGB",
|
||||
"GL_EXT_texture_compression_dxt1",
|
||||
"GL_EXT_texture_filter_anisotropic",
|
||||
"GL_EXT_texture_format_BGRA8888",
|
||||
"GL_EXT_texture_lod_bias",
|
||||
"GL_EXT_texture_storage",
|
||||
"GL_EXT_texture_type_2_10_10_10_REV",
|
||||
"GL_IMG_multisampled_render_to_texture",
|
||||
"GL_IMG_program_binary",
|
||||
"GL_IMG_read_format",
|
||||
"GL_IMG_shader_binary",
|
||||
"GL_IMG_texture_compression_pvrtc",
|
||||
"GL_IMG_texture_env_enhanced_fixed_function",
|
||||
"GL_IMG_texture_format_BGRA8888",
|
||||
"GL_IMG_user_clip_plane",
|
||||
"GL_IMG_vertex_program",
|
||||
"GL_NV_coverage_sample",
|
||||
"GL_NV_depth_nonlinear",
|
||||
"GL_NV_fence",
|
||||
"GL_OES_blend_equation_separate",
|
||||
"GL_OES_blend_func_separate",
|
||||
"GL_OES_blend_subtract",
|
||||
"GL_OES_byte_coordinates",
|
||||
"GL_OES_compressed_ETC1_RGB8_texture",
|
||||
"GL_OES_compressed_paletted_texture",
|
||||
"GL_OES_depth24",
|
||||
"GL_OES_depth32",
|
||||
"GL_OES_depth_texture",
|
||||
"GL_OES_draw_texture",
|
||||
"GL_OES_EGL_image",
|
||||
"GL_OES_EGL_image_external",
|
||||
"GL_OES_EGL_sync",
|
||||
"GL_OES_element_index_uint",
|
||||
"GL_OES_extended_matrix_palette",
|
||||
"GL_OES_fbo_render_mipmap",
|
||||
"GL_OES_fixed_point",
|
||||
"GL_OES_fragment_precision_high",
|
||||
"GL_OES_framebuffer_object",
|
||||
"GL_OES_get_program_binary",
|
||||
"GL_OES_mapbuffer",
|
||||
"GL_OES_matrix_get",
|
||||
"GL_OES_matrix_palette",
|
||||
"GL_OES_packed_depth_stencil",
|
||||
"GL_OES_point_size_array",
|
||||
"GL_OES_point_sprite",
|
||||
"GL_OES_query_matrix",
|
||||
"GL_OES_read_format",
|
||||
"GL_OES_required_internalformat",
|
||||
"GL_OES_rgb8_rgba8",
|
||||
"GL_OES_single_precision",
|
||||
"GL_OES_standard_derivatives",
|
||||
"GL_OES_stencil1",
|
||||
"GL_OES_stencil4",
|
||||
"GL_OES_stencil8",
|
||||
"GL_OES_stencil_wrap",
|
||||
"GL_OES_texture_3D",
|
||||
"GL_OES_texture_cube_map",
|
||||
"GL_OES_texture_env_crossbar",
|
||||
"GL_OES_texture_float",
|
||||
"GL_OES_texture_float_linear",
|
||||
"GL_OES_texture_half_float",
|
||||
"GL_OES_texture_half_float_linear",
|
||||
"GL_OES_texture_mirrored_repeat",
|
||||
"GL_OES_texture_npot",
|
||||
"GL_OES_vertex_array_object",
|
||||
"GL_OES_vertex_half_float",
|
||||
"GL_OES_vertex_type_10_10_10_2",
|
||||
"GL_QCOM_driver_control",
|
||||
"GL_QCOM_extended_get",
|
||||
"GL_QCOM_extended_get2",
|
||||
"GL_QCOM_performance_monitor_global_mode",
|
||||
"GL_QCOM_tiled_rendering",
|
||||
"GL_QCOM_writeonly_rendering",
|
||||
"GL_SUN_multi_draw_arrays",
|
||||
"GL_VIV_shader_binary"
|
||||
};
|
||||
|
||||
|
||||
COGLES1ExtensionHandler::COGLES1ExtensionHandler() :
|
||||
#if defined(_IRR_OGLES1_USE_EXTPOINTER_)
|
||||
pGlDrawTexiOES(0), pGlDrawTexfOES(0),
|
||||
pGlDrawTexivOES(0), pGlDrawTexfvOES(0),
|
||||
pGlBindRenderbufferOES(0), pGlDeleteRenderbuffersOES(0),
|
||||
pGlGenRenderbuffersOES(0), pGlRenderbufferStorageOES(0),
|
||||
pGlBindFramebufferOES(0), pGlDeleteFramebuffersOES(0),
|
||||
pGlGenFramebuffersOES(0), pGlCheckFramebufferStatusOES(0),
|
||||
pGlFramebufferRenderbufferOES(0), pGlFramebufferTexture2DOES(0),
|
||||
pGlGenerateMipMapOES(0),
|
||||
#endif
|
||||
EGLVersion(0), 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)
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
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::initExtensions(COGLES1Driver* driver,
|
||||
#ifdef EGL_VERSION_1_0
|
||||
EGLDisplay display,
|
||||
#endif
|
||||
bool withStencil)
|
||||
{
|
||||
#ifdef EGL_VERSION_1_0
|
||||
const f32 egl_ver = core::fast_atof(reinterpret_cast<const c8*>(eglQueryString(display, EGL_VERSION)));
|
||||
EGLVersion = static_cast<u16>(core::floor32(egl_ver)*100+core::round32(core::fract(egl_ver)*10.0f));
|
||||
core::stringc eglExtensions = eglQueryString(display, EGL_EXTENSIONS);
|
||||
os::Printer::log(eglExtensions.c_str());
|
||||
#endif
|
||||
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());
|
||||
|
||||
// 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;
|
||||
}
|
||||
}
|
||||
|
||||
p = p + strlen(p) + 1;
|
||||
}
|
||||
}
|
||||
|
||||
delete [] str;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
#endif
|
||||
#ifdef GL_MAX_ELEMENTS_INDICES
|
||||
glGetIntegerv(GL_MAX_ELEMENTS_INDICES, &val);
|
||||
MaxIndices=val;
|
||||
#endif
|
||||
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);
|
||||
#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);
|
||||
|
||||
MaxTextureUnits = core::min_(MaxSupportedTextures, static_cast<u8>(MATERIAL_MAX_TEXTURES));
|
||||
|
||||
#if defined(_IRR_OGLES1_USE_EXTPOINTER_)
|
||||
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_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");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
} // end namespace video
|
||||
} // end namespace irr
|
||||
|
||||
|
||||
#endif // _IRR_COMPILE_WITH_OGLES1_
|
@ -1,472 +0,0 @@
|
||||
// Copyright (C) 2008 Christian Stehno
|
||||
// Heavily based on the OpenGL driver implemented by Nikolaus Gebhardt
|
||||
// This file is part of the "Irrlicht Engine".
|
||||
// For conditions of distribution and use, see copyright notice in Irrlicht.h
|
||||
|
||||
#ifndef __C_OGLES_EXTENSION_HANDLER_H_INCLUDED__
|
||||
#define __C_OGLES_EXTENSION_HANDLER_H_INCLUDED__
|
||||
|
||||
#include "IrrCompileConfig.h"
|
||||
|
||||
#ifdef _IRR_COMPILE_WITH_OGLES1_
|
||||
#if defined(_IRR_COMPILE_WITH_IPHONE_DEVICE_)
|
||||
#include <OpenGLES/ES1/gl.h>
|
||||
#include <OpenGLES/ES1/glext.h>
|
||||
#elif defined(_IRR_ANDROID_PLATFORM_)
|
||||
#include <GLES/gl.h>
|
||||
#include <GLES/glext.h>
|
||||
#include <EGL/egl.h>
|
||||
#else
|
||||
#include <GLES/egl.h>
|
||||
#include <GLES/gl.h>
|
||||
// seems to be missing...
|
||||
typedef char GLchar;
|
||||
#if defined(_IRR_OGLES1_USE_EXTPOINTER_)
|
||||
#include "gles-ext.h"
|
||||
#endif
|
||||
#endif
|
||||
#include "os.h"
|
||||
#include "EDriverFeatures.h"
|
||||
|
||||
namespace irr
|
||||
{
|
||||
namespace video
|
||||
{
|
||||
class COGLES1Driver;
|
||||
class COGLES1ExtensionHandler
|
||||
{
|
||||
public:
|
||||
enum EOGLESFeatures
|
||||
{
|
||||
IRR_AMD_compressed_3DC_texture = 0, //39
|
||||
IRR_AMD_compressed_ATC_texture, //40
|
||||
IRR_AMD_performance_monitor, //50
|
||||
IRR_AMD_program_binary_Z400, //48
|
||||
IRR_ANGLE_framebuffer_blit, // 84
|
||||
IRR_ANGLE_framebuffer_multisample, // 85
|
||||
IRR_APPLE_copy_texture_levels, // 123
|
||||
IRR_APPLE_framebuffer_multisample, // 79
|
||||
IRR_APPLE_rgb_422, // 77
|
||||
IRR_APPLE_sync, // 124
|
||||
IRR_APPLE_texture_2D_limited_npot, // 59
|
||||
IRR_APPLE_texture_format_BGRA8888, // 80
|
||||
IRR_APPLE_texture_max_level, // 81
|
||||
IRR_ARB_texture_env_combine, //ogl, IMG simulator
|
||||
IRR_ARB_texture_env_dot3, //ogl, IMG simulator
|
||||
IRR_ARM_mali_shader_binary, // 82
|
||||
IRR_ARM_rgba8, // 83
|
||||
IRR_DMP_shader_binary, // 89
|
||||
IRR_EXT_blend_minmax, // 65
|
||||
IRR_EXT_discard_framebuffer, // 64
|
||||
IRR_EXT_frag_depth, // 87
|
||||
IRR_EXT_map_buffer_range, // 121
|
||||
IRR_EXT_multisampled_render_to_texture, // 106
|
||||
IRR_EXT_multi_draw_arrays, // 69
|
||||
IRR_EXT_robustness, // 107
|
||||
IRR_EXT_read_format_bgra, // 66
|
||||
IRR_EXT_shader_texture_lod, // 78
|
||||
IRR_EXT_sRGB, // 105
|
||||
IRR_EXT_texture_compression_dxt1, //49
|
||||
IRR_EXT_texture_filter_anisotropic, //41
|
||||
IRR_EXT_texture_format_BGRA8888, //51
|
||||
IRR_EXT_texture_lod_bias, // 60
|
||||
IRR_EXT_texture_storage, // 108
|
||||
IRR_EXT_texture_type_2_10_10_10_REV, //42
|
||||
IRR_IMG_multisampled_render_to_texture, // 75
|
||||
IRR_IMG_program_binary, // 67
|
||||
IRR_IMG_read_format, //53
|
||||
IRR_IMG_shader_binary, // 68
|
||||
IRR_IMG_texture_compression_pvrtc, //54
|
||||
IRR_IMG_texture_env_enhanced_fixed_function, // 58
|
||||
IRR_IMG_texture_format_BGRA8888, // replaced by EXT version
|
||||
IRR_IMG_user_clip_plane, // 57, was clip_planes
|
||||
IRR_IMG_vertex_program, // non-standard
|
||||
IRR_NV_coverage_sample, // 73
|
||||
IRR_NV_depth_nonlinear, // 74
|
||||
IRR_NV_fence, //52
|
||||
IRR_OES_blend_equation_separate, //1
|
||||
IRR_OES_blend_func_separate, //2
|
||||
IRR_OES_blend_subtract, //3
|
||||
IRR_OES_byte_coordinates, //4
|
||||
IRR_OES_compressed_ETC1_RGB8_texture, //5
|
||||
IRR_OES_compressed_paletted_texture, //6
|
||||
IRR_OES_depth24, //24
|
||||
IRR_OES_depth32, //25
|
||||
IRR_OES_depth_texture, //43
|
||||
IRR_OES_draw_texture, //7
|
||||
IRR_OES_EGL_image, //23
|
||||
IRR_OES_EGL_image_external, // 88
|
||||
IRR_OES_EGL_sync, // 76
|
||||
IRR_OES_element_index_uint, //26
|
||||
IRR_OES_extended_matrix_palette, //8
|
||||
IRR_OES_fbo_render_mipmap, //27
|
||||
IRR_OES_fixed_point, //9
|
||||
IRR_OES_fragment_precision_high, //28
|
||||
IRR_OES_framebuffer_object, //10
|
||||
IRR_OES_get_program_binary, //47
|
||||
IRR_OES_mapbuffer, //29
|
||||
IRR_OES_matrix_get, //11
|
||||
IRR_OES_matrix_palette, //12
|
||||
IRR_OES_packed_depth_stencil, //44
|
||||
IRR_OES_point_size_array, //14
|
||||
IRR_OES_point_sprite, //15
|
||||
IRR_OES_query_matrix, //16
|
||||
IRR_OES_read_format, //17
|
||||
IRR_OES_required_internalformat, // 115
|
||||
IRR_OES_rgb8_rgba8, //30
|
||||
IRR_OES_single_precision, //18
|
||||
IRR_OES_standard_derivatives, //45
|
||||
IRR_OES_stencil1, //31
|
||||
IRR_OES_stencil4, //32
|
||||
IRR_OES_stencil8, //33
|
||||
IRR_OES_stencil_wrap, //19
|
||||
IRR_OES_texture_3D, //34
|
||||
IRR_OES_texture_cube_map, //20
|
||||
IRR_OES_texture_env_crossbar, //21
|
||||
IRR_OES_texture_float, //36
|
||||
IRR_OES_texture_float_linear, //35
|
||||
IRR_OES_texture_half_float, //36
|
||||
IRR_OES_texture_half_float_linear, //35
|
||||
IRR_OES_texture_mirrored_repeat, //22
|
||||
IRR_OES_texture_npot, //37
|
||||
IRR_OES_vertex_array_object, // 72
|
||||
IRR_OES_vertex_half_float, //38
|
||||
IRR_OES_vertex_type_10_10_10_2, //46
|
||||
IRR_QCOM_driver_control, //55
|
||||
IRR_QCOM_extended_get, // 62
|
||||
IRR_QCOM_extended_get2, // 63
|
||||
IRR_QCOM_performance_monitor_global_mode, //56
|
||||
IRR_QCOM_tiled_rendering, // 71
|
||||
IRR_QCOM_writeonly_rendering, // 61
|
||||
IRR_SUN_multi_draw_arrays, // 70
|
||||
IRR_VIV_shader_binary, // 86
|
||||
|
||||
IRR_OGLES_Feature_Count
|
||||
};
|
||||
|
||||
//! queries the features of the driver, returns true if feature is available
|
||||
bool queryOpenGLFeature(EOGLESFeatures feature) const
|
||||
{
|
||||
return FeatureAvailable[feature];
|
||||
}
|
||||
|
||||
u16 EGLVersion;
|
||||
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();
|
||||
|
||||
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_TEXTURE_NSQUARE:
|
||||
return true; // non-square is always supported
|
||||
case EVDF_TEXTURE_NPOT:
|
||||
return FeatureAvailable[IRR_APPLE_texture_2D_limited_npot];
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
void dump() const;
|
||||
|
||||
void initExtensions(COGLES1Driver* driver,
|
||||
#ifdef EGL_VERSION_1_0
|
||||
EGLDisplay display,
|
||||
#endif
|
||||
bool withStencil);
|
||||
|
||||
public:
|
||||
void extGlBindFramebuffer(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)
|
||||
{
|
||||
#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)
|
||||
{
|
||||
#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)
|
||||
{
|
||||
#ifdef _IRR_OGLES1_USE_EXTPOINTER_
|
||||
if (pGlCheckFramebufferStatusOES)
|
||||
return pGlCheckFramebufferStatusOES(target);
|
||||
else
|
||||
return 0;
|
||||
#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)
|
||||
{
|
||||
#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)
|
||||
{
|
||||
#ifdef _IRR_OGLES1_USE_EXTPOINTER_
|
||||
if (pGlBindRenderbufferOES)
|
||||
pGlBindRenderbufferOES(target, renderbuffer);
|
||||
#elif defined(GL_OES_framebuffer_object)
|
||||
glBindRenderbufferOES(target, renderbuffer);
|
||||
#else
|
||||
os::Printer::log("glBindRenderbuffer not supported", ELL_ERROR);
|
||||
#endif
|
||||
}
|
||||
|
||||
void extGlDeleteRenderbuffers(GLsizei n, const GLuint *renderbuffers)
|
||||
{
|
||||
#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);
|
||||
#endif
|
||||
}
|
||||
|
||||
void extGlGenRenderbuffers(GLsizei n, GLuint *renderbuffers)
|
||||
{
|
||||
#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);
|
||||
#endif
|
||||
}
|
||||
|
||||
void extGlRenderbufferStorage(GLenum target, GLenum internalformat, GLsizei width, GLsizei height)
|
||||
{
|
||||
#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)
|
||||
{
|
||||
#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)
|
||||
{
|
||||
#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 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;
|
||||
PFNGLBINDRENDERBUFFEROES pGlBindRenderbufferOES;
|
||||
PFNGLDELETERENDERBUFFERSOES pGlDeleteRenderbuffersOES;
|
||||
PFNGLGENRENDERBUFFERSOES pGlGenRenderbuffersOES;
|
||||
PFNGLRENDERBUFFERSTORAGEOES pGlRenderbufferStorageOES;
|
||||
PFNGLBINDFRAMEBUFFEROES pGlBindFramebufferOES;
|
||||
PFNGLDELETEFRAMEBUFFERSOES pGlDeleteFramebuffersOES;
|
||||
PFNGLGENFRAMEBUFFERSOES pGlGenFramebuffersOES;
|
||||
PFNGLCHECKFRAMEBUFFERSTATUSOES pGlCheckFramebufferStatusOES;
|
||||
PFNGLFRAMEBUFFERRENDERBUFFEROES pGlFramebufferRenderbufferOES;
|
||||
PFNGLFRAMEBUFFERTEXTURE2DOES pGlFramebufferTexture2DOES;
|
||||
PFNGLGENERATEMIPMAPOES pGlGenerateMipMapOES;
|
||||
#endif
|
||||
};
|
||||
|
||||
} // end namespace video
|
||||
} // end namespace irr
|
||||
|
||||
|
||||
#endif // _IRR_COMPILE_WITH_OGLES1_
|
||||
#endif
|
||||
|
@ -1,637 +0,0 @@
|
||||
// Copyright (C) 2002-2008 Nikolaus Gebhardt
|
||||
// This file is part of the "Irrlicht Engine".
|
||||
// For conditions of distribution and use, see copyright notice in irrlicht.h
|
||||
|
||||
#ifndef __C_OGLES1_MATERIAL_RENDERER_H_INCLUDED__
|
||||
#define __C_OGLES1_MATERIAL_RENDERER_H_INCLUDED__
|
||||
|
||||
#include "IrrCompileConfig.h"
|
||||
#ifdef _IRR_COMPILE_WITH_OGLES1_
|
||||
|
||||
#include "COGLESDriver.h"
|
||||
#include "IMaterialRenderer.h"
|
||||
|
||||
namespace irr
|
||||
{
|
||||
namespace video
|
||||
{
|
||||
|
||||
//! Base class for all internal OGLES1 material renderers
|
||||
class COGLES1MaterialRenderer : public IMaterialRenderer
|
||||
{
|
||||
public:
|
||||
|
||||
//! Constructor
|
||||
COGLES1MaterialRenderer(video::COGLES1Driver* driver) : Driver(driver)
|
||||
{
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
video::COGLES1Driver* Driver;
|
||||
};
|
||||
|
||||
|
||||
//! Solid material renderer
|
||||
class COGLES1MaterialRenderer_SOLID : public COGLES1MaterialRenderer
|
||||
{
|
||||
public:
|
||||
|
||||
COGLES1MaterialRenderer_SOLID(video::COGLES1Driver* d)
|
||||
: COGLES1MaterialRenderer(d) {}
|
||||
|
||||
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))
|
||||
{
|
||||
// thanks to Murphy, the following line removed some
|
||||
// bugs with several OGLES1 implementations.
|
||||
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
//! Generic Texture Blend
|
||||
class COGLES1MaterialRenderer_ONETEXTURE_BLEND : public COGLES1MaterialRenderer
|
||||
{
|
||||
public:
|
||||
|
||||
COGLES1MaterialRenderer_ONETEXTURE_BLEND(video::COGLES1Driver* d)
|
||||
: COGLES1MaterialRenderer(d) {}
|
||||
|
||||
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 ||
|
||||
// material.MaterialTypeParam != lastMaterial.MaterialTypeParam ||
|
||||
// resetAllRenderstates)
|
||||
{
|
||||
E_BLEND_FACTOR srcFact,dstFact;
|
||||
E_MODULATE_FUNC modulate;
|
||||
u32 alphaSource;
|
||||
unpack_textureBlendFunc ( srcFact, dstFact, modulate, alphaSource, material.MaterialTypeParam );
|
||||
|
||||
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE);
|
||||
glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_MODULATE);
|
||||
glTexEnvf(GL_TEXTURE_ENV, GL_SRC0_RGB, GL_TEXTURE);
|
||||
glTexEnvf(GL_TEXTURE_ENV, GL_SRC1_RGB, GL_PREVIOUS);
|
||||
|
||||
glTexEnvf(GL_TEXTURE_ENV, GL_RGB_SCALE, (f32) modulate );
|
||||
|
||||
glBlendFunc( getGLBlend(srcFact), getGLBlend(dstFact) );
|
||||
glEnable(GL_ALPHA_TEST);
|
||||
glAlphaFunc(GL_GREATER, 0.f);
|
||||
glEnable(GL_BLEND);
|
||||
|
||||
if ( textureBlendFunc_hasAlpha(srcFact) || textureBlendFunc_hasAlpha(dstFact) )
|
||||
{
|
||||
glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_ALPHA, GL_REPLACE);
|
||||
glTexEnvf(GL_TEXTURE_ENV, GL_SRC0_ALPHA, GL_TEXTURE);
|
||||
|
||||
glTexEnvf(GL_TEXTURE_ENV, GL_SRC1_RGB, GL_PRIMARY_COLOR);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
virtual void OnUnsetMaterial()
|
||||
{
|
||||
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
|
||||
glTexEnvf(GL_TEXTURE_ENV, GL_RGB_SCALE, 1.f );
|
||||
glTexEnvf(GL_TEXTURE_ENV, GL_SRC1_RGB, GL_PREVIOUS);
|
||||
|
||||
glDisable(GL_BLEND);
|
||||
glDisable(GL_ALPHA_TEST);
|
||||
}
|
||||
|
||||
//! Returns if the material is transparent.
|
||||
/** Is not always transparent, but mostly. */
|
||||
virtual bool isTransparent() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
u32 getGLBlend ( E_BLEND_FACTOR factor ) const
|
||||
{
|
||||
u32 r = 0;
|
||||
switch ( factor )
|
||||
{
|
||||
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;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
//! Solid 2 layer material renderer
|
||||
class COGLES1MaterialRenderer_SOLID_2_LAYER : public COGLES1MaterialRenderer
|
||||
{
|
||||
public:
|
||||
|
||||
COGLES1MaterialRenderer_SOLID_2_LAYER(video::COGLES1Driver* d)
|
||||
: COGLES1MaterialRenderer(d) {}
|
||||
|
||||
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);
|
||||
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);
|
||||
glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_INTERPOLATE);
|
||||
glTexEnvf(GL_TEXTURE_ENV, GL_SRC0_RGB, GL_PREVIOUS);
|
||||
glTexEnvf(GL_TEXTURE_ENV, GL_SRC1_RGB, GL_TEXTURE);
|
||||
glTexEnvf(GL_TEXTURE_ENV, GL_SRC2_RGB, GL_PRIMARY_COLOR);
|
||||
glTexEnvf(GL_TEXTURE_ENV, GL_OPERAND2_RGB, GL_SRC_ALPHA);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
virtual void OnUnsetMaterial()
|
||||
{
|
||||
if (Driver->queryFeature(EVDF_MULTITEXTURE))
|
||||
{
|
||||
Driver->extGlActiveTexture(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);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
//! Transparent add color material renderer
|
||||
class COGLES1MaterialRenderer_TRANSPARENT_ADD_COLOR : public COGLES1MaterialRenderer
|
||||
{
|
||||
public:
|
||||
|
||||
COGLES1MaterialRenderer_TRANSPARENT_ADD_COLOR(video::COGLES1Driver* d)
|
||||
: COGLES1MaterialRenderer(d) {}
|
||||
|
||||
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)
|
||||
{
|
||||
glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_COLOR);
|
||||
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
|
||||
glEnable(GL_BLEND);
|
||||
}
|
||||
}
|
||||
|
||||
virtual void OnUnsetMaterial()
|
||||
{
|
||||
glDisable(GL_BLEND);
|
||||
}
|
||||
|
||||
//! Returns if the material is transparent.
|
||||
virtual bool isTransparent() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
//! Transparent vertex alpha material renderer
|
||||
class COGLES1MaterialRenderer_TRANSPARENT_VERTEX_ALPHA : public COGLES1MaterialRenderer
|
||||
{
|
||||
public:
|
||||
|
||||
COGLES1MaterialRenderer_TRANSPARENT_VERTEX_ALPHA(video::COGLES1Driver* d)
|
||||
: COGLES1MaterialRenderer(d) {}
|
||||
|
||||
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)
|
||||
{
|
||||
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 );
|
||||
|
||||
glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_MODULATE);
|
||||
glTexEnvf(GL_TEXTURE_ENV, GL_SRC0_RGB, GL_PRIMARY_COLOR );
|
||||
glTexEnvf(GL_TEXTURE_ENV, GL_SRC1_RGB, GL_TEXTURE);
|
||||
|
||||
glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
|
||||
glEnable(GL_BLEND);
|
||||
}
|
||||
}
|
||||
|
||||
virtual void OnUnsetMaterial()
|
||||
{
|
||||
// default values
|
||||
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
|
||||
glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_ALPHA, GL_MODULATE );
|
||||
glTexEnvf(GL_TEXTURE_ENV, GL_SRC0_ALPHA, GL_TEXTURE );
|
||||
glTexEnvf(GL_TEXTURE_ENV, GL_SRC1_ALPHA, GL_PREVIOUS );
|
||||
glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_MODULATE);
|
||||
glTexEnvf(GL_TEXTURE_ENV, GL_SRC0_RGB, GL_TEXTURE );
|
||||
glTexEnvf(GL_TEXTURE_ENV, GL_SRC1_RGB, GL_PREVIOUS);
|
||||
|
||||
glDisable(GL_BLEND);
|
||||
}
|
||||
|
||||
//! Returns if the material is transparent.
|
||||
virtual bool isTransparent() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
//! Transparent alpha channel material renderer
|
||||
class COGLES1MaterialRenderer_TRANSPARENT_ALPHA_CHANNEL : public COGLES1MaterialRenderer
|
||||
{
|
||||
public:
|
||||
|
||||
COGLES1MaterialRenderer_TRANSPARENT_ALPHA_CHANNEL(video::COGLES1Driver* d)
|
||||
: COGLES1MaterialRenderer(d) {}
|
||||
|
||||
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
|
||||
|| material.MaterialTypeParam != lastMaterial.MaterialTypeParam )
|
||||
{
|
||||
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE);
|
||||
glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_MODULATE);
|
||||
glTexEnvf(GL_TEXTURE_ENV, GL_SRC0_RGB, GL_TEXTURE);
|
||||
glTexEnvf(GL_TEXTURE_ENV, GL_SRC1_RGB, GL_PREVIOUS);
|
||||
|
||||
glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_ALPHA, GL_REPLACE);
|
||||
glTexEnvf(GL_TEXTURE_ENV, GL_SRC0_ALPHA, GL_TEXTURE);
|
||||
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
glEnable(GL_BLEND);
|
||||
glEnable(GL_ALPHA_TEST);
|
||||
|
||||
glAlphaFunc(GL_GREATER, material.MaterialTypeParam);
|
||||
}
|
||||
}
|
||||
|
||||
virtual void OnUnsetMaterial()
|
||||
{
|
||||
glDisable(GL_ALPHA_TEST);
|
||||
glDisable(GL_BLEND);
|
||||
}
|
||||
|
||||
//! Returns if the material is transparent.
|
||||
virtual bool isTransparent() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
//! Transparent alpha channel material renderer
|
||||
class COGLES1MaterialRenderer_TRANSPARENT_ALPHA_CHANNEL_REF : public COGLES1MaterialRenderer
|
||||
{
|
||||
public:
|
||||
|
||||
COGLES1MaterialRenderer_TRANSPARENT_ALPHA_CHANNEL_REF(video::COGLES1Driver* d)
|
||||
: COGLES1MaterialRenderer(d) {}
|
||||
|
||||
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)
|
||||
{
|
||||
glEnable(GL_ALPHA_TEST);
|
||||
glAlphaFunc(GL_GREATER, 0.5f);
|
||||
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
|
||||
}
|
||||
}
|
||||
|
||||
virtual void OnUnsetMaterial()
|
||||
{
|
||||
glDisable(GL_ALPHA_TEST);
|
||||
}
|
||||
|
||||
//! Returns if the material is transparent.
|
||||
virtual bool isTransparent() const
|
||||
{
|
||||
return false; // this material is not really transparent because it does no blending.
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
//! material renderer for all kinds of lightmaps
|
||||
class COGLES1MaterialRenderer_LIGHTMAP : public COGLES1MaterialRenderer
|
||||
{
|
||||
public:
|
||||
|
||||
COGLES1MaterialRenderer_LIGHTMAP(video::COGLES1Driver* d)
|
||||
: COGLES1MaterialRenderer(d) {}
|
||||
|
||||
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)
|
||||
{
|
||||
// diffuse map
|
||||
|
||||
switch (material.MaterialType)
|
||||
{
|
||||
case EMT_LIGHTMAP_LIGHTING:
|
||||
case EMT_LIGHTMAP_LIGHTING_M2:
|
||||
case EMT_LIGHTMAP_LIGHTING_M4:
|
||||
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
|
||||
break;
|
||||
case EMT_LIGHTMAP_ADD:
|
||||
case EMT_LIGHTMAP:
|
||||
case EMT_LIGHTMAP_M2:
|
||||
case EMT_LIGHTMAP_M4:
|
||||
default:
|
||||
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
|
||||
break;
|
||||
}
|
||||
|
||||
if (Driver->queryFeature(EVDF_MULTITEXTURE))
|
||||
{
|
||||
// lightmap
|
||||
|
||||
Driver->extGlActiveTexture(GL_TEXTURE1);
|
||||
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE);
|
||||
|
||||
if (material.MaterialType == EMT_LIGHTMAP_ADD)
|
||||
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_ADD_SIGNED);
|
||||
else
|
||||
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_MODULATE);
|
||||
|
||||
glTexEnvi(GL_TEXTURE_ENV, GL_SRC0_RGB, GL_PREVIOUS);
|
||||
glTexEnvi(GL_TEXTURE_ENV, GL_SRC1_RGB, GL_TEXTURE);
|
||||
|
||||
glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_ALPHA, GL_MODULATE);
|
||||
glTexEnvi(GL_TEXTURE_ENV, GL_SRC0_ALPHA, GL_PREVIOUS);
|
||||
glTexEnvi(GL_TEXTURE_ENV, GL_SRC1_ALPHA, GL_PREVIOUS);
|
||||
|
||||
switch (material.MaterialType)
|
||||
{
|
||||
case EMT_LIGHTMAP_M4:
|
||||
case EMT_LIGHTMAP_LIGHTING_M4:
|
||||
glTexEnvf(GL_TEXTURE_ENV, GL_RGB_SCALE, 4.0f);
|
||||
break;
|
||||
case EMT_LIGHTMAP_M2:
|
||||
case EMT_LIGHTMAP_LIGHTING_M2:
|
||||
glTexEnvf(GL_TEXTURE_ENV, GL_RGB_SCALE, 2.0f);
|
||||
break;
|
||||
default:
|
||||
glTexEnvf(GL_TEXTURE_ENV, GL_RGB_SCALE, 1.0f);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
virtual void OnUnsetMaterial()
|
||||
{
|
||||
if (Driver->queryFeature(EVDF_MULTITEXTURE))
|
||||
{
|
||||
Driver->extGlActiveTexture(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);
|
||||
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) {}
|
||||
|
||||
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)
|
||||
{
|
||||
// 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
//! sphere map material renderer
|
||||
class COGLES1MaterialRenderer_SPHERE_MAP : public COGLES1MaterialRenderer
|
||||
{
|
||||
public:
|
||||
|
||||
COGLES1MaterialRenderer_SPHERE_MAP(video::COGLES1Driver* d)
|
||||
: COGLES1MaterialRenderer(d) {}
|
||||
|
||||
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)
|
||||
{
|
||||
// glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP);
|
||||
// glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP);
|
||||
|
||||
// glEnable(GL_TEXTURE_GEN_S);
|
||||
// glEnable(GL_TEXTURE_GEN_T);
|
||||
}
|
||||
}
|
||||
|
||||
virtual void OnUnsetMaterial()
|
||||
{
|
||||
// glDisable(GL_TEXTURE_GEN_S);
|
||||
// glDisable(GL_TEXTURE_GEN_T);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
//! reflection 2 layer material renderer
|
||||
class COGLES1MaterialRenderer_REFLECTION_2_LAYER : public COGLES1MaterialRenderer
|
||||
{
|
||||
public:
|
||||
|
||||
COGLES1MaterialRenderer_REFLECTION_2_LAYER(video::COGLES1Driver* d)
|
||||
: COGLES1MaterialRenderer(d) {}
|
||||
|
||||
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);
|
||||
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);
|
||||
glTexEnvi(GL_TEXTURE_ENV, GL_SRC1_RGB, GL_TEXTURE);
|
||||
|
||||
}
|
||||
// glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP);
|
||||
// glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP);
|
||||
// glEnable(GL_TEXTURE_GEN_S);
|
||||
// glEnable(GL_TEXTURE_GEN_T);
|
||||
}
|
||||
}
|
||||
|
||||
virtual void OnUnsetMaterial()
|
||||
{
|
||||
if (Driver->queryFeature(EVDF_MULTITEXTURE))
|
||||
{
|
||||
Driver->extGlActiveTexture(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);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
//! reflection 2 layer material renderer
|
||||
class COGLES1MaterialRenderer_TRANSPARENT_REFLECTION_2_LAYER : public COGLES1MaterialRenderer
|
||||
{
|
||||
public:
|
||||
|
||||
COGLES1MaterialRenderer_TRANSPARENT_REFLECTION_2_LAYER(video::COGLES1Driver* d)
|
||||
: COGLES1MaterialRenderer(d) {}
|
||||
|
||||
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);
|
||||
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);
|
||||
glTexEnvi(GL_TEXTURE_ENV, GL_SRC1_RGB, GL_TEXTURE);
|
||||
}
|
||||
// glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP);
|
||||
// glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP);
|
||||
// glEnable(GL_TEXTURE_GEN_S);
|
||||
// glEnable(GL_TEXTURE_GEN_T);
|
||||
|
||||
glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_COLOR);
|
||||
glEnable(GL_BLEND);
|
||||
}
|
||||
}
|
||||
|
||||
virtual void OnUnsetMaterial()
|
||||
{
|
||||
if (Driver->queryFeature(EVDF_MULTITEXTURE))
|
||||
{
|
||||
Driver->extGlActiveTexture(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);
|
||||
}
|
||||
glDisable(GL_BLEND);
|
||||
}
|
||||
|
||||
//! Returns if the material is transparent.
|
||||
virtual bool isTransparent() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
} // end namespace video
|
||||
} // end namespace irr
|
||||
|
||||
#endif
|
||||
#endif
|
@ -1,804 +0,0 @@
|
||||
// Copyright (C) 2002-2008 Nikolaus Gebhardt
|
||||
// This file is part of the "Irrlicht Engine".
|
||||
// For conditions of distribution and use, see copyright notice in irrlicht.h
|
||||
|
||||
#include "IrrCompileConfig.h"
|
||||
|
||||
#ifdef _IRR_COMPILE_WITH_OGLES1_
|
||||
|
||||
#include "irrTypes.h"
|
||||
#include "COGLESTexture.h"
|
||||
#include "COGLESDriver.h"
|
||||
#include "os.h"
|
||||
#include "CImage.h"
|
||||
#include "CColorConverter.h"
|
||||
|
||||
#include "irrString.h"
|
||||
|
||||
namespace
|
||||
{
|
||||
#ifndef GL_BGRA
|
||||
// we need to do this for the IMG_BGRA8888 extension
|
||||
int GL_BGRA=GL_RGBA;
|
||||
#endif
|
||||
}
|
||||
|
||||
namespace irr
|
||||
{
|
||||
namespace video
|
||||
{
|
||||
|
||||
//! constructor for usual textures
|
||||
COGLES1Texture::COGLES1Texture(IImage* origImage, const io::path& name, COGLES1Driver* driver, void* mipmapData)
|
||||
: ITexture(name), Driver(driver), Image(0), MipImage(0),
|
||||
TextureName(0), InternalFormat(GL_RGBA), PixelFormat(GL_RGBA),
|
||||
// TODO ogl-es
|
||||
// PixelFormat(GL_BGRA),
|
||||
PixelType(GL_UNSIGNED_BYTE), MipLevelStored(0),
|
||||
HasMipMaps(true), IsRenderTarget(false), AutomaticMipmapUpdate(false),
|
||||
UseStencil(false), ReadOnlyLock(false), KeepImage(true)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
setDebugName("COGLES1Texture");
|
||||
#endif
|
||||
|
||||
HasMipMaps = Driver->getTextureCreationFlag(ETCF_CREATE_MIP_MAPS);
|
||||
getImageValues(origImage);
|
||||
|
||||
glGenTextures(1, &TextureName);
|
||||
|
||||
Image = new CImage(ColorFormat, TextureSize);
|
||||
if (ImageSize==TextureSize)
|
||||
origImage->copyTo(Image);
|
||||
else
|
||||
// scale texture
|
||||
origImage->copyToScaling(Image);
|
||||
uploadTexture(true, mipmapData);
|
||||
if (!KeepImage)
|
||||
{
|
||||
Image->drop();
|
||||
Image=0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
//! constructor for basic setup (only for derived classes)
|
||||
COGLES1Texture::COGLES1Texture(const io::path& name, COGLES1Driver* driver)
|
||||
: ITexture(name), Driver(driver), Image(0), MipImage(0),
|
||||
TextureName(0), InternalFormat(GL_RGBA), PixelFormat(GL_RGBA),
|
||||
PixelType(GL_UNSIGNED_BYTE), MipLevelStored(0),
|
||||
HasMipMaps(true), IsRenderTarget(false), AutomaticMipmapUpdate(false),
|
||||
ReadOnlyLock(false), KeepImage(true)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
setDebugName("COGLES1Texture");
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
//! destructor
|
||||
COGLES1Texture::~COGLES1Texture()
|
||||
{
|
||||
glDeleteTextures(1, &TextureName);
|
||||
if (Image)
|
||||
Image->drop();
|
||||
}
|
||||
|
||||
|
||||
ECOLOR_FORMAT COGLES1Texture::getBestColorFormat(ECOLOR_FORMAT format)
|
||||
{
|
||||
ECOLOR_FORMAT destFormat = ECF_A8R8G8B8;
|
||||
switch (format)
|
||||
{
|
||||
case ECF_A1R5G5B5:
|
||||
if (!Driver->getTextureCreationFlag(ETCF_ALWAYS_32_BIT))
|
||||
destFormat = ECF_A1R5G5B5;
|
||||
break;
|
||||
case ECF_R5G6B5:
|
||||
if (!Driver->getTextureCreationFlag(ETCF_ALWAYS_32_BIT))
|
||||
destFormat = ECF_A1R5G5B5;
|
||||
break;
|
||||
case ECF_A8R8G8B8:
|
||||
if (Driver->getTextureCreationFlag(ETCF_ALWAYS_16_BIT) ||
|
||||
Driver->getTextureCreationFlag(ETCF_OPTIMIZED_FOR_SPEED))
|
||||
destFormat = ECF_A1R5G5B5;
|
||||
break;
|
||||
case ECF_R8G8B8:
|
||||
if (Driver->getTextureCreationFlag(ETCF_ALWAYS_16_BIT) ||
|
||||
Driver->getTextureCreationFlag(ETCF_OPTIMIZED_FOR_SPEED))
|
||||
destFormat = ECF_A1R5G5B5;
|
||||
break;
|
||||
}
|
||||
if (Driver->getTextureCreationFlag(ETCF_NO_ALPHA_CHANNEL))
|
||||
{
|
||||
switch (destFormat)
|
||||
{
|
||||
case ECF_A1R5G5B5:
|
||||
destFormat = ECF_R5G6B5;
|
||||
break;
|
||||
case ECF_A8R8G8B8:
|
||||
destFormat = ECF_R8G8B8;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
return destFormat;
|
||||
}
|
||||
|
||||
|
||||
void COGLES1Texture::getImageValues(IImage* image)
|
||||
{
|
||||
if (!image)
|
||||
{
|
||||
os::Printer::log("No image for OGLES1 texture.", ELL_ERROR);
|
||||
return;
|
||||
}
|
||||
|
||||
ImageSize = image->getDimension();
|
||||
|
||||
if ( !ImageSize.Width || !ImageSize.Height)
|
||||
{
|
||||
os::Printer::log("Invalid size of image for OGLES1 Texture.", ELL_ERROR);
|
||||
return;
|
||||
}
|
||||
|
||||
const f32 ratio = (f32)ImageSize.Width/(f32)ImageSize.Height;
|
||||
if ((ImageSize.Width>Driver->MaxTextureSize) && (ratio >= 1.0f))
|
||||
{
|
||||
ImageSize.Width = Driver->MaxTextureSize;
|
||||
ImageSize.Height = (u32)(Driver->MaxTextureSize/ratio);
|
||||
}
|
||||
else if (ImageSize.Height>Driver->MaxTextureSize)
|
||||
{
|
||||
ImageSize.Height = Driver->MaxTextureSize;
|
||||
ImageSize.Width = (u32)(Driver->MaxTextureSize*ratio);
|
||||
}
|
||||
TextureSize=ImageSize.getOptimalSize(!Driver->queryFeature(EVDF_TEXTURE_NPOT));
|
||||
|
||||
ColorFormat = getBestColorFormat(image->getColorFormat());
|
||||
}
|
||||
|
||||
|
||||
//! copies the the texture into an open gl texture.
|
||||
void COGLES1Texture::uploadTexture(bool newTexture, void* mipmapData, u32 level)
|
||||
{
|
||||
IImage* image = level?MipImage:Image;
|
||||
if (!image)
|
||||
{
|
||||
os::Printer::log("No image for OGLES1 texture to upload", ELL_ERROR);
|
||||
return;
|
||||
}
|
||||
|
||||
#ifndef GL_BGRA
|
||||
// whoa, pretty badly implemented extension...
|
||||
if (Driver->FeatureAvailable[COGLES1ExtensionHandler::IRR_IMG_texture_format_BGRA8888] || Driver->FeatureAvailable[COGLES1ExtensionHandler::IRR_EXT_texture_format_BGRA8888])
|
||||
GL_BGRA=0x80E1;
|
||||
else
|
||||
GL_BGRA=GL_RGBA;
|
||||
#endif
|
||||
|
||||
GLenum oldInternalFormat = InternalFormat;
|
||||
void(*convert)(const void*, s32, void*)=0;
|
||||
switch (Image->getColorFormat())
|
||||
{
|
||||
case ECF_A1R5G5B5:
|
||||
InternalFormat=GL_RGBA;
|
||||
PixelFormat=GL_RGBA;
|
||||
PixelType=GL_UNSIGNED_SHORT_5_5_5_1;
|
||||
convert=CColorConverter::convert_A1R5G5B5toR5G5B5A1;
|
||||
break;
|
||||
case ECF_R5G6B5:
|
||||
InternalFormat=GL_RGB;
|
||||
PixelFormat=GL_RGB;
|
||||
PixelType=GL_UNSIGNED_SHORT_5_6_5;
|
||||
break;
|
||||
case ECF_R8G8B8:
|
||||
InternalFormat=GL_RGB;
|
||||
PixelFormat=GL_RGB;
|
||||
PixelType=GL_UNSIGNED_BYTE;
|
||||
convert=CColorConverter::convert_R8G8B8toB8G8R8;
|
||||
break;
|
||||
case ECF_A8R8G8B8:
|
||||
PixelType=GL_UNSIGNED_BYTE;
|
||||
if (!Driver->queryOpenGLFeature(COGLES1ExtensionHandler::IRR_IMG_texture_format_BGRA8888) && !Driver->queryOpenGLFeature(COGLES1ExtensionHandler::IRR_EXT_texture_format_BGRA8888))
|
||||
{
|
||||
convert=CColorConverter::convert_A8R8G8B8toA8B8G8R8;
|
||||
InternalFormat=GL_RGBA;
|
||||
PixelFormat=GL_RGBA;
|
||||
}
|
||||
else
|
||||
{
|
||||
InternalFormat=GL_BGRA;
|
||||
PixelFormat=GL_BGRA;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
os::Printer::log("Unsupported texture format", ELL_ERROR);
|
||||
break;
|
||||
}
|
||||
// Hack for iPhone SDK, which requires a different InternalFormat
|
||||
#ifdef _IRR_IPHONE_PLATFORM_
|
||||
if (InternalFormat==GL_BGRA)
|
||||
InternalFormat=GL_RGBA;
|
||||
#endif
|
||||
// make sure we don't change the internal format of existing matrices
|
||||
if (!newTexture)
|
||||
InternalFormat=oldInternalFormat;
|
||||
|
||||
Driver->setActiveTexture(0, this);
|
||||
if (Driver->testGLError())
|
||||
os::Printer::log("Could not bind Texture", ELL_ERROR);
|
||||
|
||||
if (!level && newTexture)
|
||||
{
|
||||
#ifndef DISABLE_MIPMAPPING
|
||||
if (HasMipMaps && !mipmapData && Driver->queryFeature(EVDF_MIP_MAP_AUTO_UPDATE))
|
||||
{
|
||||
// automatically generate and update mipmaps
|
||||
glTexParameteri( GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_TRUE );
|
||||
AutomaticMipmapUpdate=true;
|
||||
}
|
||||
else
|
||||
{
|
||||
AutomaticMipmapUpdate=false;
|
||||
regenerateMipMapLevels(mipmapData);
|
||||
}
|
||||
if (HasMipMaps) // might have changed in regenerateMipMapLevels
|
||||
{
|
||||
// enable bilinear mipmap filter
|
||||
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST );
|
||||
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
}
|
||||
else
|
||||
#else
|
||||
HasMipMaps=false;
|
||||
os::Printer::log("Did not create OGLES1 texture mip maps.", ELL_ERROR);
|
||||
#endif
|
||||
{
|
||||
// enable bilinear filter without mipmaps
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
}
|
||||
}
|
||||
|
||||
void* source = image->lock();
|
||||
IImage* tmpImage=0;
|
||||
if (convert)
|
||||
{
|
||||
tmpImage = new CImage(image->getColorFormat(), image->getDimension());
|
||||
void* dest = tmpImage->lock();
|
||||
convert(source, image->getDimension().getArea(), dest);
|
||||
image->unlock();
|
||||
source = dest;
|
||||
}
|
||||
if (newTexture)
|
||||
glTexImage2D(GL_TEXTURE_2D, level, InternalFormat, image->getDimension().Width,
|
||||
image->getDimension().Height, 0, PixelFormat, PixelType, source);
|
||||
else
|
||||
glTexSubImage2D(GL_TEXTURE_2D, level, 0, 0, image->getDimension().Width,
|
||||
image->getDimension().Height, PixelFormat, PixelType, source);
|
||||
if (convert)
|
||||
{
|
||||
tmpImage->unlock();
|
||||
tmpImage->drop();
|
||||
}
|
||||
else
|
||||
image->unlock();
|
||||
|
||||
if (Driver->testGLError())
|
||||
os::Printer::log("Could not glTexImage2D", ELL_ERROR);
|
||||
}
|
||||
|
||||
|
||||
//! lock function
|
||||
void* COGLES1Texture::lock(E_TEXTURE_LOCK_MODE mode, u32 mipmapLevel)
|
||||
{
|
||||
// store info about which image is locked
|
||||
IImage* image = (mipmapLevel==0)?Image:MipImage;
|
||||
|
||||
ReadOnlyLock |= (mode==ETLM_READ_ONLY);
|
||||
MipLevelStored = mipmapLevel;
|
||||
|
||||
if (!Image)
|
||||
Image = new CImage(ECF_A8R8G8B8, ImageSize);
|
||||
if (IsRenderTarget)
|
||||
{
|
||||
u8* pPixels = static_cast<u8*>(Image->lock());
|
||||
if (!pPixels)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
// we need to keep the correct texture bound...
|
||||
GLint tmpTexture;
|
||||
glGetIntegerv(GL_TEXTURE_BINDING_2D, &tmpTexture);
|
||||
glBindTexture(GL_TEXTURE_2D, TextureName);
|
||||
|
||||
// TODO ogl-es
|
||||
// glGetTexImage(GL_TEXTURE_2D, 0, GL_BGRA, GL_UNSIGNED_BYTE, pPixels);
|
||||
|
||||
// opengl images are horizontally flipped, so we have to fix that here.
|
||||
const u32 pitch=Image->getPitch();
|
||||
u8* p2 = pPixels + (ImageSize.Height - 1) * pitch;
|
||||
u8* tmpBuffer = new u8[pitch];
|
||||
for (u32 i=0; i < ImageSize.Height; i += 2)
|
||||
{
|
||||
memcpy(tmpBuffer, pPixels, pitch);
|
||||
memcpy(pPixels, p2, pitch);
|
||||
memcpy(p2, tmpBuffer, pitch);
|
||||
pPixels += pitch;
|
||||
p2 -= pitch;
|
||||
}
|
||||
delete [] tmpBuffer;
|
||||
Image->unlock();
|
||||
|
||||
//reset old bound texture
|
||||
glBindTexture(GL_TEXTURE_2D, tmpTexture);
|
||||
}
|
||||
return Image->lock();
|
||||
}
|
||||
|
||||
|
||||
//! unlock function
|
||||
void COGLES1Texture::unlock()
|
||||
{
|
||||
Image->unlock();
|
||||
if (!ReadOnlyLock)
|
||||
uploadTexture(false);
|
||||
ReadOnlyLock = false;
|
||||
}
|
||||
|
||||
|
||||
//! Returns size of the original image.
|
||||
const core::dimension2d<u32>& COGLES1Texture::getOriginalSize() const
|
||||
{
|
||||
return ImageSize;
|
||||
}
|
||||
|
||||
|
||||
//! Returns size of the texture.
|
||||
const core::dimension2d<u32>& COGLES1Texture::getSize() const
|
||||
{
|
||||
if (Image)
|
||||
return Image->getDimension();
|
||||
else
|
||||
return ImageSize;
|
||||
}
|
||||
|
||||
|
||||
//! returns driver type of texture, i.e. the driver, which created the texture
|
||||
E_DRIVER_TYPE COGLES1Texture::getDriverType() const
|
||||
{
|
||||
return EDT_OGLES1;
|
||||
}
|
||||
|
||||
|
||||
//! returns color format of texture
|
||||
ECOLOR_FORMAT COGLES1Texture::getColorFormat() const
|
||||
{
|
||||
if (Image)
|
||||
return Image->getColorFormat();
|
||||
else
|
||||
return ECF_A8R8G8B8;
|
||||
}
|
||||
|
||||
|
||||
//! returns pitch of texture (in bytes)
|
||||
u32 COGLES1Texture::getPitch() const
|
||||
{
|
||||
if (Image)
|
||||
return Image->getPitch();
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
//! return open gl texture name
|
||||
GLuint COGLES1Texture::getOGLES1TextureName() const
|
||||
{
|
||||
return TextureName;
|
||||
}
|
||||
|
||||
|
||||
//! Returns whether this texture has mipmaps
|
||||
bool COGLES1Texture::hasMipMaps() const
|
||||
{
|
||||
return HasMipMaps;
|
||||
}
|
||||
|
||||
|
||||
//! Regenerates the mip map levels of the texture.
|
||||
void COGLES1Texture::regenerateMipMapLevels(void* mipmapData)
|
||||
{
|
||||
if (AutomaticMipmapUpdate || !HasMipMaps || !Image)
|
||||
return;
|
||||
if ((Image->getDimension().Width==1) && (Image->getDimension().Height==1))
|
||||
return;
|
||||
|
||||
// Manually create mipmaps
|
||||
u32 width=Image->getDimension().Width;
|
||||
u32 height=Image->getDimension().Height;
|
||||
u32 i=0;
|
||||
if (mipmapData)
|
||||
{
|
||||
do
|
||||
{
|
||||
if (width>1)
|
||||
width>>=1;
|
||||
if (height>1)
|
||||
height>>=1;
|
||||
++i;
|
||||
glTexImage2D(GL_TEXTURE_2D, i, InternalFormat, width, height,
|
||||
0, PixelFormat, PixelType, mipmapData);
|
||||
mipmapData = ((u8*)mipmapData)+width*height*Image->getBytesPerPixel();
|
||||
}
|
||||
while (width!=1 || height!=1);
|
||||
}
|
||||
else
|
||||
{
|
||||
u8* target = new u8[Image->getImageDataSizeInBytes()];
|
||||
do
|
||||
{
|
||||
if (width>1)
|
||||
width>>=1;
|
||||
if (height>1)
|
||||
height>>=1;
|
||||
++i;
|
||||
Image->copyToScaling(target, width, height, Image->getColorFormat());
|
||||
glTexImage2D(GL_TEXTURE_2D, i, InternalFormat, width, height,
|
||||
0, PixelFormat, PixelType, target);
|
||||
}
|
||||
while (width!=1 || height!=1);
|
||||
delete [] target;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool COGLES1Texture::isRenderTarget() const
|
||||
{
|
||||
return IsRenderTarget;
|
||||
}
|
||||
|
||||
|
||||
bool COGLES1Texture::isFrameBufferObject() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
void COGLES1Texture::setIsRenderTarget(bool isTarget)
|
||||
{
|
||||
IsRenderTarget = isTarget;
|
||||
}
|
||||
|
||||
|
||||
//! Bind Render Target Texture
|
||||
void COGLES1Texture::bindRTT()
|
||||
{
|
||||
glViewport(0, 0, getSize().Width, getSize().Height);
|
||||
}
|
||||
|
||||
|
||||
//! Unbind Render Target Texture
|
||||
void COGLES1Texture::unbindRTT()
|
||||
{
|
||||
glBindTexture(GL_TEXTURE_2D, getOGLES1TextureName());
|
||||
|
||||
// Copy Our ViewPort To The Texture
|
||||
glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, getSize().Width, getSize().Height);
|
||||
}
|
||||
|
||||
/* FBO Textures */
|
||||
|
||||
#ifdef GL_OES_framebuffer_object
|
||||
// helper function for render to texture
|
||||
static bool checkFBOStatus(COGLES1Driver* Driver);
|
||||
#endif
|
||||
|
||||
|
||||
//! RTT ColorFrameBuffer constructor
|
||||
COGLES1FBOTexture::COGLES1FBOTexture(const core::dimension2d<u32>& size,
|
||||
const io::path& name,
|
||||
COGLES1Driver* driver, ECOLOR_FORMAT format)
|
||||
: COGLES1Texture(name, driver), DepthTexture(0), ColorFrameBuffer(0)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
setDebugName("COGLES1Texture_FBO");
|
||||
#endif
|
||||
|
||||
ECOLOR_FORMAT col = getBestColorFormat(format);
|
||||
switch (col)
|
||||
{
|
||||
case ECF_A8R8G8B8:
|
||||
#ifdef GL_OES_rgb8_rgba8
|
||||
if (driver->queryOpenGLFeature(video::COGLES1ExtensionHandler::IRR_OES_rgb8_rgba8))
|
||||
InternalFormat = GL_RGBA8_OES;
|
||||
else
|
||||
#endif
|
||||
InternalFormat = GL_RGB5_A1_OES;
|
||||
break;
|
||||
case ECF_R8G8B8:
|
||||
#ifdef GL_OES_rgb8_rgba8
|
||||
if (driver->queryOpenGLFeature(video::COGLES1ExtensionHandler::IRR_OES_rgb8_rgba8))
|
||||
InternalFormat = GL_RGB8_OES;
|
||||
else
|
||||
#endif
|
||||
InternalFormat = GL_RGB565_OES;
|
||||
break;
|
||||
case ECF_A1R5G5B5:
|
||||
InternalFormat = GL_RGB5_A1_OES;
|
||||
break;
|
||||
case ECF_R5G6B5:
|
||||
InternalFormat = GL_RGB565_OES;
|
||||
break;
|
||||
}
|
||||
PixelFormat = GL_RGBA;
|
||||
PixelType = GL_UNSIGNED_BYTE;
|
||||
ImageSize = size;
|
||||
HasMipMaps = false;
|
||||
IsRenderTarget = true;
|
||||
|
||||
#ifdef GL_OES_framebuffer_object
|
||||
// generate frame buffer
|
||||
Driver->extGlGenFramebuffers(1, &ColorFrameBuffer);
|
||||
Driver->extGlBindFramebuffer(GL_FRAMEBUFFER_OES, ColorFrameBuffer);
|
||||
|
||||
// generate color texture
|
||||
glGenTextures(1, &TextureName);
|
||||
glBindTexture(GL_TEXTURE_2D, TextureName);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, InternalFormat, ImageSize.Width,
|
||||
ImageSize.Height, 0, PixelFormat, PixelType, 0);
|
||||
|
||||
// attach color texture to frame buffer
|
||||
Driver->extGlFramebufferTexture2D(GL_FRAMEBUFFER_OES,
|
||||
GL_COLOR_ATTACHMENT0_OES,
|
||||
GL_TEXTURE_2D,
|
||||
TextureName,
|
||||
0);
|
||||
#endif
|
||||
unbindRTT();
|
||||
}
|
||||
|
||||
|
||||
//! destructor
|
||||
COGLES1FBOTexture::~COGLES1FBOTexture()
|
||||
{
|
||||
if (DepthTexture)
|
||||
if (DepthTexture->drop())
|
||||
Driver->removeDepthTexture(DepthTexture);
|
||||
if (ColorFrameBuffer)
|
||||
Driver->extGlDeleteFramebuffers(1, &ColorFrameBuffer);
|
||||
}
|
||||
|
||||
|
||||
bool COGLES1FBOTexture::isFrameBufferObject() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
//! Bind Render Target Texture
|
||||
void COGLES1FBOTexture::bindRTT()
|
||||
{
|
||||
#ifdef GL_OES_framebuffer_object
|
||||
if (ColorFrameBuffer != 0)
|
||||
Driver->extGlBindFramebuffer(GL_FRAMEBUFFER_OES, ColorFrameBuffer);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
//! Unbind Render Target Texture
|
||||
void COGLES1FBOTexture::unbindRTT()
|
||||
{
|
||||
#ifdef GL_OES_framebuffer_object
|
||||
if (ColorFrameBuffer != 0)
|
||||
Driver->extGlBindFramebuffer(GL_FRAMEBUFFER_OES, 0);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
/* FBO Depth Textures */
|
||||
|
||||
//! RTT DepthBuffer constructor
|
||||
COGLES1FBODepthTexture::COGLES1FBODepthTexture(
|
||||
const core::dimension2d<u32>& size,
|
||||
const io::path& name,
|
||||
COGLES1Driver* driver,
|
||||
bool useStencil)
|
||||
: COGLES1FBOTexture(size, name, driver), DepthRenderBuffer(0),
|
||||
StencilRenderBuffer(0), UseStencil(useStencil)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
setDebugName("COGLES1TextureFBO_Depth");
|
||||
#endif
|
||||
|
||||
ImageSize = size;
|
||||
#ifdef GL_OES_depth24
|
||||
InternalFormat = GL_DEPTH_COMPONENT24_OES;
|
||||
#elif defined(GL_OES_depth32)
|
||||
InternalFormat = GL_DEPTH_COMPONENT32_OES;
|
||||
#else
|
||||
InternalFormat = GL_DEPTH_COMPONENT16_OES;
|
||||
#endif
|
||||
|
||||
PixelFormat = GL_RGBA;
|
||||
PixelType = GL_UNSIGNED_BYTE;
|
||||
HasMipMaps = false;
|
||||
|
||||
if (useStencil)
|
||||
{
|
||||
#ifdef GL_OES_packed_depth_stencil
|
||||
glGenTextures(1, &DepthRenderBuffer);
|
||||
glBindTexture(GL_TEXTURE_2D, DepthRenderBuffer);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
if (Driver->queryOpenGLFeature(COGLES1ExtensionHandler::IRR_OES_packed_depth_stencil))
|
||||
{
|
||||
// generate packed depth stencil texture
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_STENCIL_OES, ImageSize.Width,
|
||||
ImageSize.Height, 0, GL_DEPTH_STENCIL_OES, GL_UNSIGNED_INT_24_8_OES, 0);
|
||||
StencilRenderBuffer = DepthRenderBuffer; // stencil is packed with depth
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
#if defined(GL_OES_framebuffer_object) && (defined(GL_OES_stencil1) || defined(GL_OES_stencil4) || defined(GL_OES_stencil8))
|
||||
// generate stencil buffer
|
||||
Driver->extGlGenRenderbuffers(1, &StencilRenderBuffer);
|
||||
Driver->extGlBindRenderbuffer(GL_RENDERBUFFER_OES, StencilRenderBuffer);
|
||||
Driver->extGlRenderbufferStorage(GL_RENDERBUFFER_OES,
|
||||
#if defined(GL_OES_stencil8)
|
||||
GL_STENCIL_INDEX8_OES,
|
||||
#elif defined(GL_OES_stencil4)
|
||||
GL_STENCIL_INDEX4_OES,
|
||||
#elif defined(GL_OES_stencil1)
|
||||
GL_STENCIL_INDEX1_OES,
|
||||
#endif
|
||||
ImageSize.Width, ImageSize.Height);
|
||||
#endif
|
||||
}
|
||||
#ifdef GL_OES_framebuffer_object
|
||||
// generate depth buffer
|
||||
Driver->extGlGenRenderbuffers(1, &DepthRenderBuffer);
|
||||
Driver->extGlBindRenderbuffer(GL_RENDERBUFFER_OES, DepthRenderBuffer);
|
||||
Driver->extGlRenderbufferStorage(GL_RENDERBUFFER_OES,
|
||||
InternalFormat, ImageSize.Width, ImageSize.Height);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
//! destructor
|
||||
COGLES1FBODepthTexture::~COGLES1FBODepthTexture()
|
||||
{
|
||||
if (DepthRenderBuffer && UseStencil)
|
||||
glDeleteTextures(1, &DepthRenderBuffer);
|
||||
else
|
||||
Driver->extGlDeleteRenderbuffers(1, &DepthRenderBuffer);
|
||||
if (StencilRenderBuffer && StencilRenderBuffer != DepthRenderBuffer)
|
||||
glDeleteTextures(1, &StencilRenderBuffer);
|
||||
}
|
||||
|
||||
|
||||
//combine depth texture and rtt
|
||||
void COGLES1FBODepthTexture::attach(ITexture* renderTex)
|
||||
{
|
||||
if (!renderTex)
|
||||
return;
|
||||
video::COGLES1FBOTexture* rtt = static_cast<video::COGLES1FBOTexture*>(renderTex);
|
||||
rtt->bindRTT();
|
||||
#ifdef GL_OES_framebuffer_object
|
||||
if (UseStencil)
|
||||
{
|
||||
// attach stencil texture to stencil buffer
|
||||
Driver->extGlFramebufferTexture2D(GL_FRAMEBUFFER_OES,
|
||||
GL_STENCIL_ATTACHMENT_OES,
|
||||
GL_TEXTURE_2D,
|
||||
StencilRenderBuffer,
|
||||
0);
|
||||
|
||||
// attach depth texture to depth buffer
|
||||
Driver->extGlFramebufferTexture2D(GL_FRAMEBUFFER_OES,
|
||||
GL_DEPTH_ATTACHMENT_OES,
|
||||
GL_TEXTURE_2D,
|
||||
DepthRenderBuffer,
|
||||
0);
|
||||
}
|
||||
else
|
||||
{
|
||||
// attach depth renderbuffer to depth buffer
|
||||
Driver->extGlFramebufferRenderbuffer(GL_FRAMEBUFFER_OES,
|
||||
GL_DEPTH_ATTACHMENT_OES,
|
||||
GL_RENDERBUFFER_OES,
|
||||
DepthRenderBuffer);
|
||||
}
|
||||
// check the status
|
||||
if (!checkFBOStatus(Driver))
|
||||
os::Printer::log("FBO incomplete");
|
||||
#endif
|
||||
rtt->DepthTexture=this;
|
||||
grab(); // grab the depth buffer, not the RTT
|
||||
rtt->unbindRTT();
|
||||
}
|
||||
|
||||
|
||||
//! Bind Render Target Texture
|
||||
void COGLES1FBODepthTexture::bindRTT()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
//! Unbind Render Target Texture
|
||||
void COGLES1FBODepthTexture::unbindRTT()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
#ifdef GL_OES_framebuffer_object
|
||||
bool checkFBOStatus(COGLES1Driver* Driver)
|
||||
{
|
||||
GLenum status = Driver->extGlCheckFramebufferStatus(GL_FRAMEBUFFER_OES);
|
||||
|
||||
switch (status)
|
||||
{
|
||||
//Our FBO is perfect, return true
|
||||
case GL_FRAMEBUFFER_COMPLETE_OES:
|
||||
return true;
|
||||
|
||||
case GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_OES:
|
||||
os::Printer::log("FBO has one or several incomplete image attachments", ELL_ERROR);
|
||||
break;
|
||||
|
||||
case GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_OES:
|
||||
os::Printer::log("FBO missing an image attachment", ELL_ERROR);
|
||||
break;
|
||||
|
||||
case GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_OES:
|
||||
os::Printer::log("FBO has one or several image attachments with different dimensions", ELL_ERROR);
|
||||
break;
|
||||
|
||||
case GL_FRAMEBUFFER_INCOMPLETE_FORMATS_OES:
|
||||
os::Printer::log("FBO has one or several image attachments with different internal formats", ELL_ERROR);
|
||||
break;
|
||||
|
||||
// not part of all implementations
|
||||
#ifdef GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_OES
|
||||
case GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_OES:
|
||||
os::Printer::log("FBO has invalid draw buffer", ELL_ERROR);
|
||||
break;
|
||||
#endif
|
||||
|
||||
// not part of all implementations
|
||||
#ifdef GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_OES
|
||||
case GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_OES:
|
||||
os::Printer::log("FBO has invalid read buffer", ELL_ERROR);
|
||||
break;
|
||||
#endif
|
||||
|
||||
// not part of fbo_object anymore, but won't harm as it is just a return value
|
||||
#ifdef GL_FRAMEBUFFER_INCOMPLETE_DUPLICATE_ATTACHMENT_OES
|
||||
case GL_FRAMEBUFFER_INCOMPLETE_DUPLICATE_ATTACHMENT_OES:
|
||||
os::Printer::log("FBO has a duplicate image attachment", ELL_ERROR);
|
||||
break;
|
||||
#endif
|
||||
|
||||
case GL_FRAMEBUFFER_UNSUPPORTED_OES:
|
||||
os::Printer::log("FBO format unsupported", ELL_ERROR);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
os::Printer::log("FBO error", ELL_ERROR);
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
} // end namespace video
|
||||
} // end namespace irr
|
||||
|
||||
#endif // _IRR_COMPILE_WITH_OGLES1_
|
||||
|
@ -1,177 +0,0 @@
|
||||
// Copyright (C) 2002-2008 Nikolaus Gebhardt
|
||||
// This file is part of the "Irrlicht Engine".
|
||||
// For conditions of distribution and use, see copyright notice in irrlicht.h
|
||||
|
||||
#ifndef __C_OGLES1_TEXTURE_H_INCLUDED__
|
||||
#define __C_OGLES1_TEXTURE_H_INCLUDED__
|
||||
|
||||
#include "ITexture.h"
|
||||
#include "IImage.h"
|
||||
|
||||
#include "IrrCompileConfig.h"
|
||||
#if defined(_IRR_COMPILE_WITH_OGLES1_)
|
||||
|
||||
#if defined(_IRR_COMPILE_WITH_IPHONE_DEVICE_)
|
||||
#include <OpenGLES/ES1/gl.h>
|
||||
#include <OpenGLES/ES1/glext.h>
|
||||
#elif defined(_IRR_ANDROID_PLATFORM_)
|
||||
#include <GLES/gl.h>
|
||||
#include <GLES/glext.h>
|
||||
#else
|
||||
#include <GLES/egl.h>
|
||||
#endif
|
||||
|
||||
namespace irr
|
||||
{
|
||||
namespace video
|
||||
{
|
||||
|
||||
class COGLES1Driver;
|
||||
//! OGLES1 texture.
|
||||
class COGLES1Texture : public ITexture
|
||||
{
|
||||
public:
|
||||
|
||||
//! constructor
|
||||
COGLES1Texture(IImage* surface, const io::path& name, COGLES1Driver* driver=0, void* mipmapData=0);
|
||||
|
||||
//! destructor
|
||||
virtual ~COGLES1Texture();
|
||||
|
||||
//! lock function
|
||||
virtual void* lock(E_TEXTURE_LOCK_MODE mode=ETLM_READ_WRITE, u32 mipmapLevel=0);
|
||||
|
||||
//! unlock function
|
||||
virtual void unlock();
|
||||
|
||||
//! Returns original size of the texture (image).
|
||||
virtual const core::dimension2d<u32>& getOriginalSize() const;
|
||||
|
||||
//! Returns size of the texture.
|
||||
virtual const core::dimension2d<u32>& getSize() const;
|
||||
|
||||
//! returns driver type of texture (=the driver, that created it)
|
||||
virtual E_DRIVER_TYPE getDriverType() const;
|
||||
|
||||
//! returns color format of texture
|
||||
virtual ECOLOR_FORMAT getColorFormat() const;
|
||||
|
||||
//! returns pitch of texture (in bytes)
|
||||
virtual u32 getPitch() const;
|
||||
|
||||
//! return open gl texture name
|
||||
GLuint getOGLES1TextureName() const;
|
||||
|
||||
//! return whether this texture has mipmaps
|
||||
virtual bool hasMipMaps() const;
|
||||
|
||||
//! Regenerates the mip map levels of the texture.
|
||||
virtual void regenerateMipMapLevels(void* mipmapData=0);
|
||||
|
||||
//! Is it a render target?
|
||||
virtual bool isRenderTarget() const;
|
||||
|
||||
//! Is it a FrameBufferObject?
|
||||
virtual bool isFrameBufferObject() const;
|
||||
|
||||
//! Bind RenderTargetTexture
|
||||
void bindRTT();
|
||||
|
||||
//! Unbind RenderTargetTexture
|
||||
void unbindRTT();
|
||||
|
||||
//! sets whether this texture is intended to be used as a render target.
|
||||
void setIsRenderTarget(bool isTarget);
|
||||
|
||||
protected:
|
||||
|
||||
//! protected constructor with basic setup, no GL texture name created, for derived classes
|
||||
COGLES1Texture(const io::path& name, COGLES1Driver* driver);
|
||||
|
||||
//! get the desired color format based on texture creation flags and the input format.
|
||||
ECOLOR_FORMAT getBestColorFormat(ECOLOR_FORMAT format);
|
||||
|
||||
//! convert the image into an internal image with better properties for this driver.
|
||||
void getImageValues(IImage* image);
|
||||
|
||||
//! copies the the texture into an open gl texture.
|
||||
void uploadTexture(bool newTexture=true, void* mipmapData=0, u32 mipLevel=0);
|
||||
|
||||
core::dimension2d<u32> ImageSize;
|
||||
core::dimension2d<u32> TextureSize;
|
||||
ECOLOR_FORMAT ColorFormat;
|
||||
COGLES1Driver* Driver;
|
||||
IImage* Image;
|
||||
IImage* MipImage;
|
||||
|
||||
GLuint TextureName;
|
||||
GLint InternalFormat;
|
||||
GLenum PixelFormat;
|
||||
GLenum PixelType;
|
||||
u32 MipLevelStored;
|
||||
|
||||
bool HasMipMaps;
|
||||
bool IsRenderTarget;
|
||||
bool AutomaticMipmapUpdate;
|
||||
bool UseStencil;
|
||||
bool ReadOnlyLock;
|
||||
bool KeepImage;
|
||||
};
|
||||
|
||||
|
||||
//! OGLES1 FBO texture.
|
||||
class COGLES1FBOTexture : public COGLES1Texture
|
||||
{
|
||||
public:
|
||||
|
||||
//! FrameBufferObject constructor
|
||||
COGLES1FBOTexture(const core::dimension2d<u32>& size, const io::path& name, COGLES1Driver* driver=0, ECOLOR_FORMAT format = ECF_UNKNOWN);
|
||||
|
||||
//! destructor
|
||||
virtual ~COGLES1FBOTexture();
|
||||
|
||||
//! Is it a FrameBufferObject?
|
||||
virtual bool isFrameBufferObject() const;
|
||||
|
||||
//! Bind RenderTargetTexture
|
||||
virtual void bindRTT();
|
||||
|
||||
//! Unbind RenderTargetTexture
|
||||
virtual void unbindRTT();
|
||||
|
||||
ITexture* DepthTexture;
|
||||
protected:
|
||||
GLuint ColorFrameBuffer;
|
||||
};
|
||||
|
||||
|
||||
//! OGLES1 FBO depth texture.
|
||||
class COGLES1FBODepthTexture : public COGLES1FBOTexture
|
||||
{
|
||||
public:
|
||||
//! FrameBufferObject depth constructor
|
||||
COGLES1FBODepthTexture(const core::dimension2d<u32>& size, const io::path& name, COGLES1Driver* driver=0, bool useStencil=false);
|
||||
|
||||
//! destructor
|
||||
virtual ~COGLES1FBODepthTexture();
|
||||
|
||||
//! Bind RenderTargetTexture
|
||||
virtual void bindRTT();
|
||||
|
||||
//! Unbind RenderTargetTexture
|
||||
virtual void unbindRTT();
|
||||
|
||||
void attach(ITexture*);
|
||||
|
||||
protected:
|
||||
GLuint DepthRenderBuffer;
|
||||
GLuint StencilRenderBuffer;
|
||||
bool UseStencil;
|
||||
};
|
||||
|
||||
|
||||
} // end namespace video
|
||||
} // end namespace irr
|
||||
|
||||
#endif
|
||||
#endif // _IRR_COMPILE_WITH_OGLES1_
|
Loading…
Reference in New Issue
Block a user