Multiple texturing issues.

Whether you're a newbie or an experienced programmer, any questions, help, or just talk of any language will be welcomed here.

Moderator: Coders of Rage

Post Reply
User avatar
MadPumpkin
Chaos Rift Maniac
Chaos Rift Maniac
Posts: 484
Joined: Fri Feb 13, 2009 4:48 pm
Current Project: Octopia
Favorite Gaming Platforms: PS1-3, Genesis, Dreamcast, SNES, PC
Programming Language of Choice: C/++,Java,Py,LUA,XML
Location: C:\\United States of America\Utah\West Valley City\Neighborhood\House\Computer Desk

Multiple texturing issues.

Post by MadPumpkin »

Having multitexturing issues. Been way to long since I've done this successfully...


Image Loading, uses SDL_Image and converts it to a GL texture, which works fine!!
BUT only with one texture.

Code: Select all

bool GL_LoadIMG(char *file)
{
    SDL_Surface *SDLTexture = LoadIMG(file);
    GLuint GLTexture;

	printf("\n");
    if(SDLTexture)
    {
		printf("OGL - Image loaded.\n");
        glGenTextures(1, &GLTexture);
        glBindTexture(GL_TEXTURE_2D, GLTexture);
        
		glTexImage2D(GL_TEXTURE_2D, 0, 3, SDLTexture->w, SDLTexture->h, 0, GL_BGRA_EXT, GL_UNSIGNED_BYTE, SDLTexture->pixels);

		glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);

        printf("OGL - Image optimized.\n");
        SDL_FreeSurface(SDLTexture);
    }
    else
    {
        printf("OGL - Image could not be loaded.\n");
		return false;
    }

    return true;
}
I believe it has something to do with the above, and this:

Code: Select all

menuTextures[1] = GL_LoadIMG("data\\textures\\homeicon.png");
printf("\n");
menuTextures[2] = GL_LoadIMG("data\\textures\\file.png");
printf("\n");
menuTextures[3] = GL_LoadIMG("data\\textures\\edit.png");
printf("\n");
menuTextures[4] = GL_LoadIMG("data\\textures\\mode.png");
printf("\n");
menuTextures[5] = GL_LoadIMG("data\\textures\\options.png");
printf("\n");
That's what loads the textures... well sort of. no matter what number I use in place of NUMBER it displays the last texture loaded:
glBindTexture(GL_TEXTURE_2D, menuTextures[NUMBER]);



EDIT: I take that back, depending on whether I put glBindTexture or GL_Begin first here: (I can access the first or last texture, but still none between)

Code: Select all

glBindTexture(GL_TEXTURE_2D, menuTextures[3]);
glBegin(GL_QUADS);
glTexCoord2f (0.0, 0.0);
glVertex3f (0.0, 0.0, 0.0);

glTexCoord2f (1.0, 0.0);
glVertex3f (50.0, 0.0, 0.0);

glTexCoord2f (1.0, 1.0);
glVertex3f (50.0, 50.0, 0.0);

glTexCoord2f (0.0, 1.0);
glVertex3f (0.0, 50.0, 0.0);
glEnd();
While Jesus equipped with angels, the Devil's equipped with cops
For God so loved the world that he blessed the thugs with rock
Image
Image
Image
qpHalcy0n
Respected Programmer
Respected Programmer
Posts: 387
Joined: Fri Dec 19, 2008 3:33 pm
Location: Dallas
Contact:

Re: Multiple texturing issues.

Post by qpHalcy0n »

Your load function is not returning the texture handle. It's returning true or false. You're then assigning this value to "menuTextures[x]" and attempting to bind either true or false as a texture object. :]
User avatar
MadPumpkin
Chaos Rift Maniac
Chaos Rift Maniac
Posts: 484
Joined: Fri Feb 13, 2009 4:48 pm
Current Project: Octopia
Favorite Gaming Platforms: PS1-3, Genesis, Dreamcast, SNES, PC
Programming Language of Choice: C/++,Java,Py,LUA,XML
Location: C:\\United States of America\Utah\West Valley City\Neighborhood\House\Computer Desk

Re: Multiple texturing issues.

Post by MadPumpkin »

I'm just the god of stupid as shit mistakes today, I don't know what I would do without you qp xD
While Jesus equipped with angels, the Devil's equipped with cops
For God so loved the world that he blessed the thugs with rock
Image
Image
Image
User avatar
GroundUpEngine
Chaos Rift Devotee
Chaos Rift Devotee
Posts: 835
Joined: Sun Nov 08, 2009 2:01 pm
Current Project: mixture
Favorite Gaming Platforms: PC
Programming Language of Choice: C++
Location: UK

Re: Multiple texturing issues.

Post by GroundUpEngine »

MadPumpkin wrote:I'm just the god of stupid as shit mistakes today, I don't know what I would do without you qp xD
Aha it happens... especially if you end up code till late at night like most programmers ;)
User avatar
MadPumpkin
Chaos Rift Maniac
Chaos Rift Maniac
Posts: 484
Joined: Fri Feb 13, 2009 4:48 pm
Current Project: Octopia
Favorite Gaming Platforms: PS1-3, Genesis, Dreamcast, SNES, PC
Programming Language of Choice: C/++,Java,Py,LUA,XML
Location: C:\\United States of America\Utah\West Valley City\Neighborhood\House\Computer Desk

Re: Multiple texturing issues.

Post by MadPumpkin »

GroundUpEngine wrote:
MadPumpkin wrote:I'm just the god of stupid as shit mistakes today, I don't know what I would do without you qp xD
Aha it happens... especially if you end up code till late at night like most programmers ;)
That's usually when I START coding xD
While Jesus equipped with angels, the Devil's equipped with cops
For God so loved the world that he blessed the thugs with rock
Image
Image
Image
Post Reply