Why i don't get the correct vertex coordinates with this:
Where i define my vertex descriptor for a S3DVertex
Code: Select all
IVertexDescriptor* ShaderFloor::getVertexDescriptor(IVideoDriver* driver)
{
IVertexDescriptor* descriptor = driver->getVertexDescriptor(SHADER_FLOOR_VERTEX_FORMAT_NAME);
if(descriptor==nullptr)
{
descriptor = driver->addVertexDescriptor(SHADER_FLOOR_VERTEX_FORMAT_NAME);
descriptor->addAttribute("inPosition",3,video::EVAS_POSITION,video::EVAT_FLOAT,0);
descriptor->addAttribute("inNormal",3,video::EVAS_NORMAL,video::EVAT_FLOAT,0);
descriptor->addAttribute("inColor",1,video::EVAS_COLOR,video::EVAT_UINT,0);
descriptor->addAttribute("inTexCoord",2,video::EVAS_TEXCOORD0,video::EVAT_FLOAT,0);
}
return descriptor;
}
Code: Select all
void Plane::setVertexDescriptor(IVertexDescriptor* descriptor)
{
mMeshBuffer->setVertexDescriptor(descriptor);
}
my vertexShader
Code: Select all
#version 120
uniform mat4 uWorldViewProj;
attribute vec3 inPosition;
attribute vec3 inNormal;
attribute int inColor;
attribute vec2 inTexCoord;
varying vec2 vTexCoord;
void main ()
{
gl_Position = uWorldViewProj * vec4(inPosition,1.0f);
vTexCoord=inTexCoord;
}
Code: Select all
#version 120
uniform sampler2D uTex0;
varying vec2 vTexCoord;
void main ()
{
gl_FragColor = texture2D(uTex0,vTexCoord);
}
In the shader pipeline is this function correct? CMeshBuffer.h
Code: Select all
virtual bool setVertexDescriptor(video::IVertexDescriptor* vertexDescriptor)
{
if (vertexDescriptor && vertexDescriptor != VertexDescriptor)
{
if (VertexDescriptor)
VertexDescriptor->drop();
VertexDescriptor = vertexDescriptor;
VertexDescriptor->grab();
bool vertexBufferCompatible = true;
for (u32 i = 0; i < VertexBuffer.size(); ++i)
{
if (VertexDescriptor->getVertexSize(i) != VertexBuffer[i]->getVertexSize())
{
vertexBufferCompatible = false;
break;
}
}
VertexBufferCompatible = vertexBufferCompatible;
return true; /// <-- HERE
}
return false;
}