Porting RoomTiny Client distortion to Jogl
I am trying to port the RoomTiny example to jogl (Opengl binding for Java)
I dont know DirectX unfortunately, although it looks quite similar to OpenGL..
My question is where the texture is binded to the context before the draw command
In the RenderTiny_D3D11_Device.cpp I see:
In the
void RenderDevice::Render(const Matrix4f& view, Model* model)
basically if vbo and ibo are not yet initialized, then they created.
While in the
void RenderDevice::Render(const ShaderFill* fill, Buffer* vertices, Buffer* indices, int stride,
const Matrix4f& matrix, int offset, int count, PrimitiveType rprim, bool updateUniformData)
Shaders get binded together with several uniforms. Then the primitive type is choose and then the draw command..
Where the texture binding get place?
I dont know DirectX unfortunately, although it looks quite similar to OpenGL..
My question is where the texture is binded to the context before the draw command
In the RenderTiny_D3D11_Device.cpp I see:
void RenderDevice::Render(const Matrix4f& view, Model* model)
{
// Store data in buffers if not already
if (!model->VertexBuffer)
{
Ptr<Buffer> vb = *CreateBuffer();
vb->Data(Buffer_Vertex, &model->Vertices[0], model->Vertices.GetSize() * sizeof(Vertex));
model->VertexBuffer = vb;
}
if (!model->IndexBuffer)
{
Ptr<Buffer> ib = *CreateBuffer();
ib->Data(Buffer_Index, &model->Indices[0], model->Indices.GetSize() * 2);
model->IndexBuffer = ib;
}
Render(model->Fill ? model->Fill : DefaultFill,
model->VertexBuffer, model->IndexBuffer,sizeof(Vertex),
view, 0, (unsigned)model->Indices.GetSize(), model->GetPrimType());
}
//Cut down one for ORT for simplicity
void RenderDevice::Render(const ShaderFill* fill, Buffer* vertices, Buffer* indices, int stride)
{
Render(fill, vertices, indices, stride, Matrix4f(), 0,(int)vertices->GetSize(), Prim_Triangles, false);
}
void RenderDevice::Render(const ShaderFill* fill, Buffer* vertices, Buffer* indices, int stride,
const Matrix4f& matrix, int offset, int count, PrimitiveType rprim, bool updateUniformData)
{
if(((ShaderFill*)fill)->GetInputLayout() != NULL)
Context->IASetInputLayout((ID3D11InputLayout*)((ShaderFill*)fill)->GetInputLayout());
else
Context->IASetInputLayout(ModelVertexIL);
if (indices)
{
Context->IASetIndexBuffer(((Buffer*)indices)->GetBuffer(), DXGI_FORMAT_R16_UINT, 0);
}
ID3D11Buffer* vertexBuffer = ((Buffer*)vertices)->GetBuffer();
UINT vertexStride = stride;
UINT vertexOffset = offset;
Context->IASetVertexBuffers(0, 1, &vertexBuffer, &vertexStride, &vertexOffset);
ShaderSet* shaders = ((ShaderFill*)fill)->GetShaders();
ShaderBase* vshader = ((ShaderBase*)shaders->GetShader(Shader_Vertex));
unsigned char* vertexData = vshader->UniformData;
if (vertexData)
{
// TODO: some VSes don't start with StandardUniformData!
if ( updateUniformData )
{
StandardUniformData* stdUniforms = (StandardUniformData*) vertexData;
stdUniforms->View = matrix.Transposed();
stdUniforms->Proj = StdUniforms.Proj;
}
UniformBuffers[Shader_Vertex]->Data(Buffer_Uniform, vertexData, vshader->UniformsSize);
vshader->SetUniformBuffer(UniformBuffers[Shader_Vertex]);
}
for(int i = Shader_Vertex + 1; i < Shader_Count; i++)
if (shaders->GetShader(i))
{
((ShaderBase*)shaders->GetShader(i))->UpdateBuffer(UniformBuffers[i]);
((ShaderBase*)shaders->GetShader(i))->SetUniformBuffer(UniformBuffers[i]);
}
D3D11_PRIMITIVE_TOPOLOGY prim;
switch(rprim)
{
case Prim_Triangles:
prim = D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST;
break;
case Prim_Lines:
prim = D3D11_PRIMITIVE_TOPOLOGY_LINELIST;
break;
case Prim_TriangleStrip:
prim = D3D11_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP;
break;
default:
OVR_ASSERT(0);
return;
}
Context->IASetPrimitiveTopology(prim);
fill->Set(rprim);
if (indices)
{
Context->DrawIndexed(count, 0, 0);
}
else
{
Context->Draw(count, 0);
}
}
In the
void RenderDevice::Render(const Matrix4f& view, Model* model)
basically if vbo and ibo are not yet initialized, then they created.
While in the
void RenderDevice::Render(const ShaderFill* fill, Buffer* vertices, Buffer* indices, int stride,
const Matrix4f& matrix, int offset, int count, PrimitiveType rprim, bool updateUniformData)
Shaders get binded together with several uniforms. Then the primitive type is choose and then the draw command..
Where the texture binding get place?
