Results 1 to 2 of 2

Thread: DirectX to OpenGL translation...

  1. #1

    DirectX to OpenGL translation...

    Hi guys,
    I searched the netz, but could not find a page which showed how to port DirectX 3D calls to OpenGL. Does anyone here know what the following calls become in OpenGL...


    [pascal]
    GR_D3D_Device.SetTextureStageState(0,D3DTSS_ADDRES SU,D3DTADDRESS_CLAMP);
    GR_D3D_Device.SetTextureStageState(0,D3DTSS_ADDRES SV,D3DTADDRESS_CLAMP);
    GR_D3D_Device.SetTexture(0,tex);
    GR_D3D_Device.SetVertexShader(SHADER_TEX);
    GR_D3D_Device.DrawPrimitiveUp(D3DPT_TRIANGLEFAN, 2, vvv, SizeOf(VERTEX_TEX));
    [/pascal]

    Thanks.
    <br /><br />There are a lot of people who are dead while they are still alive. I want to be alive until the day I die.<br />-= Paulo Coelho =-

  2. #2

    DirectX to OpenGL translation...

    This is how I would translate the D3D code to OpenGL (2.0)
    [pascal]
    glActiveTexture(GL_TEXTURE0);
    glBindTexture(GL_TEXTURE_2D, tex);
    glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,GL _CLAMP);
    glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,GL _CLAMP);
    glUseProgram(SHADER_TEX);
    glDrawArrays(GL_TRIANGLE_FAN,0,2);
    [/pascal]

    The code above assumes that tex is the texture identifier,
    SHADER_TEX is theshader id.

    The call to glActiveTexture sets the texture stage - it corresponds to first parameter in SetTexture and setTextureStageState.

    glDrawArrays function is the closest equivalent of DrawPrimitiveUP I can think of.

    This is a literal translation, I assumed that you have created the texture, the shader prgram and prepared the geometry data to be rendered with glDrawArrays.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •