Sign in to follow this  
bladetnt

A Few Texture Problems

Recommended Posts

I use the following code to lay textures to floor for (int m = -9; m < 9; m++) { for (int k = -9; k < 9; k++) { Gl.glPushMatrix(); Gl.glTranslated(-2 + 2 * k, 0, 8+2*m); Gl.glScaled(1, 0.1, 1); Draw2(); Gl.glPopMatrix(); } } void Draw2() { Gl.glBegin(Gl.GL_QUADS); Gl.glTexCoord2f(1.0f, 1.0f); Gl.glVertex3f(1.0f, 1.0f, -1.0f); Gl.glTexCoord2f(0.0f, 1.0f); Gl.glVertex3f(-1.0f, 1.0f, -1.0f); Gl.glTexCoord2f(0.0f, 0.0f); Gl.glVertex3f(-1.0f, 1.0f, 1.0f); Gl.glTexCoord2f(1.0f, 0.0f); Gl.glVertex3f(1.0f, 1.0f, 1.0f); Gl.glEnd(); } Code is fine with for from -9 to 9 but if the number increasas program gets too slow. My graphics card is Ati radeon mobility x300. Can anyone suggest a better(faster)way for using textures in the code. Also the same code does not work with nvidia mx440 garphics card. Program runs but can't see texture objects. Does anyone have an idea?

Share this post


Link to post
Share on other sites
Use display lists.

Display lists work just like Immediate calls but you can't change them afterwards.

After you've set up you opengl context and whatnot run Draw2 but change the code to:

int listId = glGenLists (1) // Generate display list id

glNewList listId, glCompile

//
Code for drawing whatever (Exact code from your previous Draw2
//

glEndList

Then where you have Draw2() in your for loops just have

glCallList listId

That way the quad as already been stored in the GFX card memory and is therefore very fast. Only downside of Display Lists is that you can't edit them afterwards.

Hope this helps

P.S. And don't forget your glBindTexture... call before glBegin
P.P.S Since I program in VB this code might not be exactly how you need it

Share this post


Link to post
Share on other sites
i think he makes texture tile, try this :

Gl.glBegin(Gl.GL_QUADS);
Gl.glTexCoord2f(18.0f, 18.0f);
Gl.glVertex3f(1.0f, 1.0f, -1.0f);
Gl.glTexCoord2f(0.0f, 18.0f);
Gl.glVertex3f(-1.0f, 1.0f, -1.0f);
Gl.glTexCoord2f(0.0f, 0.0f);
Gl.glVertex3f(-1.0f, 1.0f, 1.0f);
Gl.glTexCoord2f(18.0f, 0.0f);
Gl.glVertex3f(1.0f, 1.0f, 1.0f);
Gl.glEnd();

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this