1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
| #include <cstdlib>
#include <iostream>
#include <windows.h>
#include <GL/gl.h>
#include <GL/glu.h>
#include "IL/il.h"
using namespace std;
int main(int argc, char *argv[])
{
int i=0;
while ( i != 2 ){
printf("2 pour exit\n");
scanf(" %d",&i);
if ( i == 1 ){
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0, 1024, 0, 768, -1, 1);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
int hauteur= 768;
int largeur= 1024;
unsigned char * data = new unsigned char[3*largeur*hauteur];
glReadPixels(0, 0, largeur, hauteur, GL_RGB, GL_UNSIGNED_BYTE, data);
ilInit();
ilEnable(IL_ORIGIN_SET);
ilOriginFunc(IL_ORIGIN_UPPER_LEFT);
ILuint id;
ilGenImages(1, &id);
ilBindImage(id);
ilTexImage(1024, 768, 1, 3, IL_RGB, IL_UNSIGNED_BYTE, data);
ilSaveImage("C:\\Documents and Settings\\home\\Bureau\\testimagecopy.jpg");
}
}
system("PAUSE");
return EXIT_SUCCESS;
} |
Partager