libpng with OpenGL : return what?

Jones
Unregistered
 
Post: #1
I'm trying to learn how to use libpng with OpenGL, using this O'reilly tutorial:

http://www.macdevcenter.com/pub/a/mac/20...tml?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.
Quote this message in a reply
Member
Posts: 269
Joined: 2005.04
Post: #2
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.
Quote this message in a reply
Jones
Unregistered
 
Post: #3
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*
Quote this message in a reply
Jones
Unregistered
 
Post: #4
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.
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  libPng And Memory Access Violations Jaden 12 12,505 Sep 4, 2013 04:50 AM
Last Post: miye
  Xcode and glfw, the return of cryptic errors BarneyBear 6 6,495 Apr 19, 2008 04:35 AM
Last Post: BarneyBear
  libpng loading junk at bottom of my OpenGL textures...? BinarySpike 6 6,213 Apr 19, 2007 12:20 PM
Last Post: BinarySpike
  libpng transparency problem wyrmmage 3 5,437 Mar 1, 2007 05:53 PM
Last Post: OneSadCookie
  Trouble writing PNGs with 16 bits per channel using libpng flash 2 3,892 Aug 28, 2006 11:01 AM
Last Post: flash