iDevGames Forums
libpng with OpenGL : return what? - Printable Version

+- iDevGames Forums (http://www.idevgames.com/forums)
+-- Forum: Development Zone (/forum-3.html)
+--- Forum: Graphics & Audio Programming (/forum-9.html)
+--- Thread: libpng with OpenGL : return what? (/thread-4236.html)



libpng with OpenGL : return what? - Jones - May 27, 2006 03:49 PM

I'm trying to learn how to use libpng with OpenGL, using this O'reilly tutorial:

http://www.macdevcenter.com/pub/a/mac/2005/10/14/texture-maps.html?page=3

Unfortunatly, I'm not quite sure how his actual image data gets from his libpng structs to his GL texture. What should my libpng load func return? By default, I set it to GLint, just to start, as I have no idea what it should return. And how is it that he does not even properly declare some of his variables like "width" "height" and "image_data" do they just pop out of nowhere? Rolleyes

Argh this is annoying.

Thanks.


libpng with OpenGL : return what? - Bachus - May 27, 2006 09:25 PM

His code loads the image data into "char *image;" which is passed to glTexImage2D. Follow *image in the PNG driver code and **image_data_ptr in the PNG loader code.


libpng with OpenGL : return what? - Jones - May 27, 2006 09:51 PM

Bachus Wrote:His code loads the image data into "char *image;" which is passed to glTexImage2D. Follow *image in the PNG driver code and **image_data_ptr in the PNG loader code.

Ok, I now know the function has four arguments and is of type char. But nothing else. Mad Does the function get the data to a format that's GL ready? And it assigns nothing to the "image" argument, so I'm not sure what it's for. Annoyed Does the GL "texture preparation" function automatically know which png buffer to get it from? Does pnglib handle that?

Shock BlinkHuhCry

*confuzled*


libpng with OpenGL : return what? - Jones - May 28, 2006 07:32 AM

Ah wait, I think I get it now. By going through is code and finding all the illegal (undeclared) variables, I think I know what makes up the arguments of the function.

I wish he'd stop naming his function prototypes after other variables. If you're gonna do that, add a tag to indentify to which function it belongs.