1
\$\begingroup\$

What i'm trying to achieve. I need to know the equivalent of LPDIRECT3DTEXTURE9 to openGL, the problem is I only know Pixmap class of libgdx which pixmap.drawPixel(x, y, color) is only available, I cannot find how to convert layer->lightMap->LockRect(0, &rectLock, 0, 0)

Below is example code of c, LPDIRECT3DTEXTURE9 lightMap is used which unknown in openGL to me.

D3DLOCKED_RECT rectLock;
D3DCOLOR* pixels;
LandLayer* layer;
int j;

for (int i = 0; i < m_layers.GetSize(); i++)
{
    layer = m_layers[i];
    layer->lightMap->LockRect(0, &rectLock, 0, 0);
    pixels = (D3DCOLOR*)rectLock.pBits;
    for (j = 0; j < MAP_SIZE * MAP_SIZE; j++)
        pixels[j] = D3DCOLOR_ARGB(layer->alphaMap[j], m_colorMap[j * 3], m_colorMap[j * 3 + 1], m_colorMap[j * 3 + 2]);
    layer->lightMap->UnlockRect(0);
}

What I have done in kotlin, using Pixmap from libgx https://github.com/libgdx/libgdx/blob/master/gdx/src/com/badlogic/gdx/graphics/Pixmap.java

tmpColor.set( Color.toIntBits( r.toInt(),g.toInt(),b.toInt(),a.toInt()))
pixmap.drawPixel(x, y, tmpColor.toIntBits())
\$\endgroup\$
2
\$\begingroup\$

LPDIRECT3DTEXTURE9 is a texture object. OpenGL, by comparison to Direct3D, is weakly-typed, so there is no class or struct that is equivalent; instead texture objects are represented by unsigned integer "names" - the same GLuint data type that is used for other object types.

From the code you posted it looks as though you're trying to set texture data from a system memory array. The OpenGL calls to do this are glTexImage2D (for creating a new texture) or glTexSubImage2D (for updating an existing texture) - assuming a 2D texture, of course. There is no direct OpenGL equivalent to LockRect.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.