- Fixed some OGL ES2 issues related to shaders.
git-svn-id: http://svn.code.sf.net/p/irrlicht/code/branches/ogl-es@4395 dfc29bdd-3216-0410-991c-e03cc46cb475
This commit is contained in:
parent
6444bb9cdf
commit
2e02393fd6
@ -204,8 +204,12 @@ define out. */
|
||||
#undef _IRR_COMPILE_WITH_OGLES2_
|
||||
#endif
|
||||
#ifndef IRR_OGLES2_SHADER_PATH
|
||||
#ifdef _IRR_COMPILE_WITH_IPHONE_DEVICE_
|
||||
#define IRR_OGLES2_SHADER_PATH ""
|
||||
#else
|
||||
#define IRR_OGLES2_SHADER_PATH "../../media/Shaders/"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
//! Define _IRR_COMPILE_WITH_SOFTWARE_ to compile the Irrlicht engine with software driver
|
||||
/** If you do not need the software driver, or want to use Burning's Video instead,
|
||||
|
@ -2502,7 +2502,7 @@ namespace video
|
||||
u32 verticesOut,
|
||||
IShaderConstantSetCallBack* callback,
|
||||
E_MATERIAL_TYPE baseMaterial,
|
||||
s32 userData)
|
||||
s32 userData, E_GPU_SHADING_LANGUAGE shadingLang)
|
||||
{
|
||||
s32 nr = -1;
|
||||
COGLES2SLMaterialRenderer* r = new COGLES2SLMaterialRenderer(
|
||||
|
@ -285,7 +285,8 @@ namespace video
|
||||
u32 verticesOut = 0,
|
||||
IShaderConstantSetCallBack* callback = 0,
|
||||
E_MATERIAL_TYPE baseMaterial = video::EMT_SOLID,
|
||||
s32 userData=0);
|
||||
s32 userData=0,
|
||||
E_GPU_SHADING_LANGUAGE shadingLang = EGSL_DEFAULT);
|
||||
|
||||
//! Returns pointer to the IGPUProgrammingServices interface.
|
||||
virtual IGPUProgrammingServices* getGPUProgrammingServices();
|
||||
|
@ -261,8 +261,8 @@ namespace video
|
||||
//if (BaseMaterial)
|
||||
// BaseMaterial->OnSetMaterial(material, material, true, this);
|
||||
|
||||
//for (u32 i=0; i<MATERIAL_MAX_TEXTURES; ++i)
|
||||
// Driver->setActiveTexture(i, material.getTexture(i));
|
||||
for (u32 i=0; i<MATERIAL_MAX_TEXTURES; ++i)
|
||||
Driver->setActiveTexture(i, material.getTexture(i));
|
||||
Driver->setBasicRenderStates( material, lastMaterial, resetAllRenderstates );
|
||||
}
|
||||
|
||||
@ -352,22 +352,23 @@ namespace video
|
||||
int num = 0;
|
||||
glGetProgramiv( Program, GL_ACTIVE_UNIFORMS, &num );
|
||||
|
||||
if (num == 0)
|
||||
return true;
|
||||
|
||||
int maxlen = 0;
|
||||
glGetProgramiv( Program, GL_ACTIVE_UNIFORM_MAX_LENGTH, &maxlen );
|
||||
|
||||
if ( maxlen == 0 && num != 0 )
|
||||
if (maxlen == 0)
|
||||
{
|
||||
os::Printer::log( "GLSL: failed to retrieve uniform information", ELL_ERROR );
|
||||
os::Printer::log("GLSL: failed to retrieve uniform information", ELL_ERROR);
|
||||
return false;
|
||||
}
|
||||
|
||||
maxlen++;
|
||||
c8 *buf = new c8[maxlen];
|
||||
|
||||
UniformInfo.clear();
|
||||
UniformInfo.reallocate( num );
|
||||
|
||||
core::array<core::stringc> names( num );
|
||||
core::array<SUniformInfo> uni( num );
|
||||
UniformInfo.reallocate(num);
|
||||
|
||||
for ( int i = 0; i < num; ++i )
|
||||
{
|
||||
@ -375,37 +376,15 @@ namespace video
|
||||
GLint size;
|
||||
SUniformInfo ui;
|
||||
glGetActiveUniform( Program, i, maxlen, 0, &size, &ui.type, reinterpret_cast<char*>( buf ) );
|
||||
|
||||
ui.name = buf;
|
||||
ui.location = glGetUniformLocation( Program, buf );
|
||||
uni.push_back( ui );
|
||||
names.push_back( buf );
|
||||
|
||||
UniformInfo.push_back(ui);
|
||||
}
|
||||
|
||||
delete [] buf;
|
||||
|
||||
for ( int i = 0; i < UniformCount; ++i )
|
||||
{
|
||||
int j;
|
||||
for ( j = 0; j < num; ++j )
|
||||
{
|
||||
if ( names[j] == UniformStringTable[i] )
|
||||
break;
|
||||
}
|
||||
if ( j < num )
|
||||
{
|
||||
UniformInfo.push_back( uni[j] );
|
||||
}
|
||||
else
|
||||
{
|
||||
wchar_t buf[512];
|
||||
swprintf( buf, 512, L"Unable to find uniform : %s", UniformStringTable[i] );
|
||||
os::Printer::log( buf, ELL_WARNING );
|
||||
SUniformInfo blank;
|
||||
blank.location = -1;
|
||||
blank.type = GL_INVALID_ENUM;
|
||||
UniformInfo.push_back( blank );
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -454,14 +433,109 @@ namespace video
|
||||
|
||||
bool COGLES2SLMaterialRenderer::setPixelShaderConstant( const c8* name, const f32* floats, int count )
|
||||
{
|
||||
os::Printer::log( "Cannot set constant, use high level shader call.", ELL_WARNING );
|
||||
u32 i;
|
||||
const u32 num = UniformInfo.size();
|
||||
|
||||
for (i=0; i < num; ++i)
|
||||
{
|
||||
if (UniformInfo[i].name == name)
|
||||
break;
|
||||
}
|
||||
|
||||
if (i == num)
|
||||
return false;
|
||||
|
||||
if(UniformInfo[i].location == -1)
|
||||
return false;
|
||||
|
||||
bool status = true;
|
||||
|
||||
switch (UniformInfo[i].type)
|
||||
{
|
||||
case GL_FLOAT:
|
||||
glUniform1fv(UniformInfo[i].location, count, floats);
|
||||
break;
|
||||
case GL_FLOAT_VEC2:
|
||||
glUniform2fv(UniformInfo[i].location, count/2, floats);
|
||||
break;
|
||||
case GL_FLOAT_VEC3:
|
||||
glUniform3fv(UniformInfo[i].location, count/3, floats);
|
||||
break;
|
||||
case GL_FLOAT_VEC4:
|
||||
glUniform4fv(UniformInfo[i].location, count/4, floats);
|
||||
break;
|
||||
case GL_FLOAT_MAT2:
|
||||
glUniformMatrix2fv(UniformInfo[i].location, count/4, false, floats);
|
||||
break;
|
||||
case GL_FLOAT_MAT3:
|
||||
glUniformMatrix3fv(UniformInfo[i].location, count/9, false, floats);
|
||||
break;
|
||||
case GL_FLOAT_MAT4:
|
||||
glUniformMatrix4fv(UniformInfo[i].location, count/16, false, floats);
|
||||
break;
|
||||
case GL_SAMPLER_2D:
|
||||
case GL_SAMPLER_CUBE:
|
||||
{
|
||||
if(floats)
|
||||
{
|
||||
GLint id = *floats;
|
||||
glUniform1iv(UniformInfo[i].location, 1, &id);
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
status = false;
|
||||
break;
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
bool COGLES2SLMaterialRenderer::setPixelShaderConstant( const c8* name, const s32* ints, int count )
|
||||
{
|
||||
os::Printer::log( "Cannot set constant, use high level shader call.", ELL_WARNING );
|
||||
u32 i;
|
||||
const u32 num = UniformInfo.size();
|
||||
|
||||
for (i=0; i < num; ++i)
|
||||
{
|
||||
if (UniformInfo[i].name == name)
|
||||
break;
|
||||
}
|
||||
|
||||
if (i == num)
|
||||
return false;
|
||||
|
||||
if(UniformInfo[i].location == -1)
|
||||
return false;
|
||||
|
||||
bool status = true;
|
||||
|
||||
switch (UniformInfo[i].type)
|
||||
{
|
||||
case GL_INT_VEC2:
|
||||
case GL_BOOL_VEC2:
|
||||
glUniform2iv(UniformInfo[i].location, count/2, ints);
|
||||
break;
|
||||
case GL_INT_VEC3:
|
||||
case GL_BOOL_VEC3:
|
||||
glUniform3iv(UniformInfo[i].location, count/3, ints);
|
||||
break;
|
||||
case GL_INT_VEC4:
|
||||
case GL_BOOL_VEC4:
|
||||
glUniform4iv(UniformInfo[i].location, count/4, ints);
|
||||
break;
|
||||
case GL_INT:
|
||||
case GL_BOOL:
|
||||
case GL_SAMPLER_2D:
|
||||
case GL_SAMPLER_CUBE:
|
||||
glUniform1iv(UniformInfo[i].location, count, ints);
|
||||
break;
|
||||
default:
|
||||
status = false;
|
||||
break;
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
bool COGLES2SLMaterialRenderer::setUniform( int index, const void* data, int count )
|
||||
|
@ -34,6 +34,7 @@ namespace video
|
||||
protected:
|
||||
struct SUniformInfo
|
||||
{
|
||||
core::stringc name;
|
||||
u32 type;
|
||||
s32 location;
|
||||
};
|
||||
|
@ -24,6 +24,7 @@
|
||||
#include "SIrrCreationParameters.h"
|
||||
#include <CoreFoundation/CFRunLoop.h>
|
||||
#include "SExposedVideoData.h"
|
||||
#include "IFileSystem.h"
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
#import <CoreMotion/CoreMotion.h>
|
||||
@ -486,7 +487,6 @@ namespace irr
|
||||
#ifdef _DEBUG
|
||||
setDebugName("CIrrDeviceIPhone");
|
||||
#endif
|
||||
|
||||
DeviceM = [[IrrIPhoneDevice alloc] initWithDevice: this];
|
||||
|
||||
// print version, distribution etc.
|
||||
@ -507,6 +507,13 @@ namespace irr
|
||||
return;
|
||||
}
|
||||
|
||||
NSBundle* Bundle = [NSBundle mainBundle];
|
||||
NSString* BundlePath = [Bundle bundlePath];
|
||||
|
||||
core::stringc NewPath = [BundlePath cStringUsingEncoding:NSASCIIStringEncoding];
|
||||
|
||||
FileSystem->changeWorkingDirectoryTo(NewPath);
|
||||
|
||||
// create driver
|
||||
createDriver();
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user