OpenGL and GLUT in Fedora 12: windows too small and don't resize
I have verified using yum that I have the most uptodate glut, freeglut, freeglut-devel etc., yet when I compile Example 2-6 from the Red Book at http://www.glprogramming.com/red/chapter02.html#name16, I get a window that is too small for the program output, includes display from other windows, and will not redraw after being resized.
I get slightly better behavior with the SGI sample program mentioned in the same book, 'checkers.c'. Again, the initial size is too small, but at least it will resize and redraw the checkerboards entirely inside the resized window. What is going on here? Is this some bug in glut? I can't see anything obviously wrong in their glut initialization, which looks like: int main(int argc, char** argv) { glutInit(&argc, argv); glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB); glutInitWindowSize (350, 150); // glutInitWindowSize (700, 300); // did not help glutCreateWindow (argv[0]); init (); glutDisplayFunc(display); glutReshapeFunc(reshape); glutMainLoop(); return 0; Then again, since I am such a newbie to glut, I am not sure I would recognize what, if anything, they did wrong. But I have a simpler question: what ARE the valid and useful command line parameters I could have passed to the main() above? |
this part looks good to me,
what does your reshape function look like? Quote:
|
Quote:
void reshape (int w, int h) { glViewport (0, 0, (GLsizei) w, (GLsizei) h); glMatrixMode (GL_PROJECTION); glLoadIdentity (); gluOrtho2D (0.0, (GLdouble) w, 0.0, (GLdouble) h); } |
After you call gluOrtho2D, try calling
Code:
glMatrixMode(GL_MODELVIEW); |
Quote:
Code:
void reshape (int w, int h) So the placement in the output window is still very wrong, but once it is forced to redraw after losing focus, the portion that gets rendered gets rendered correctly. Does this tell you anything? BTW: I have both Gnome and KDE loaded on this thing. How do I tell which windowing system it is using? Could this be what is confusing GLUT? |
Code:
void reshape (int w, int h) Quote:
|
Try compiling the following code and see if it works for you. It does on mine:
Code:
#include <GL/glut.h> |
Quote:
Since it was right in the middle, and did not require any switching in/out of focus, I assume it worked flawlessly. So what does this tell us? |
Quote:
Then again, it may not even be relevant after all, since in fact, I have always invoked the OpenGL sample programs from the command line, usually Gnome's Terminal, very rarely KDE's Konsole, which, however, gave the identical results. So, for example, I named devnull10's code 'Ex9.c', compiled with "gcc -o Ex9 -lglut Ex9.c" and ran with "./Ex9" to see much better results. |
Quote:
Code:
glColor3f (0.0, 1.0, 0.0); |
Quote:
[edit] Just seen your post about the colours - not too sure about that - I'll take a look later, just in the middle of something now! :) |
Quote:
I can't remember how to view what version of OpenGl and GLUT I have, but I do remember installing the most up-to-date available as packages for Fedora; I did the install within the last three weeks. |
1 Attachment(s)
Try this - rename the attachment to ex4.tar and then extract. I think the example I provided might have been a poor one - it was just one I pulled from my old uni archive! :)
This is one I wrote when at uni. |
All times are GMT -5. The time now is 08:01 AM. |