Skip to main content
gamedev.net
🔒 Locked

Help, first program... first problem!

Started by KappaMic Oct 16, 2000 at 2:32 PM 5 replies 500+ views
Original Post
KappaMic
KappaMic
I whant to learn... my first prg... A simple bitmapped quad... But it display only a white quad... where''s the problem??? Here''s my little program... ---------------------------- function DrawGLScene():bool; // Here''s Where We Do All The Drawing var prova: GLuint; begin glClear(GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT); glLoadIdentity(); // Reset The View prova:=LoadGLTexture(''sfondo.bmp''); //this bitmap exist!!!! glTranslatef(-1.5,0.0,-6.0); glDisable(GL_DEPTH_TEST); glBindTexture(GL_TEXTURE_2D, prova); // sfondo glBegin(GL_QUADS); glNormal3f(-2.0, 0.0, 0.0); glTexCoord2f(0.0, 0.0); glVertex3f(-3.0, -3.0, -3.0); glTexCoord2f(3.0, 0.0); glVertex3f(-3.0, 3.0, -3.0); glTexCoord2f(3.0, 3.0); glVertex3f( 3.0, 3.0, -3.0); //1 glTexCoord2f(0.0, 3.0); glVertex3f( 3.0, -3.0, -3.0); glEnd(); DrawGLScene:=true; // Everything Went OK end; Here are my functions: --------------------- function LoadBMP(Filename : string) : PTAUX_RGBImageRec; begin if Filename = '''' then // Make Sure A Filename Was Given begin result := nil; // If Not Return NULL exit; end; if fileexists(FileName) then // Does The File Exist? begin result := auxDIBImageLoadA(pchar(Filename)); // Load The Bitmap And Return A Pointer exit; end; loadBMP := nil; // If Load Failed Return NULL end; function LoadGLTexture(Filename : string) : GLuint; var texture1: PTAUX_RGBImageRec; texture: GLuint; begin texture1 := LoadBMP(PChar(Filename)); glGenTextures(1, texture); glBindTexture(GL_TEXTURE_2D, texture); glTexImage2D(GL_TEXTURE_2D, 0, 3, texture1.sizeX, texture1.sizeY, 0, GL_RGB, GL_UNSIGNED_BYTE, texture1.data); glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_NEAREST); glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_NEAREST); result := texture; end;
wolfman8k
wolfman8k
Check NeHe''s 6th tutorial. You might want to try getting rid of that "Normal3f" function call. I don''t see why you need it.
KappaMic
KappaMic
Sorry... didn''t understand... what do you mean?
I''ve tryed to past the entire "drawing" routine too...doesn''t work....


function DrawGLScene():bool; // Here''s Where We Do All The Drawing

begin

glClear(GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT);
glLoadIdentity(); // Reset The View
prova:=LoadGLTexture(''sfondo.bmp'',prova_PTAUX_RGBImageRec);
glTranslatef(-1.5,0.0,-6.0);
glDisable(GL_DEPTH_TEST);
glBindTexture(GL_TEXTURE_2D, prova); // sfondo
glBegin(GL_QUADS);
// Front Face
glNormal3f( 0.0, 0.0, 1.0);
glTexCoord2f(0.0, 0.0); glVertex3f(-1.0, -1.0, 1.0);
glTexCoord2f(1.0, 0.0); glVertex3f( 1.0, -1.0, 1.0);
glTexCoord2f(1.0, 1.0); glVertex3f( 1.0, 1.0, 1.0);
glTexCoord2f(0.0, 1.0); glVertex3f(-1.0, 1.0, 1.0);
// Back Face
glNormal3f( 0.0, 0.0,-1.0);
glTexCoord2f(1.0, 0.0); glVertex3f(-1.0, -1.0, -1.0);
glTexCoord2f(1.0, 1.0); glVertex3f(-1.0, 1.0, -1.0);
glTexCoord2f(0.0, 1.0); glVertex3f( 1.0, 1.0, -1.0);
glTexCoord2f(0.0, 0.0); glVertex3f( 1.0, -1.0, -1.0);
// Top Face
glNormal3f( 0.0, 1.0, 0.0);
glTexCoord2f(0.0, 1.0); glVertex3f(-1.0, 1.0, -1.0);
glTexCoord2f(0.0, 0.0); glVertex3f(-1.0, 1.0, 1.0);
glTexCoord2f(1.0, 0.0); glVertex3f( 1.0, 1.0, 1.0);
glTexCoord2f(1.0, 1.0); glVertex3f( 1.0, 1.0, -1.0);
// Bottom Face
glNormal3f( 0.0,-1.0, 0.0);
glTexCoord2f(1.0, 1.0); glVertex3f(-1.0, -1.0, -1.0);
glTexCoord2f(0.0, 1.0); glVertex3f( 1.0, -1.0, -1.0);
glTexCoord2f(0.0, 0.0); glVertex3f( 1.0, -1.0, 1.0);
glTexCoord2f(1.0, 0.0); glVertex3f(-1.0, -1.0, 1.0);
// Right face
glNormal3f( 1.0, 0.0, 0.0);
glTexCoord2f(1.0, 0.0); glVertex3f( 1.0, -1.0, -1.0);
glTexCoord2f(1.0, 1.0); glVertex3f( 1.0, 1.0, -1.0);
glTexCoord2f(0.0, 1.0); glVertex3f( 1.0, 1.0, 1.0);
glTexCoord2f(0.0, 0.0); glVertex3f( 1.0, -1.0, 1.0);
// Left Face
glNormal3f(-1.0, 0.0, 0.0);
glTexCoord2f(0.0, 0.0); glVertex3f(-1.0, -1.0, -1.0);
glTexCoord2f(1.0, 0.0); glVertex3f(-1.0, -1.0, 1.0);
glTexCoord2f(1.0, 1.0); glVertex3f(-1.0, 1.0, 1.0);
glTexCoord2f(0.0, 1.0); glVertex3f(-1.0, 1.0, -1.0);
glEnd();

DrawGLScene:=true; // Everything Went OK
end;


KappaMic
KappaMic
Simply forgot....

glEnable(GL_TEXTURE_2D);

avianRR
avianRR
Just a thought! Do you really have your load textures in your drawing function??? If so may I suggest you move them to the initialzation function!!! It''ll help performance!
------------------------------Piggies, I need more piggies![pig][pig][pig][pig][pig][pig]------------------------------Do not invoke the wrath of the Irken elite. [flaming]
KappaMic
KappaMic
yeah... i''ve just fixed my pgm... tnks anyway...

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.