If you really think it is raw pixel data, here is some simple openGL and GLUT code that just require you getting the pixel data loaded.
Code:
#include <GL/glut.h>
#include <iostream>
// Missing global image data
unsigned char *image = 0; // image pixel data
int imageWidth = 1; // image width
int imageHeight = 1; // image height
/**
*Sets up approriate viewport coordinates for 2D
*/
void reshape(int w, int h)
{
glViewport(0, 0, w, h);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0, w, h, 0, -1, 1);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}
/**
* display callback function
*/
void display(void){
glClear(GL_COLOR_BUFFER_BIT);
glDrawPixels(imageWidth, imageHeight, GL_RGB, GL_UNSIGNED_BYTE, image);
glFlush();
}
/**
* Main entry point
*/
int main(int argc, char *argv[]){
//TODO: READ IMAGE DATA
image = new unsigned char[0]; // Just so it doesn't segfaut when running with no image data
// Initialize glut
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
glutInitWindowSize(imageWidth, imageHeight);
glutInitWindowPosition(100,100);
glutCreateWindow("ImageLoading example");
glutDisplayFunc(display);
glutReshapeFunc(reshape);
//for GL speed-ups
glDisable(GL_DEPTH_TEST);
glDisable(GL_ALPHA_TEST);
// Override OpenGl's 4 byte boundary default
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
glutMainLoop(); // Give control to glut
exit(0);
}
To compile
All that you have to do is set the following values.
unsigned char *image,
int imageWidth,
int imageHeight,
Bookmarks