Hi all,

Im having a very annoying problem, i have an opengl engine with a texture list class. When i add a texture, all seems to go through ok, and no problems with creating the texture.

How ever no matter what i do the texture will not bind, all i get is a blank image, i copy the pixels to an sdl surface and save it and the texture is there.

Below i have included the code i am using:

Creating the texture:
[pascal]
function TXTexture.GLCreate(const Index: Cardinal): Boolean;
var
Target: TXTarget;
W,H: Integer;
begin
glGenTextures(1, @Frames[Index].Index);
Log.Debug('Generating OpenGL texture '''+MClassname+''' ['+InttoStr(ID)+'/'+InttoStr(Frames[Index].Index)+']', 'XTexture');

H := Propertise.GetInt('height', 0);
W := Propertise.GetInt('width', 0);

Target := TXTarget(Propertise.GetInt('target', 1));
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, Frames[Index].Index);

// gluBuild2DMipmaps(XTarget(Target), 3, W, H, GL_BGR, GL_UNSIGNED_BYTE, Frames[Index].Pixels);
// gluBuild2DMipmaps(XTarget(Target), GL_BGRA, W, H, GL_BGRA, GL_UNSIGNED_BYTE, Frames[Index].Pixels);
glTexImage2D(GL_TEXTURE_2D, 0, 3, W, H, 0, GL_BGR, GL_UNSIGNED_BYTE, Frames[Index].Pixels);

If (Target = xt1D) Or (Target = xt2D) Or (Target = xt3D) Then
Begin
// glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
// glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
// glTexParameteri(XTarget(Target), GL_TEXTURE_MAG_FILTER, XMagFilter(TXMagFilter(Propertise.GetInt('filter.m ag', 0))));
// glTexParameteri(XTarget(Target), GL_TEXTURE_MIN_FILTER, XMinFilter(TXMinFilter(Propertise.GetInt('filter.m in', 1))));
End Else
Begin
glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB, GL_TEXTURE_MAG_FILTER, XMagFilter(TXMagFilter(Propertise.GetInt('filter.m ag', 0))));
glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB, GL_TEXTURE_MIN_FILTER, XMinFilter(TXMinFilter(Propertise.GetInt('filter.m in', 0))));
End;

Result := (Frames[Index].Index > 0);
end;
[/pascal]

I have changed the code a little to see if i can figure out the problem.

Bind:
[pascal]
Target := TXTarget(Propertise.GetInt('target', 1));
glEnable(XTarget(Target));
glBindTexture(XTarget(Target), Frames[0].Index);
// glBindTexture(XTarget(Target), Frames[Frame].Index);
[/pascal]

I have been trying to figure this out for the last 2 days but have not got anywhere.

Many thanks
Nic