Advertisement

(possible?) problem with glGenTextures in Delphi

Started by November 26, 2001 04:39 PM
11 comments, last by NaliXL 23 years, 2 months ago
Busy with a little own conversion of Marc Aart''s converion for Delphi of NeHe''s tutor no. 6. I''ve worked from lesson 1 to this one, and assured everything worked up to this lesson. Now I''m busy with the texturing, and I''ve literally copied and pasted the LoadGLTextures, glGenTextures and the glBindTexture procedures, as well as the code to create the cube and the code that enables texture-mapping as in Marc Aart''s conversion for Delphi. Only changed some names of var''s etc. Marc Aart''s converion works fine with me. But when I compile my own code and run it, the cube isn''t textured. I''ve been trying to debug the whole thing a for quite some time now, and discovered that everything seems to be OK, up to the glGenTextures statement in the LoadGLTextures procedure. I''ve made the following little code to test it : procedure TMainForm.LoadGLTextures; var TextureImage0: PTAUX_RGBIMAGERec; begin //blah - some code left out - texture[1] := texture[0]; //Made the texture-array somewhat bigger here. Make texture[1] equal texture[0] glGenTextures(1, texture[0]); glBindTexture(GL_TEXTURE_2D, texture[0]); // check if texture[0] is still the same, which I think it // shouldn''t be. This is where I discovered the error. if (texture[1] = texture[0]) then begin Application.Messagebox(''this box pops up on error'',''error'',MB_OK); end; end; I''ve verified that glGenTextures is actually executed. Has anyone got an idea what my problem could be? And a possible solution? Thank you VERY VERY much, since I''ve been busy with this one for quite a long time now, NaliXL.
Newbie programmers think programming is hard.Amature programmers think programming is easy.Professional programmers know programming is hard.
to load in x textures use:
glGenTextures(x, texture[0]);

also this:
texture[1] := texture[0];
makes little sense to me. doesnt seem to be the proper way to define how large the array is. I don''t know how to do this in delphi but in C arrays are initialized at the beginning of the program. All you''re doing is copying what is in index 0 to index 1. you shouldnt do that instead have glGenTextures put the data into those array elements.

so if you do:
glGenTextures(5, texture[0]);

that will load up textures into
texture[0],
texture[1],
texture[2],
texture[3] and finally,
texture[4]

glBindTexture(GL_TEXTURE_2D, texture[0]);
selects which texture will be applied to the next polygon created
Advertisement
Oh, I think you''re not quite getting what I''m trying to say here. I''ve enlarged the texture[] array somewhat. Then I''ve made texture[1] equal texture[0], in order to check if the statements :

glGenTextures(1, texture[0]);
glBindTexture(GL_TEXTURE_2D, texture[0]);


had any result, with the statenments :

if (texture[1] = texture[0]) then begin
Application.Messagebox(''this box pops up on error'',''error'',MB_OK);
end;

Thus, what I''m doing here is only some error checking, and since the messagebox does pop up when I load my program, I thought I could conclude out of that that something goes wrong with glGenTextures. That''s cause I understood that glGenTextures should change the contents of texture[0].

Hope I made this clear.

PS : can anyone tell me how to make such a white block of code in the forum? Typing it plain here only gets it messed up...
Newbie programmers think programming is hard.Amature programmers think programming is easy.Professional programmers know programming is hard.
ah I see, you''re right I wasn''t following what you were doing and too hastily replied.

to put up source code use:
[ source ]
...your source code here...
[ / source ]

without the spaces.

as for the texture problem you''re having, did you modify the loading code to load in a new texture? Other wise you''re just generating the same texture over again. also the //blah some code left out might have something to do with why its not generating a new texture into texture[0]
Hello there,

try

    glGenTextures(1,@Texture);  


if that doesnt work i''ll have a look at it when i get home

Mark.
Okay, thanks for helping. My code still doesn''t work though. The glGenTextures(1,@Texture) method didn''t work, got a compiler error. I''m not trying to load more than one texture or so, so that''s not the problem. I hope you can help me if you''ve seen the code. As it is now, it compiles under Delphi, but the texturing problem of course is still there.

U can dowl the source from http://home.hetnet.nl/~babipanghang/glframe.zip

The OpenGL source is in the myframe unit.

Thanks!
Newbie programmers think programming is hard.Amature programmers think programming is easy.Professional programmers know programming is hard.
Advertisement
Hi

I don''t think you can resize arrays in that way, texture is declared as array [0..0] of ... ,and not as dynamic array which you can resize by calling SetLength. so maybe Texture[1] has no meaning ?!

Micky
Maybe you have incorrect headers translation?

procedure glGenTextures (n: integer; textures: PCardinal); stdcall;

glGetTextures(1,@texture[0]);//!!!


Are you sure that the texture is in the right directory and that it''s the right size?

Just a thought



"To err is human, to really mess up requires a computer"
"To err is human, to really mess up requires a computer"
Okay guys, thanks again for all help, I appreciate it very much. I''ll get working on it as soon as I get some spare time. Even if it still doesn''t work, you''ve still been very helpful!
Newbie programmers think programming is hard.Amature programmers think programming is easy.Professional programmers know programming is hard.

This topic is closed to new replies.

Advertisement