- Fixed many issues with OGL ES 2.0 driver under iOS.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/branches/ogl-es@4245 dfc29bdd-3216-0410-991c-e03cc46cb475
master
nadro 2012-07-13 23:16:59 +00:00
parent f5cda1464a
commit 5d8cb2efce
8 changed files with 44 additions and 21 deletions

View File

@ -309,6 +309,18 @@ namespace irr
return true;
#else
return false;
#endif
case video::EDT_OGLES1:
#ifdef _IRR_COMPILE_WITH_OGLES1_
return true;
#else
return false;
#endif
case video::EDT_OGLES2:
#ifdef _IRR_COMPILE_WITH_OGLES2_
return true;
#else
return false;
#endif
default:
return false;

View File

@ -33,7 +33,7 @@ varying float varClipDist;
/* Uniforms */
uniform int uRenderMode;
uniform int uFRenderMode;
uniform bool uAlphaTest;
uniform float uAlphaValue;
@ -149,21 +149,21 @@ void main (void)
if(varClipDist < 0.0)
discard;
if( uRenderMode == TwoD)
if( uFRenderMode == TwoD)
gl_FragColor = render2D();
else if( uRenderMode == Solid)
else if( uFRenderMode == Solid)
gl_FragColor = renderSolid();
else if(uRenderMode == LightMap)
else if(uFRenderMode == LightMap)
gl_FragColor = renderLightMap();
else if(uRenderMode == DetailMap)
else if(uFRenderMode == DetailMap)
gl_FragColor = renderDetailMap();
else if(uRenderMode == SphereMap)
else if(uFRenderMode == SphereMap)
gl_FragColor = renderSolid();
else if(uRenderMode == Reflection2Layer)
else if(uFRenderMode == Reflection2Layer)
gl_FragColor = renderReflection2Layer();
else if(uRenderMode == TransparentVertexAlpha)
else if(uFRenderMode == TransparentVertexAlpha)
gl_FragColor = renderTransparentVertexAlpha();
else if(uRenderMode == TransparentAlphaChannel)
else if(uFRenderMode == TransparentAlphaChannel)
gl_FragColor = renderTransparentAlphaChannel();
else
gl_FragColor = vec4(0.0, 1.0, 1.0, 1.0);

View File

@ -22,8 +22,10 @@ attribute vec4 inVertexColor;
attribute vec4 inTexCoord0;
attribute vec4 inTexCoord1;
attribute vec3 inVertexNormal;
attribute vec3 inVertexTangent;
attribute vec3 inVertexBinormal;
uniform int uRenderMode;
uniform int uVRenderMode;
/* Matrix Uniforms */
@ -213,7 +215,7 @@ void main(void)
if( uUseTexture[0])
{
if(uRenderMode == SphereMap || uRenderMode == Reflection2Layer)
if(uVRenderMode == SphereMap || uVRenderMode == Reflection2Layer)
{
vec3 eyeDir = normalize(inVertexPosition.xyz - uEyePos);
vec3 reflection = reflect(eyeDir, gNormal);

View File

@ -18,7 +18,8 @@ namespace video
const char* const COGLES2FixedPipelineShader::sBuiltInShaderUniformNames[] =
{
"uRenderMode",
"uVRenderMode",
"uFRenderMode",
"uMvpMatrix",
"uWorldMatrix",
"uNormalize",
@ -221,7 +222,8 @@ namespace video
setUniform(CLIP, &Clip);
setUniform(CLIP_PLANE, &ClipPlane);
setUniform(RENDER_MODE, &RenderMode);
setUniform(VRENDER_MODE, &RenderMode);
setUniform(FRENDER_MODE, &RenderMode);
return statusOk ;
};

View File

@ -147,7 +147,8 @@ namespace video
private :
enum SHADER_UNIFORM
{
RENDER_MODE = 0,
VRENDER_MODE = 0,
FRENDER_MODE,
MVP_MATRIX,
WORLD_MATRIX,
NORMALIZE,

View File

@ -104,10 +104,12 @@ CIrrDeviceIPhone::~CIrrDeviceIPhone()
bool CIrrDeviceIPhone::createDisplay()
{
bool typeES2 = (CreationParams.DriverType == video::EDT_OGLES2) ? true : false;
(*IrrIPhoneDevice.displayCreate)(
&IrrIPhoneDevice,
&CreationParams.WindowId,
CreationParams.WindowSize.Width, CreationParams.WindowSize.Height);
CreationParams.WindowSize.Width, CreationParams.WindowSize.Height, typeES2);
return true;
}

View File

@ -24,7 +24,7 @@ struct MIrrIPhoneDevice
/* The *display* functions call into the Obj-C instance. */
void (*displayCreate)(struct MIrrIPhoneDevice * dev,
void** window, int w, int h);
void** window, int w, int h, bool type);
void (*displayInit)(struct MIrrIPhoneDevice * dev,
void** context, void** view);
void (*displayBegin)(struct MIrrIPhoneDevice * dev);

View File

@ -192,7 +192,7 @@
- (void) applicationWillResignActive: (UIApplication *) application;
- (void) applicationDidBecomeActive: (UIApplication *) application;
- (void) applicationWillTerminate: (UIApplication *) application;
- (void) displayCreateInWindow: (UIWindow**) window Width: (int) w Height: (int) h;
- (void) displayCreateInWindow: (UIWindow**) window Width: (int) w Height: (int) h OGLESType: (bool) type;
- (void) displayInitialize: (EAGLContext**) context_ View: (IrrIPhoneView**) view_;
- (void) displayBegin;
- (void) displayEnd;
@ -228,7 +228,7 @@
{
(*(dev->onTerminate))(dev);
}
- (void) displayCreateInWindow: (UIWindow**) window Width: (int) w Height: (int) h
- (void) displayCreateInWindow: (UIWindow**) window Width: (int) w Height: (int) h OGLESType: (bool) type
{
// Create our view.
CGRect rect;
@ -247,7 +247,11 @@
// Create the GL context now, so that the driver initializetion
// can make OpenGL calls.
context = [[EAGLContext alloc] initWithAPI: kEAGLRenderingAPIOpenGLES1];
if(type)
context = [[EAGLContext alloc] initWithAPI: kEAGLRenderingAPIOpenGLES2];
else
context = [[EAGLContext alloc] initWithAPI: kEAGLRenderingAPIOpenGLES1];
[EAGLContext setCurrentContext: context];
}
- (void) displayInitialize: (EAGLContext**) context_ View: (IrrIPhoneView**) view_
@ -279,9 +283,9 @@
@end
void irr_device_iphone_display_create(struct irr::MIrrIPhoneDevice * dev,
void** window, int w, int h)
void** window, int w, int h, bool type)
{
[((IrrIPhoneDevice*)dev->DeviceM) displayCreateInWindow: (UIWindow**)window Width: w Height: h];
[((IrrIPhoneDevice*)dev->DeviceM) displayCreateInWindow: (UIWindow**)window Width: w Height: h OGLESType: type];
}
void irr_device_iphone_display_init(struct irr::MIrrIPhoneDevice * dev,