I have written a program by starting with a window and waiting for the user to press any keys from keyboard to create a new window. (the existing window will not be destroyed)
My program can create the first window but after the user press the key, it seems no response. I have registered the keyboard function in the main function…but it still cant work.
How can this be done?
try posting some code
Hi !
I guess you are using GLUT then ?, it’s pretty difficult to answer what the problem is without having a look at the code. There are lot’s of examples out there, have a look at thoose and see if there is anything that do something similar to what you want to do.
Mikael
i pick up some code and post it here
#include <stdio.h>
#include <stdlib.h>
#include <windows.h>
#include <gl/gl.h>
#include <gl/glu.h>
#include <gl/glut.h>
void
KeyPressFunc(unsigned char key, int x, int y)
{
if(key == 66) // B-key
{
glutCreateSubWindow(0, 30, 30, 100, 100);
}
}
void main (int argc, char **argv)
{
glutInit (&argc, argv);
glutInitDisplayMode (GLUT_RGB | GLUT_DOUBLE);
glutInitWindowPosition (0, 0);
glutInitWindowSize (300, 300);
glutCreateWindow (“OpenGL”);
glutReshapeFunc(myReshape);
glutDisplayFunc (Display);
glutKeyboardFunc(KeyPressFunc);
glutMainLoop ();
}
GLUT: Warning in main: The following is a new check for GLUT 3.0; update your co
de.
GLUT: Fatal Error in main: redisplay needed for window 2, but no display callbac
k.
when run the program then these errors appear
GLUT: Warning in main: The following is a new check for GLUT 3.0; update your co
de.
GLUT: Fatal Error in main: redisplay needed for window 2, but no display callbac
k.
these errors appear when press a B-key
GLUT: Warning in main: The following is a new check for GLUT 3.0; update your co
de.
GLUT: Fatal Error in main: redisplay needed for window 2, but no display callbac
k.
Hi !
If you have a look at the documentation for the redisplay callback function registration you find the note “Will register a callback function for the current window”, so when you create a new window there is no callback function for that window, you must do that when you have created the (second) window also.
Mikael
hi, Mikael
where can i find the documentation for the redisplay callback function registration “Will register a callback function for the current window” ?
hi, Mikael
can you post some code that show how to register the second window?
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB);
glutInitWindowSize(flir.header.width, flir.header.height);
glutInitWindowPosition(200, 200);
flir_win = glutCreateWindow(“Tabu Search”);
glutDisplayFunc(MyDisplayFLIR);
glutReshapeFunc(MyReshape);
glutMouseFunc(MyMouse);
MyInit();
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB);
glutInitWindowSize(flir.header.width, flir.header.height);
glutInitWindowPosition(200, 200);
neighbour_win = glutCreateWindow("Neighbour");
glutDisplayFunc(MyDisplayNeighbour);
glutReshapeFunc(MyReshape);
MyInit();
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB);
glutInitWindowSize(flir.header.width, flir.header.height);
glutInitWindowPosition(200, 200);
best_win = glutCreateWindow("Best");
glutDisplayFunc(MyDisplayBest);
glutReshapeFunc(MyReshape);
MyInitBest();
glutMainLoop();
hi Gvain
thx for ur code