Advertisement

Please help a new guy.

Started by September 25, 2002 11:21 AM
16 comments, last by LostBoy 22 years, 5 months ago
I don''t mean to be greedy, but while I''ve got all of your attention, does anyone know the other way of assigning a bitmap texture with mip-mapping ? From what I understand you can get around the 256*256 limitation on the bitmap you use, but I''m not quite sure how to use this. Also, what would be the correct way to introduce two or more BMP''s to use as textures ? For some reason when I try that, I end up with only the last BMP that I loaded as a texture, and the first one is discarded.

JC
Could you send sample code?

PM
PM Times change... Excuse my poor english!
Advertisement
PM has written a piece of code that can use different textures for different objects. See a few posts above.

But that's for rendering only.
For initialization, do this :
glBindTexture(GL_TEXTURE_2D, tex_id1);
load_texture_1();
glBindTexture(GL_TEXTURE_2D, tex_id2);
load_texture_2();

where tex_id1 and tex_id2 are integers that can be initialized with :
glGenTextures(1, &tex_id1);
glGenTextures(1, &tex_id2);

[edited by - vincoof on September 25, 2002 2:01:46 PM]
Thanks Vincoof, I almost understand that, but it seems like I am missing something. Sometimes I am thick headed.

PM, I already trashed the part of my code where I was trying to load 2 BMP's and use them as textures (I couldn't get it to work). And I can't remember how I was doing it(good because it was wrong).

Would you be so kind as to show me the most basic way of accomplishing this ? When I do it, I succeed in loading both bitmaps (textures 0 and 1), but only texture 1 makes it through the process. I'm droping the ball somewhere.

JC

[edited by - LostBoy on September 25, 2002 2:58:59 PM]
glBegin(GL_QUADS);

//Texture and quad coordinates
glTexCoord2f(0.0f, 1.0f); glVertex3f(-1.0f, 1.0f, 0.0f);
glTexCoord2f(1.0f, 1.0f); glVertex3f( 1.0f, 1.0f, 0.0f);
glTexCoord2f(1.0f, 0.0f); glVertex3f( 1.0f,-1.0f, 0.0f);
glTexCoord2f(0.0f, 0.0f); glVertex3f(-1.0f,-1.0f, 0.0f);
glDisable(GL_TEXTURE_2D);
glEnd(); *----- < Do I need this ?>-----------yes

glColor3f(1.0f,0.0f,0.0f);
gluSphere(quadratic,0.035f,32,32); glColor3f(1.0f,1.0f,1.0f);
glColor3f(1.0f,1.0f,1.0f);
glEnd(); -------------------------------------no
...GLuint tex1, tex2;...int LoadTextures(){    glEnable(GL_TEXUTRE_2D);    // Enable Texturing    ...    glGenTextures(1, &tex1);    // Generate Texture ID    glBindTexture(GL_TEXTURE_2D, tex1) // Bind the texture    LoadTex1();    // calls glTexImage2D  // Load it    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINER);  // Texture parameter    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINER);  // Texture parameter    glGenTextures(1, &tex2);    glBindTexture(GL_TEXTURE_2D, tex2)    LoadTex2();    // calls glTexImage2D    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINER);    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINER);    glDisable(GL_TEXUTRE_2D);}void Render(){    glEnable(GL_TEXTURE_2D)    glBindTexture(GL_TEXTURE_2D, tex1);    RenderObject1();    glBindTexture(GL_TEXTURE_2D, tex2);    RenderObject2();    glDisable(GL_TEXTURE_2D);}


Maybe there are errors, but I hope this will help you.

PM
PM Times change... Excuse my poor english!
Advertisement
Did it help???
PM Times change... Excuse my poor english!
Yes it did. Now I see the method, and where I made my mistake.

Thanks very much

BTW, do you know a practical approach to my other post (the one about bounding a semicircle). I am stuck on this one. To get an idea of what I''m talking about, imagine a 2D mini golf bitmap. It''s surface is green (solid green/no texture), and in some places it has rounded angles. It also has what looks like a street with a court at the end of it, so in other words you have a straight path with a semicircle at the end of it. I have got to come up with a practicle way to bound it''s diameter so that my ball can bounce off of it. The idea that I came up with is no good. It will be too much coding.

Please help if you can.

JC

This topic is closed to new replies.

Advertisement