This is the code which draws two triangles/a square using SMeshBuffer:
Code: Select all
Buffer->Vertices.push_back(S3DVertex2TCoords(140.0f, 90.0f + Size, 140.0f + Size, 0.0, 1.0, 0.0, SColor(255, 255, 255, 255), 0.0, 1.0, 1.0 , 0.0));
Buffer->Vertices.push_back(S3DVertex2TCoords(140.0f + Size, 90.0f + Size, 140.0f + Size, 0.0, 1.0, 0.0, SColor(255, 255, 255, 255), 1.0, 1.0, 1.0, 0.0));
Buffer->Vertices.push_back(S3DVertex2TCoords(140.0f + Size, 90.0f + Size, 140.0f, 0.0, 1.0, 0.0, SColor(255, 255, 255, 255), 1.0, 0.0, 1.0, 0.0));
Buffer->Vertices.push_back(S3DVertex2TCoords(140.0f, 90.0f + Size, 140.0f, 0.0, 1.0, 0.0, SColor(255, 255, 255, 255), 0.0, 0.0, 1.0, 0.0));
Code: Select all
ShaderMaterial = IrrDriver->getGPUProgrammingServices()->addHighLevelShaderMaterialFromFiles(vsFile, "main", EVST_VS_4_1, psFile, "main", EPST_PS_4_1, ShaderCallback, EMT_SOLID, 0, EGSL_DEFAULT);
Code: Select all
virtual void OnSetConstants(video::IMaterialRendererServices* Services, s32 UserData)
{
IVideoDriver* IrrDriver = Services->getVideoDriver();
matrix4 ModelMatrix = IrrDriver->getTransform(video::ETS_WORLD);
ModelMatrix.getTransposed();
Services->setVertexShaderConstant("M", ModelMatrix.pointer(), 16);
matrix4 ViewMatrix = IrrDriver->getTransform(video::ETS_VIEW);
Services->setVertexShaderConstant("V", ViewMatrix.pointer(), 16);
matrix4 ProjectionMatrix = IrrDriver->getTransform(video::ETS_PROJECTION);
Services->setVertexShaderConstant("P", ProjectionMatrix.pointer(), 16);
f32 Texture = 0;
Services->setPixelShaderConstant("TextureArray", &Texture, 1);
}
Code: Select all
#version 410 compatibility
uniform mat4 M;
uniform mat4 V;
uniform mat4 P;
out vec4 texCoord;
out vec4 texCoord1;
void main()
{
texCoord = gl_MultiTexCoord0;
texCoord1 = gl_MultiTexCoord1;
mat4 MV = V * M;
mat4 MVP = P * MV;
gl_Position = MVP * gl_Vertex;
}
Code: Select all
#version 410
#extension GL_EXT_texture_array: enable
uniform sampler2DArray TextureArray;
in vec4 texCoord;
in vec4 texCoord1;
out vec4 colorOut;
void main()
{
//This doesn't work
colorOut = texture2DArray(TextureArray, vec3(texCoord.xy, texCoord1.x));
//This doesn't work either
//colorOut = texture2DArray(TextureArray, vec3(texCoord.xy, texCoord.z)
}