Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game. |
Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
 |
12-02-2023, 12:11 PM
|
#1
|
Member
Registered: Aug 2013
Distribution: Debian, Ubuntu
Posts: 271
Rep: 
|
display callback fails after dist upgrade
william@geeves:~/projects/gnutran$ uname -a
Linux geeves 6.1.0-13-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.55-1 (2023-09-29) x86_64 GNU/Linux
libglut-dev 3.4.0-1
I tried to run a program that used to run perfectly, and received the error:
./gnutran: error while loading shared libraries: libglut.so.3: cannot open shared object file: No such file or directory
So I recompiled the program, ran it and got:
freeglut (./gnutran): ERROR: No display callback registered for window 2
Subject code:
Code:
glutInit(&argc,argv);
glutInitDisplayMode (GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
// glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB);
glutInitWindowSize(WindowWidth, WindowHeight);
glutInitWindowPosition(100, 100);
mainWindow = glutCreateWindow(argv[1]);
glutReshapeFunc(reshape);
glutInitWindowSize(TWindowWidth, TWindowHeight);
glutInitWindowPosition(800, 200);
textWindow = glutCreateWindow("textbox");
glutReshapeFunc(reshapeText);
glutSetWindow(mainWindow);
GLenum err = glewInit();
if (GLEW_OK != err){
/* Problem: glewInit failed, something is seriously wrong. */
fprintf(stderr, "Error: %s\n", glewGetErrorString(err));
}
init();
glutDisplayFunc(display);
glutDisplayFunc(displayText);
Presumably it does not like something about
Code:
glutDisplayFunc(displayText)
Can someone give me a clue?
|
|
|
12-04-2023, 03:03 PM
|
#3
|
Member
Registered: Aug 2013
Distribution: Debian, Ubuntu
Posts: 271
Original Poster
Rep: 
|
Verifiable example:
Note that lines 63 - 66, 69 (window 2) are commented out. The result is similar to a "Hello World", and displays window1.
If instead I comment out lines 58 - 61, 68 (window 1) and recompile, window2 is displayed.
If none of the code is commented out, the result is the error message:
Quote:
freeglut (./reshape_test): ERROR: No display callback registered for window 1
|
Code:
// reshape_test.c
// compile as gcc reshape_test.c -o reshape_test -lglut -lGLEW -lGL
#include <GL/glut.h>
int firstWindow, secondWindow;
void display1(){
glutSetWindow(firstWindow);
glClearColor(0.0, 0.0, 0.0, 0.0);
glClear(GL_COLOR_BUFFER_BIT);
glLoadIdentity();
glColor3f(0.0, 1.0, 0.0);
glBegin(GL_POLYGON);
glVertex3f(0.0, 0.0, 0.0);
glVertex3f(0.5, 0.0, 0.0);
glVertex3f(0.5, 0.5, 0.0);
glVertex3f(0.0, 0.5, 0.0);
glEnd();
glFlush();
glutSwapBuffers();
}
void display2(){
glutSetWindow(secondWindow);
glClearColor(0.0, 0.0, 0.0, 0.0);
glClear(GL_COLOR_BUFFER_BIT);
glLoadIdentity();
glColor3f(1.0, 0.0, 0.0);
glBegin(GL_POLYGON);
glVertex3f(0.0, 0.0, 0.0);
glVertex3f(0.5, 0.0, 0.0);
glVertex3f(0.5, 0.5, 0.0);
glVertex3f(0.0, 0.5, 0.0);
glEnd();
glutSwapBuffers();
glFlush();
}
void reshape1(int w, int h){
glutSetWindow(firstWindow);
glViewport(0, 0, (GLsizei) w, (GLsizei) h);
display1();
}
void reshape2(int w, int h){
glutSetWindow(secondWindow);
glViewport(0, 0, (GLsizei) w, (GLsizei) h);
display2();
}
int main(int argc, char* argv[]){
glutInit(&argc,argv);
glutInitDisplayMode (GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
glutInitWindowSize(300,100);
glutInitWindowPosition(100, 100);
firstWindow = glutCreateWindow("1st_window");
glutReshapeFunc(reshape1);
/* glutInitWindowSize(300,100);
glutInitWindowPosition(600, 100);
secondWindow = glutCreateWindow("2nd_window");
glutReshapeFunc(reshape2);*/
glutDisplayFunc(display1);
// glutDisplayFunc(display2);
glutMainLoop();
return 0;
}
|
|
|
12-04-2023, 07:54 PM
|
#4
|
Senior Member
Registered: Dec 2010
Location: California, USA
Distribution: I run my own OS
Posts: 1,058
|
The order matters.
You need to create the first window and set its reshape and display callbacks, and then create the second window and set its reshape and display callbacks.
Ed
Code:
// reshape_test.c
// compile as gcc reshape_test.c -o reshape_test -lglut -lGLEW -lGL
#include <GL/glut.h>
int firstWindow, secondWindow;
void display1(){
glutSetWindow(firstWindow);
glClearColor(0.0, 0.0, 0.0, 0.0);
glClear(GL_COLOR_BUFFER_BIT);
glLoadIdentity();
glColor3f(0.0, 1.0, 0.0);
glBegin(GL_POLYGON);
glVertex3f(0.0, 0.0, 0.0);
glVertex3f(0.5, 0.0, 0.0);
glVertex3f(0.5, 0.5, 0.0);
glVertex3f(0.0, 0.5, 0.0);
glEnd();
glFlush();
glutSwapBuffers();
}
void display2(){
glutSetWindow(secondWindow);
glClearColor(0.0, 0.0, 0.0, 0.0);
glClear(GL_COLOR_BUFFER_BIT);
glLoadIdentity();
glColor3f(1.0, 0.0, 0.0);
glBegin(GL_POLYGON);
glVertex3f(0.0, 0.0, 0.0);
glVertex3f(0.5, 0.0, 0.0);
glVertex3f(0.5, 0.5, 0.0);
glVertex3f(0.0, 0.5, 0.0);
glEnd();
glutSwapBuffers();
glFlush();
}
void reshape1(int w, int h){
glutSetWindow(firstWindow);
glViewport(0, 0, (GLsizei) w, (GLsizei) h);
display1();
}
void reshape2(int w, int h){
glutSetWindow(secondWindow);
glViewport(0, 0, (GLsizei) w, (GLsizei) h);
display2();
}
int main(int argc, char* argv[]){
glutInit(&argc,argv);
glutInitDisplayMode (GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
glutInitWindowSize(300,100);
glutInitWindowPosition(100, 100);
firstWindow = glutCreateWindow("1st_window");
glutReshapeFunc(reshape1);
glutDisplayFunc(display1);
glutInitWindowSize(300,100);
glutInitWindowPosition(600, 100);
secondWindow = glutCreateWindow("2nd_window");
glutReshapeFunc(reshape2);
glutDisplayFunc(display2);
glutMainLoop();
return 0;
}
|
|
1 members found this post helpful.
|
12-04-2023, 09:04 PM
|
#5
|
Member
Registered: Aug 2013
Distribution: Debian, Ubuntu
Posts: 271
Original Poster
Rep: 
|
So all that I needed to do was move the
Code:
glutDisplayFunc(display1);
up six lines. I tried that, and it works. Thank you
The original code snippet that I provided is over a decade old. I wonder why it never bombed before.
Quote:
Originally Posted by EdGr
The order matters.
You need to create the first window and set its reshape and display callbacks, and then create the second window and set its reshape and display callbacks.
Ed
|
|
|
|
12-05-2023, 09:37 AM
|
#6
|
Senior Member
Registered: Dec 2010
Location: California, USA
Distribution: I run my own OS
Posts: 1,058
|
Quote:
Originally Posted by piobair
The original code snippet that I provided is over a decade old. I wonder why it never bombed before.
|
The library likely changed. This is an old-style API that relies on a global variable (the current window).
Ed
|
|
|
All times are GMT -5. The time now is 07:57 PM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|