/* attempt to deal with prototype, bootstrap, jquery conflicts */ /* for dropdown menus */

Jump to content

Image of the Day

Today's #ScreenshotSaturday features Face Your Fears from Turtle Roc ... #virtualrealityshop #mobilevr #vrshop https://t.co/3qhSNAVNOZ
IOTD | Top Screenshots

The latest, straight to your Inbox.

Subscribe to GameDev.net's newsletters to receive the latest updates and exclusive content.


Sign up now

Lesson 06 : Problem when using u, v superior to 1.0f

4: Adsense

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.


  • You cannot reply to this topic
No replies to this topic

#1 Cydriic   Members   

174
Like
0Likes
Like

Posted 22 June 2014 - 11:54 AM

Hi Everyone,

 

I'm having this problem with using U, Vs on my Textures, using the SOIL Library.

If I pass a u or v superior to 1.0f, the texture will only show fully at u:0.0f and v:0,0f scaled down correctly, but all the other positions will be bugged out and stretched...

 

When using Glaux, I didn't have that problem, but ever since switching to SOIL, does that.

 

 

Here is my code for loading my textures:

 

void LoadTextures()

{

 

//LOAD TEXTURES
 
//GRASS TEXTURE TEXTURE 0
    texture[0] = SOIL_load_OGL_texture("Data/Grass00.bmp", SOIL_LOAD_AUTO, SOIL_CREATE_NEW_ID, SOIL_FLAG_INVERT_Y);
 
    if(texture[0] == 0)
        return false;
 
    // Typical Texture Generation Using Data From The Bitmap
    glBindTexture(GL_TEXTURE_2D, texture[0]);
    glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
    glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
 
 
//STONEWALL TEXTURE 1
    texture[1] = SOIL_load_OGL_texture("Data/StoneWall00.bmp", SOIL_LOAD_AUTO, SOIL_CREATE_NEW_ID, SOIL_FLAG_INVERT_Y);
 
    if(texture[1] == 0)
        return false;
 
    // Typical Texture Generation Using Data From The Bitmap
    glBindTexture(GL_TEXTURE_2D, texture[1]);
    glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
    glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
 
//STONEWALLDOOR TEXTURE 2
    texture[2] = SOIL_load_OGL_texture("Data/WoodStoneDoor00.bmp", SOIL_LOAD_AUTO, SOIL_CREATE_NEW_ID, SOIL_FLAG_INVERT_Y);
 
    if(texture[2] == 0)
        return false;
 
    // Typical Texture Generation Using Data From The Bitmap
    glBindTexture(GL_TEXTURE_2D, texture[2]);
    glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
    glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
 
return true;
 
}
 
And Here is my code for Drawing an Object:
 
void CHouse::Draw(GLuint texture)
{
 
glBindTexture(GL_TEXTURE_2D, texture);
 
glBegin(GL_TRIANGLES);
glNormal3f( 0.0f, 0.0f, 1.0f);
glTexCoord2f(m_u1,m_v1); glVertex3f(m_x1,m_y1,m_z2);
glTexCoord2f(m_u2,m_v1); glVertex3f(m_x2,m_y1,m_z2);
glTexCoord2f(m_u2,m_v2); glVertex3f(m_x2,m_y2,m_z2);
glEnd();
 
glBindTexture(GL_TEXTURE_2D, texture);
 
glBegin(GL_TRIANGLES);
glNormal3f( 0.0f, 0.0f, 1.0f);
glTexCoord2f(m_u2,m_v2); glVertex3f(m_x2,m_y2,m_z2);
glTexCoord2f(m_u1,m_v2); glVertex3f(m_x1,m_y2,m_z2);
glTexCoord2f(m_u1,m_v1); glVertex3f(m_x1,m_y1,m_z2);
glEnd();
 
glBindTexture(GL_TEXTURE_2D, texture);
 
glBegin(GL_TRIANGLES);
glNormal3f( 0.0f, 0.0f, 1.0f);
glTexCoord2f(m_u1,m_v1); glVertex3f(m_x1,m_y1,m_z1);
glTexCoord2f(m_u2,m_v1); glVertex3f(m_x2,m_y1,m_z1);
glTexCoord2f(m_u2,m_v2); glVertex3f(m_x2,m_y2,m_z1);
glEnd();
 
glBindTexture(GL_TEXTURE_2D, texture);
 
glBegin(GL_TRIANGLES);
glNormal3f( 0.0f, 0.0f, 1.0f);
glTexCoord2f(m_u2,m_v2); glVertex3f(m_x2,m_y2,m_z1);
glTexCoord2f(m_u1,m_v2); glVertex3f(m_x1,m_y2,m_z1);
glTexCoord2f(m_u1,m_v1); glVertex3f(m_x1,m_y1,m_z1);
glEnd();
 
glBindTexture(GL_TEXTURE_2D, texture);
 
glBegin(GL_TRIANGLES);
glNormal3f( 0.0f, 0.0f, 1.0f);
glTexCoord2f(m_u1,m_v1); glVertex3f(m_x2,m_y1,m_z2);
glTexCoord2f(m_u2,m_v1); glVertex3f(m_x2,m_y1,m_z1);
glTexCoord2f(m_u2,m_v2); glVertex3f(m_x2,m_y2,m_z1);
glEnd();
 
glBindTexture(GL_TEXTURE_2D, texture);
 
glBegin(GL_TRIANGLES);
glNormal3f( 0.0f, 0.0f, 1.0f);
glTexCoord2f(m_u2,m_v2); glVertex3f(m_x2,m_y2,m_z1);
glTexCoord2f(m_u1,m_v2); glVertex3f(m_x2,m_y2,m_z2);
glTexCoord2f(m_u1,m_v1); glVertex3f(m_x2,m_y1,m_z2);
glEnd();
 
glBindTexture(GL_TEXTURE_2D, texture);
 
glBegin(GL_TRIANGLES);
glNormal3f( 0.0f, 0.0f, 1.0f);
glTexCoord2f(m_u1,m_v1); glVertex3f(m_x1,m_y1,m_z2);
glTexCoord2f(m_u2,m_v1); glVertex3f(m_x1,m_y1,m_z1);
glTexCoord2f(m_u2,m_v2); glVertex3f(m_x1,m_y2,m_z1);
glEnd();
 
glBindTexture(GL_TEXTURE_2D, texture);
 
glBegin(GL_TRIANGLES);
glNormal3f( 0.0f, 0.0f, 1.0f);
glTexCoord2f(m_u2,m_v2); glVertex3f(m_x1,m_y2,m_z1);
glTexCoord2f(m_u1,m_v2); glVertex3f(m_x1,m_y2,m_z2);
glTexCoord2f(m_u1,m_v1); glVertex3f(m_x1,m_y1,m_z2);
glEnd();
 
if(xtrans <= -(m_x1-0.2) && xtrans >= -(m_x2+0.2) && ztrans <= -(m_z1-0.2) && ztrans >= -(m_z2+0.2))
{
 
if(MoveForward)
{
xpos += 2*(float)sin(heading*piover180) * 0.05f;
zpos += 2*(float)cos(heading*piover180) * 0.05f;
}
 
if(MoveBackward)
{
xpos -= 2*(float)sin(heading*piover180) * 0.05f;
zpos -= 2*(float)cos(heading*piover180) * 0.05f;
}
 
}
 
m_Door->Draw(texture);
 
}
 

Thanks

 






Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.