I am quite new to OpenGL (working on it for about 3-4 months) and I am currently developing an application which creates a 3D model of a wing of our office and lets a person walk through it.
As of now I have completed building the model (ours is - of course - a software company). The model contains the following objects -
Walls, Desks, Ceiling, Floor - created by specifying vertices. I used glBegin(GL_POLYGON)... glEnd() to build the display lists. Some of them, for example, the floor and the ceiling are also Texture Mapped.
Chairs, Computers, Phones, Pots - created by loading objects from .3ds files downloaded from the net. Since I didn''t have a good .3ds loader, I used 3D Exploration from XDSoft to export them to .obj files and used Nate''s Wavefront Object File loading code to load them. The class converts all objects into display lists. Each of these files contain object with around 1000 vertices on an average.
Materials and Lighting - since I wanted to concentrate on getting the geometry part of the model right first I''ve added just 1 White light and all objects are made created are made of the same material.
Keyboard Navigation - user can move around the model using the arrow keys to move Forward (Up Arrow Key), Backward (Down Arrow Key), Turn Left (Left Arrow Key), Turn Right (right arrow key), Move Up (''A'' Key) and Move Down (''Z'' Key).
The Development Environment:
I am developing this program on a Pentium II 350 Mhz machine with 128 MB RAM. It doesn''t have a 3D card, has a normal video card with 4MB VRAM. I am using SGI''s OpenGL Implementation as I heard that it is better for non-accelerated systems and is optimized for MMX processors (But I didn''t find any significant speed improvement over the Microsoft''s implementation). The OS is NT 4.0 (Service Pack 5.0) and I am using VC 6.0. I am working on 800 X 600 mode.
Finally coming to the problems I am facing. The main problem I am facing is that the speed is very very poor. I am hardly getting 1 Frames/s. I''ve done face culling wherever possible to minimize the number of polygons. But still since those .obj files contain objects huge number of vertices the polygon count is still pretty high. I am also using Display Lists everywhere possible to store and reuse geometry. As of now I am rendering the entire scene each time the screen is redrawn. And I am sure that the speed is going to go down further, once I add more Lighting to the scene.
1 - Is there a way in which I can improve the speed at which my application works?? I am sure that I can improve the speed even without the use of 3D acceleration b''cos I saw applications like Quake 2 or Doom/Wolf3D etc, working really fast even without 3D cards. How do these applications achieve this kind of speed? This is the problem I intend to address first. Please do mention any good sources of information too if possible.
2 - And if I find time, I would also like to implement some Collision Detection into the program. How do I do that?
Any help in this regard would be greatly appreciated. I would love to send in Screenshots of my application on request. Thanks in advance.
I suggest using glBegin(GL_TRIANGLE_STRIP) or at least glBegin(GL_TRIANGLES) instead of glBegin(GL_POLYGON). Furthermore, if you''re using no hardware acceleration use GL_NEAREST as your minification and magnification filters for your textures.
That depends on the OpenGL ICD. I would say send an email to opengl.org or test it with rendering a display-list of a enormous triangle strip and of a GL_POLYGON with the same amount of vertices and calculate the time either by clocking it with your watch ;-) or by your code.. shouldn''t be that hard.
The triangle strip is faster because you only need to make 1 more point for each triangle as opposed to gl_polygon which take at least 3 per triangle. so in the end each scene takes less processing power. 2+n as opposed to 3n.