Witam mam nieciekawy problem z teksturą ponieważ zostaje ona wyświetlona w czarno białym kolorze i jest skręcona o jakies 5-10 stopni w lewo.
Screen z okna :
http://img689.imageshack.us/i/oknoy.jpg/
Kawałek kodu
Status: Bool;
LightAmbient: array [0..3] of GLfloat = ( 0.5, 0.5, 0.5, 1.0 ); // Światła otoczenia
LightDiffuse: array [0..3] of GLfloat = ( 1.0, 1.0, 1.0, 1.0 ); // Bezpośredniego światła
LightPosition: array [0..3] of GLfloat = ( 0.0, 0.0, 2.0, 1.0 ); // Światła pozycji
texture: array [0..0] of GLuint;
function LoadBMP(FileName: pchar):PTAUX_RGBImageRec;
begin
if Filename = '' then
begin
Result := nil;
exit;
end;
if not FileExists(Filename) then
begin
Result := nil;
exit;
end;
Result := auxDIBImageLoadA(FileName);
end;
function LoadGLTextures: Bool;
var TextureImage: array [0..0] of PTAUX_RGBImageRec;
Status: Bool;
begin
Status := false;
ZeroMemory(@TextureImage,sizeof(TextureImage));
TextureImage[0] := LoadBMP('tekstury/Shops.bmp');
if Assigned(TextureImage[0]) then
begin
Status := true;
glGenTextures(1,Texture[0]);
glBindTexture(GL_TEXTURE_2D,texture[0]);
glTexImage2D(GL_TEXTURE_2D,0,3,TextureImage[0].sizeX,TextureImage[0].sizeY,0,GL_RGB,GL_UNSIGNED_BYTE,TextureImage[0].data); // Vlastní vytváření textury
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
end;
Result := Status;
end;
function IntToStr(Num : Integer) : String;
begin
Str(Num, result);
end;
procedure blok1 ();
begin
glPushmatrix();
glTranslatef(0.0,5.0,0.0);
glBindTexture(GL_TEXTURE_2D,texture[0]);
glBegin(GL_POLYGON);
// gorna
glVertex3f( 160.0, 70.0,-160.0);
glVertex3f(-160.0, 70.0,-160.0);
glVertex3f(-160.0, 70.0, 160.0);
glVertex3f( 160.0, 70.0, 160.0);
glEnd();
//przednia
glBegin(GL_POLYGON);
glTexCoord2f(1.0, 1.0); glVertex3f( 160.0, 70.0, 160.0);
glTexCoord2f(0.0, 1.0); glVertex3f(-160.0, 70.0, 160.0);
glTexCoord2f(0.0, 0.0); glVertex3f(-160.0,-70.0, 160.0);
glTexCoord2f(1.0, 0.0); glVertex3f( 160.0,-70.0,160.0);
glend();
//tylnia
glBegin(GL_POLYGON);
glVertex3f( 160,70.0,-160.0);
glVertex3f(-160,70.0,-160.0);
glVertex3f(-160,-70.0,-160.0);
glVertex3f( 160,-70.0,-160.0);
glend();
glBegin(GL_POLYGON);
//dolna
glVertex3f( 160.0,-70.0, 160.0);
glVertex3f(-160.0,-70.0, 160.0);
glVertex3f(-160.0,-70.0,-160.0);
glVertex3f( 160.0,-70.0,-160.0);
glend();
glBegin(GL_POLYGON);
//lewa
glVertex3f( -160.0, 70.0, 160.0);
glVertex3f(-160.0, 70.0, -160.0);
glVertex3f(-160.0,-70.0, -160.0);
glVertex3f( -160.0,-70.0, 160.0);
glend();
glBegin(GL_POLYGON);
//prawa
glVertex3f( 160.0, 70.0, -160.0);
glVertex3f(160.0, 70.0, 160.0);
glVertex3f(160.0,-70.0, 160.0);
glVertex3f( 160.0,-70.0, -160.0);
glend();
glPopmatrix();
end;
procedure glDraw();
var
x_m, y_m, z_m, u_m, v_m: GLfloat;
xtrans, ztrans, ytrans: GLfloat;
sceneroty: GLfloat;
numtriangles: integer;
loop_m: integer;
begin
xtrans := -xpos;
ztrans := -zpos;
ytrans := -walkbias-0.25;
sceneroty := 360 - yrot;
glClear(GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
glRotatef(lookupdown, 1.0,0.0,0.0);
glRotatef(sceneroty, 0.0,1.0,0.0);
glTranslatef(xtrans, ytrans, ztrans);
blok1();
end;
procedure glInit();
begin
if not LoadGLTextures then
begin
exit;
end;
glEnable(GL_TEXTURE_2D);
glShadeModel(GL_SMOOTH);
glClearColor(0.0, 0.0, 0.0, 0.5);
glClearDepth(1.0);
glEnable(GL_DEPTH_TEST) ;
glDepthFunc(GL_LEQUAL);
glHint(GL_PERSPECTIVE_CORRECTION_HINT,GL_NICEST);
end;
Teksturowaniu poddana jest tylko przednia ściana ale jak mówiłem występuje ten błąd że tekstura jest czarno biała i trochę przechylona