PocketMatrix forums

A read-only archive of the PocketMatrix forums (2001–2014). Posting and accounts are closed.

How to combine OpenGL and EDGELIB drawing?

Hi,

I'm having problem combining the OpenGL matrix calls with the EDGELIB 3D model drawing.

Is it possible to set the projection matrix used in EDGELIB to whatever I set in glFrustumx(..)?

Instead of using display->Perspective3D(..) call, I want to set the projection matrix using OpenGL call. I tried:

Code:

// Sets up the projection matrix in OpenGL
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glFrustumx(....);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();

// Renders the 3D turtle
display->SetShading(E3D_GOURAUD | E3D_TEXTURE);
display->BindTexture(&turtle;_tex);
display->SetShading(rendertype_shading[rendertype]);
display->Render(&turtle;);


But the above code doesn't seem to affect the rendering in the display [ClassEDisplay] object.

This is same for the glMultMatrixx(...) call. The rendered 3D model does not get rendered based on the matrix set by OpenGL. Is there a way to make EDGELIB uses the matrix set in OpenGL?

Thanks
Ohan[/quote]
Hi,

When calling glfrustum, I recommend first calling Perspective3D (which sets some internal variables for correct 3D rendering).

If still nothing is shown, then the model is too large or too small.
Hi edge,

Actually, it still doesn't seem to affect the rendering by display object. To test whether glFrustum really affects it, I tried setting glFrustumf(0, 0, 0, 0, 1, 2), which should theoretically makes the scene black because the clipping planes are set to zeros, but it still shows the turtle correctly in the scene. That means this glFrustum call didn't affect display->Render(..) method.

Also, I'm trying to directly set the matrix of a E3DSurface object. I got the matrix back from E3DSURFACEINFO structure using E3DSurface.Lock(&info;).
The info.matrix is an array of 16 long values, so I except that it takes fixed numbers instead of float numbers. How many bits should I shift to convert the float to fixed for your info.matrix? Is it 16 (65536) or 12 (4096)? Also, is it consistent for all of the numbers in the info.matrix? I see in one of the post that says the Scale uses 16 bits shift, but the others use 12 bits shift. This confuses me of how the actual fixed value matrix should be organized.

Thanks
Ohan
Hi,

Are you sure OpenGL is used? Maybe your application is using the internal EDGELIB renderer, thus making the call to glfrustum ineffective.

The transformation matrix is using 20:12 fixed point values. The only exception is the call to E3DSurface::Scale (which translates it into 20:12 fixed point values internally). The reason the scale function is using 16:16 fixed point values is to make it consistent with the scaling values of E2DSurface::Blt.
Hi edge,

Oh, sorry, I didn't really I had to define EGL_USEGL. That's why it didn't work out.

However, if I use OpenGL ES, it now has problem rendering the 3D turtle model which comes with the Animate3D sample. I'm using Vincent 3D Rendering Library's OpenGL ES implementation. I wonder if this is because the Vincent implementation or EDGELIB.

Anyway, thanks for the suggestions.

Now, I'm wondering if there is a way to set the camera matrix (projection matrix) used by EDGELIB's internal renderer. Also, what is the coordinate system EDGELIB uses? Is it right-handed coordinate system? Also, is the default view matrix set to +Y up and viewing toward +Z direction? Is it possible to set view matrix?

Thanks
Ohan
Hi,

Probably the vincent rendering library doesn't work, because there is no specific plugin library for the vincent OpenGL implementation. Perhaps you can search for rasteroid, which is also a software OpenGL ES renderer.

The 3D coordinates in EDGELIB are the same as OpenGL. X points to the right, y points up and z points towards the camera. Unfortunately, EDGELIB doesn't use a perspective matrix yet. This is a feature planned for upcoming releases.