I need to perform pixel manipulation from images in glut OpenGL (I know it's old, but I'm bound by many other reasons). I need to change the image several times while showing them at the same time as well. I'm trying to use key event to perform that. Also, I'm using SOIL library to load my image.
What I have tried:
This is why I've been implementing :
static void init(void);
static void mainLoop(void);
static void keyEvent( unsigned char key, int x, int y);
int main(int argc, char *argv[])
{
init();
image = SOIL_load_image("Images/img1.jpg", &width, &height, 0, SOIL_LOAD_RGBA);
if(image == NULL) exit(0);
argViewportSetImageSize(vp, width, height);
argViewportSetPixFormat(vp, AR_PIXEL_FORMAT_RGBA);
argViewportSetDispMode(vp, AR_GL_DISP_MODE_FIT_TO_VIEWPORT_KEEP_ACPECT_RATIO);
argSetKeyFunc(keyEvent);
glutIdleFunc(mainLoop);
glutMainLoop();
}
key event :
static void keyEvent( unsigned char key, int x, int y)
{
if( key == 'a' )
{image = SOIL_load_image("Images/img2.jpg", &width, &height, 0, SOIL_LOAD_RGBA);
if(image == NULL) exit(0);
printf("%d x %d\n", width, height);
genImages();
}
}
I notice how the key event works for any other command (manipulate pixel value for example), but doesn't work for changing image input. Is there any way I can achieve this ?