Jump to content
  • Advertisement
Sign in to follow this  
bladetnt

A Few Texture Problems

This topic is 4419 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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
Advertisement
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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!