1

I have a P6 PPM image file format.

It stores each value as a byte.

As I understand I need to read it into a char * array, and feed it to OpenGL, but I'm not sure how to go about reading it in.

will something like this work?

for (i number of pixels to read)
char toAdd;
image.read(&toAdd, 1); 
charArray[i] = toAdd

The main problem seems to be that it isn't reading the file format properly. And I don't quite understand why.

user1066113
  • 889
  • 3
  • 12
  • 19

1 Answers1

0

Per OpenGL you do not need to have it in a char array. This is rather just one of many options available with OpenGL. If you google for "OpenGL texture example" you'll find tons of examples out there:

Whether your example works depends on how your file type works.

On This page here the author gives anoter example for texture mapping. He claim that his code is capable of reading PPM file format. There is also another SO page that goes into texture mapping.

Community
  • 1
  • 1