|
There are several reoccuring questions that appear at the G3D forums.
This document answers many of the most common questions.
Table of Contents
1. What hardware is supported?
2. Can G3D work without a 3D card?
3. G3D::Matrix4 vs. OpenGL Matrices
4. P-Buffers
5. UNICODE Font Support
6. The next release
7. The demos run slowly
8. What are index arrays?
9. Using G3D with other libraries
10. Proximity and ray intersection with PosedModel
11. How do I rotate an object when it's drawn?
12. Is there a way to make the GCamera do an orthographic projection?
13. How do I get the world-space coordinates of the mouse cursor?
14. My G3D based project will not build with Visual Studio 2005
15. A fullscreen application shows the window title bar
16. Why are the headers out of date?/What header files are included with G3D
17. Why does the source distribution not include the build system?
18. Float / Double precision errors. Warnings in truncation, or overload errors with argument types
19. How can I join the G3D Core Dev team
20. Why does G3D come with its own OpenGL headers?
What graphics hardware does G3D support?
G3D supports any card that can run OpenGL. G3D automatically detects and works around known bugs in older cards. We've tested all the way back to pre-T&L cards and it still runs great.
Can G3D work without a 3D graphics card?
G3D can work with the full-featured Mesa3D and the extremely limited but always-available GDI Generic software renderers.
G3D::Matrix4 vs. OpenGL Matrices
User may notice passing G3D::Matrix4 as a float* to OpenGL's matrix functions has unexpected results. Similarly, copying an OpenGL float* matrix into a G3D::Matrix4 seems to store the values strangely. This is because G3D stores matrices in row major order and OpenGL stores them column major. Basically, rather than store elements contiguously by their columns, they, they are ordered by their rows. There are technical reasons to use either ordering, and it is not uncommon to encounter lively discussions arguing each representation's merits. For G3D, row major ordering was chosen for increased accessing performance at the cost of breaking an OpenGL convention. Fortunately, the conversion between OpenGL's column major ordering and G3D's row major ordering is simple: G3D::Matrix4::transpose will return a row major matrix in column major, and a column major matrix row major. Better yet, G3D's OpenGL extension will automatically perform this conversion using the G3D::CoordinateFrame objects with G3D::glLoadMatrix, G3D::glLoadInvMatrix, G3D::glMultInvMatrix, G3D::glMultMatrix, G3D::glGetFloat, and G3D::glGetMatrix. For most applications, G3D::CoordinateFrame is a better choice for rigid-body transformations than G3D::Matrix4.
P-Buffers
G3D::Framebuffer is a platform independent abstraction of OpenGL's Framebuffer mechanism, which replaces the older p-buffer mechanism. As a result, there is no need for extended functionality supporting p-buffers in G3D. This does not prevent you from using them through standard OpenGL calls, though. Using p-buffers is a recognizably difficult process, principally due to the extension's design.
UNICODE Font Support
G3D supports rendering fonts through G3D::GFont, but only through the ASCII 8-bit characters. This includes accented and Wingdings characters.
To implement extended characters, one might attempt extending G3D::GFont for extended characters. The FreeType generates little 2D bitmaps that you have to pack into a texture (using G3D::Texture the way G3D::GFont does) for rendering.
The Next Release, What's Coming, What's Going
One way to check on the overall progress of a release is to check the changelog.h in CVS for fixes and features added. This is in the G3D/doc-files directory: http://cvs.sourceforge.net/viewcvs.py/g3d-cpp/G3D/doc-files/
Deprecated functionality is removed at major releases (e.g., from 6.xx to 7.00)
Because G3D builds as a static lib, there is no code bloat to your final executable. I would not be concerned about the deprecated routines-- just avoid using them in new code. The list of all deprecated entry points is: http://g3d-cpp.sourceforge.net/html/deprecated.html
The Demos Run Slow
Most of the G3D demos are designed to stress high-end hardware, and will likely choke lower-end systems. The most significant component affecting demo performance is the video card; even with a high-speed processor, a low-end graphics card will likely be the bottleneck in the rendering pipeline. Low performance in these demos doesn't mean G3D is "slow." The demos are intentionally constructed to test against the computational limits using methods which may not accurately represent the "real" 3D applications.
For system profiling, the developers recommend using the 'gfxmeter' tool provided with G3D.
What are Index Arrays?
Say you have a shape with four distinct vertices, A, B, C, D, and the triangles you want to render are ABC and BCD. with sendVertex, you'd:
sendVertex(A); sendVertex(B); sendVertex(C); sendVertex(B); sendVertex(C); sendVertex(D);
with vertex arrays you make a VAR that contains A,B,C,D, and an Array<int> indexArray that contains 0,1,2 1,2,3.
In the VAR_Demo you will see an example of this in the 'main.cpp' file. The "Model" object has an array of Vector3 for vertex locations. Then, a VAR is created with a Vector3 array (one for verticies and one for normals).
Using G3D with other libraries
G3D is a middle-level API that is used to encapsulate and assist with common graphics tasks. It also has a very thin high-level layer (G3D::App, G3D::Applet). This can be simply ignored if you intend use some other high-level functionality, such as a Windows app you're writing or a scenegraph library. In this way, the library will make calls to G3D to do the OpenGL rendering.
However, some of these libraries even include their own render functions. In these cases, you can still use G3D to augment OpenGL functionality, but this may interfere with your library's rendering. The conditions are specific to the library, and the particular application. In any case, G3D's other non-OpenGL graphics functionality remains available; the geometry, image, and math API's may be useful depending on your needs.
Most libraries with orthogonal functionality (such as audio libraries) should operate adjacently with G3D without conflict.
For more details, see Working with Other Libraries .
Proximity and ray intersection with PosedModel
I need to intersect a ray with a PosedModel in G3D, and/or find the closest point on a model to a given point (ideally, both). Is there a way to do this in the G3D library, or do you know if there is any already-written code that can do this for us?
You can get an indexed triangle list out of a posed model, which you can use to create an array of G3D::Triangles. The triangles have a ray intersection method-- just choose the first intersection. Use the posed model's bounding boxes to test conservatively if the ray could hit the model before performing the individual tests.
To make this faster, only construct the triangle list once on startup since the constructor is kind of slow. If your model is large and you're inside it (e.g. a quake map) then you should create an AABSPTree, which will perform only log(n) ray intersection tests on average for n triangles.
How do I rotate an object when it's drawn?
G3D maintains separate matrices for object-to-world and camera-to-world. These are what OpenGL combines into MODEL_VIEW matrix set with glMulMatrix, glTranslate, etc.
Given a G3D::box it would be drawn and rotated using something similar to this code:
renderDevice->setObjectToWorldMatrix(CoordinateFrame(Matrix3::fromAxisAngle(axis, angle), Vector3(...)); Draw::box(box, renderDevice);
Note: G3D::Draw is easy to use and fairly powerful. It is also fairly slow (as indicated in the documentation). Consider using IFSModel or writing your own VAR code for a huge speedup.
Is there a way to make the GCamera do an orthographic projection instead of the perspective?
No, orthographic cameras are fundamentally different from perspective cameras because there is no center of projection. An orthographic camera has to be *huge* to do what you'd want--the viewport would have to be the size of your scene. GCamera can't be adjusted to do this without breaking it.
It is possible to build your own orthographic camera since RenderDevice accepts any 4x4 matrix as the projection matrix, if anyone implements this, please let the development team know, as we'd like to use it too.
How do I get the world-space coordinates of the mouse cursor?
First get the ray from the mouse cursor into the world:
camera->worldRay(userInput->mouseXY().x, userInput->mouseXY().y, renderDevice->getViewport());
From then, there are two methods. The first is to use CollisionDetection to calculate the intersection between this ray and the geometry of the world. Another method is to convert it to depth Z-Buffer using:
depth = readback
float csz = lerp(camera.nearPlaneZ(), camera.farPlaneZ(), depth);
Vector3 csv(0,0,csz);
camera.getCoordinateFrame().pointToWorldSpace(csv);
My G3D based project will not build with Visual Studio 2005
Please see the equivalent error in the Error FAQ.
A fullscreen application shows the window title bar.
The window is showing the frames. Create an unframed window with GWindowSettings::framed = false;
Why are the headers out of date? / What header files are included with G3D?
We intentionally use our own version of the OpenGL headers because we have found that most Linux systems have out of date headers.
Often the user (e.g., a student) does not have root access and can't correct this, so we just supply our own.
On Linux G3D will use your libjpeg, libpng, and libz headers. We include ours only for Win32.
Why does the source distribution not include the build system?
The "source" distribution intentionally does not include the G3D build system.
It is provided to help document G3D, not to rebuild it.
This is primarily because the build system is complex (it covers many platforms) and we aren't in a position to offer support for the build system yet. It is also because building requires many files that we don't include in the source distro to make the download size smaller.
Check out from CVS if you'd like to build G3D. Once the latest G3D source has been checked out, building is easy:
on Linux, type:
chmod u+x build
./build install <targetdir>
This build command also works on Win32 and OSX, but it requires Python to be installed.
We are currently in the process of redesigning the build system; hopefully the new version will be something that we're comfortable releasing with the source distro.
Float / Double precision errors. Warnings in truncation, or overload errors with argument types
In 6.08, we changed most the pass-by-value arguments from double to float to increase performance and trigger truncation warnings (i.e., to show you where you might be losing precision).
This will likely cause your code to generate warnings like: warning C4305: 'argument' : truncation from 'double' to 'float' These are usually caused by using double constants for float arguments, like:
Vector3(0.1, 2.0, 0.3). The solution is to use float or int constants, like:
Vector3(0.1f, 2, 0.3f) or Vector3(0.1f, 2.0f, 0.3f). You can also work around this on Microsoft compilers with the command pragma warnings (disable : 4305).
Occasionally, this change will cause an overload to become ambiguous, generating an error like: error C2665: 'G3Dmax' : none of the 5 overloads could convert all the argument types In this case, change your code to ensure that both of the arguments to the function have the same type.
E.g., max(1.0, 2.0f) -> max(1.0f, 2.0f).
How can I Join the G3D Core Dev Team?
We always need help with documentation. If you would like to submit new documentation for a class or for part of the manual, that is another good way to demonstrate your skills.
After someone has contributed for a few months and demonstrated both their abilities and commitment to the project, we will invite them to join the core team.
In core team members, we value most:
- Reliability
- Complete tasks you've committed to
- Maintain a presence by posting in in bug tickets and forums
- Professionalism
- Treat users and other developers with respect
- Test changes carefully
- Embrace the whole role: documentation, testing, advocacy
- Enthusiasm!
Note that we don't need the most *skilled* C++ developers in the world--we need the most reliabile, professional, and enthusiastic developers.
Why does G3D come with its own OpenGL headers?
OpenGL has a plugin architecture. There is the base OpenGL, which is statically linked. Then there are OpenGL extensions, which are loaded at runtime manually. On Windows you use DLLOpen and wglGetFunction; other operating systems have some equivalent calls.
The idea is that your operating system ships with a version of OpenGL, but new features come out after the operating system has shipped. So OpenGL programs load the OpenGL dynamic libary (which comes with the graphics card driver) manually to get the latest version. Then they load all of the extension functions which came in with system updates or graphics divers. There are two gotchas in this plan:
1. Different operating systems come with different base versions of OpenGL. OSX ships with GL 2.0, Windows with 1.3, and Linux is all over the map.
2. The system headers don't have function prototypes for those new functions. So you have to roll your own OpenGL headers.
In theory, you could update your system headers every time you installed a new graphics driver. In practice, you can't. There isn't a canonical set of up-to-date OpenGL headers and on many systems (e.g., students in a computer lab) you don't even have permission to upgrade them. So G3D gives you a set of the latest GL headers that we maintain by hand.
Generated on Thu Aug 2 11:40:43 2007 for G3D by
1.5.2
Hosted by
|