
ANother noob problem: More than one texture
Posted Friday, 8 May, 2009 - 10:47 by Symkortem inHi Communety!
I have a little noob Problem.
Sorry for that, but iam still learning.
In my Programm i want to draw many Quads, and every quad should get another bitmap as texture.
So i tried to change the code from "http://www.opentk.com/node/791" for my needs.
But all quads have the same texture.
Can anybody help me pls, how can i assign different textures to the quads?
best regards
Symi


Comments
Re: ANother noob problem: More than one texture
When loading textures, keep every created textures ID in memory and
when rendering quads, change (bind) before rendering the wanted texture id:
GL.BindTexture(TextureTarget.Texture2D, textureID);
Re: ANother noob problem: More than one texture
OK.
First of all i load the bitmap.
bitmap = new Bitmap(@"Resources\Düne.JPG");than i upload the texture
than i want to load/upload the second bitmap/texture.
same procedure.
after that, i want to draw 2 quads, which i have stored in a list.
in itemindex is stored, whether it is the first, or second texture
the first quad has itemindex = 0 and the 2nd has itemindex = 1
but now i have 2 quads with the same texture. and always the last one i have uploaded.
Re: ANother noob problem: More than one texture
BindTexture should be called before Begin.
Re: ANother noob problem: More than one texture
I guess it's a personal preference, but I like to keep all my OpenGL texture/VBO/buffer/FBO handles in separate instances of fully OO classes. That way I might load a .png of a cow and a .png of a sheep into 2 Texture2D objects called, respecively, "cow" and "sheep", with nested draw methods (
cow.Draw();, or maybegame.RenderFrame += sheep.Draw;).Edit: corrected my terminology. Changed "classes" to "objects".
Re: ANother noob problem: More than one texture
Thats. That hint with the OO class was great...
now i just have to rewrite my game class.
thanks alot