Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

TheShadow

glPNG trouble

This topic is 5544 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

Im trying to open two textures with glPNG library but i kind of cant read both... just one...
  
GLuint BindPNGTexture(char *filename)
{
	pngInfo info;
	if(!pngLoad(filename,PNG_NOMIPMAP, PNG_SOLID, &info))
	{
		MessageBox(NULL, "Error Loading PNG File ", "PNG ERROR", NULL);
		return 0;
	}
	else
	{
		return pngBind(filename, PNG_NOMIPMAP, PNG_ALPHA, &info, GL_CLAMP, GL_NEAREST, GL_NEAREST);
	}

}


int load_gl_textures()
{



	
	texture[0] = BindPNGTexture("tile0.png");
	texture[1] = BindPNGTexture("player.png");
	glBindTexture(GL_TEXTURE_2D, texture[0]);


  return(1);
}
  
With this code i can read just the second texture i load...

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
Here''s some information that you didn''t bother to get, that you''d need to post to get a good answer:

1) how do you tell that you "can only load the second texture" ? What happens?

2) what are the values of texture[0] and texture[1] after load, but before the call to glBindTexture()?

I''m assuming you know how to use a debugger?

Share this post


Link to post
Share on other sites
I was hoping a smart person would have enought information with what i give to tell me...

of course im using openGL... u know how to use it? im not dumb not to know my texture array is an GLuint type... and that it has no value before i give it the information about the texture... any more smart people out there?

Share this post


Link to post
Share on other sites
Your calls are correct (just looked in the glPNG doc to make sure). You'll have to do some debugging, it's possible there is a bug in glPNG or the file simply doesn't load correctly. Do as the AP says and answer his questions, it'll help us help you.

EDIT:

(just read the glPNG docs some more)

Why are you calling Load and then Bind? A single call to Bind would be sufficient, it loads the file automatically.

[edited by - JuNC on April 18, 2003 5:32:29 AM]

Share this post


Link to post
Share on other sites
Look at this


    
#include "gl\glpng.h"
#pragma comment (lib, "glpng.lib")

GLuint texture[100];





GLuint BindPNGTexture(char *filename)
{
pngInfo info;
if(!pngLoad(filename,PNG_NOMIPMAP, PNG_SOLID, &info))
{
MessageBox(NULL, "Error Loading File", filename, NULL);
return 0;
}
else
{
return pngBind(filename, PNG_NOMIPMAP, PNG_ALPHA, &info, GL_CLAMP, GL_NEAREST, GL_NEAREST);
}

}


void load_gl_textures()
{



texture[0] = BindPNGTexture("ship_R.png");
texture[1] = BindPNGTexture("tile0.png");


}





What im doing here is have two quads ok?

One with texture[0] and the other one with texture[1]
What happens is that texture[0] = texture[1]... and this is really strange...

[edited by - TheShadow on April 18, 2003 5:11:52 PM]

Share this post


Link to post
Share on other sites
Are the files you are loading power-of-two? What format are they? You say texture[0]=texture[1], is either of them a valid GL texture? Have you tried checking the returns from glBind?

How are you finding out that texture[0]=texture[1]?

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

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

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!