ProgrammingThis 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.
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.
The following piece of code should draw a sphere in an SDL window, which is opened from a Qt window. The SDL window pops up properly, but the sphere doesn't get displayed. I have little experience with OpenGL, and even less experience with GLU functions. I can't find my error. Can anyone help me?
(The constructor is being called from the main function)
I took the lighting out and tried to draw some vertices with glBegin(GL_TRIANGLES); glColor3f(), glVertex3f() and glEnd(); and this worked. But why doesn't gluSphere work?
I didn't have time to mess with this much, but some interesting lines that are probably the source of the problem are the following (taken from different functions):
You are using a perspective projection, so your viewing volume is kind of like a pyramid shape with the top cut off. Anything within this volume will be visible, anything not in it will not be visible.
It appears that you are trying to draw your circle at 300, 200, -5. I haven't done the calculations, but I am pretty confident that this location will not fall within your viewing volume. (It is likely clipped by both the top and right clip planes). Try Change the values you pass to DrawKugel to something like 0,0 initially and go from there.
Thanks, changing the coordinates in DrawKugel(300, 200, 10); worked and I could see a sphere (althought it looked like a circle) Now I only have to adjust the lights. Although it could be better if the sphere stayed at 300.0f, 200.0f, 10.0f and I could change the gluPerspective to see it (or replace gluPerspective with gluLookAt)
You wouldn't replace gluPerspective with gluLookAt as they do different things. Think of gluPerspective as setting the properties of your camera lens, and gluLookAt as a means pointing your camera in the direction you want. If you want to use gluLookAt, you should use it in the MODELVIEW matrix, and make sure it is the first thing applied after a glLoadIdentity().
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.