GP2X Fusion2x - Opengl Es-cl 1.0


Trenki

Member
Joined
Jun 15, 2006
Messages
114
Age
40
Location
South Tyrol, Italy
Website
www.trenki.net
Hi!

In the last couple of weeks I have been working on this OpenGL ES-CL 1.0 layer. I uses my software renderer as a base. I release it now even though it is still in Alpha state since I don't have any more time to work on it because of Uni and a shift in interests.

On my homepage I have two versions, the basic version without optimizations and a version with basic optimizations in place. The optimized version requires very long to build though and the generated library is rather large. This is due to the template method approach I used for optimizations. The optimized version is can still be optimized much more since the raw software renderer is 1.25 times faster for the same scene.

Since this is an alpha release it still contains some known and very likely a bunch of unknown bugs. Check out the included readme file for more information.

You can check it out here.
 
You mean OpenGl is over your OOP framework? or it has no OOP now?
 
quasist said:
You mean OpenGl is over your OOP framework? or it has no OOP now?
The underlying Framework is unchanged but unaccessible from this OpenGL layer. Fusion2X implements the OpenGL ES-CL 1.0 API functions by making use of my existing software renderer.
 
Last edited by a moderator:
How do I use it? I did a look at the sources and include files without luck

I see all the context creation functions but don't get how to use it. I think I have to initialize SDL and set the surface as a color buffer and another surface as a depth buffer, but can't get it to work.


EDIT: Got it working, well kind of it... I had to pass 0 as param when creating context. Don't know if there is another better value.

But now I got a segfault on glDrawElements...here:

derived.cpp
CODE
namespace {
vec4x fetch_array(const F2X_Context::GLState::DataArray &array, const void *p)
{
vec4x result(0, 0, 0, 1);

switch (array.type) {
case GL_FIXED:
{
const GLfixed *pp = static_cast<const GLfixed*>(p);
switch (array.size) {
----------------------> case 4: result[3].intValue = pp[3]; <----------------------
case 3: result[2].intValue = pp[2];
case 2: result[1].intValue = pp[1];
case 1: result[0].intValue = pp[0];
}
}
break;
case GL_BYTE:
{


"p" is a null pointer

Here "in[0]" "in[1]" "in[2]" and "in[3]" are also null pointers:

vertex_processor.h
CODE
struct OptimizedVertexShader {
static const unsigned attribute_count = 4;
static const unsigned varying_count =
(interp_color ? 3 : 0) +
(interp_alpha ? 1 : 0) +
(interp_texcoord ? 2 : 0) +
(interp_fog ? 1 : 0);

static void shade(const swr::GeometryProcessor::VertexInput in, swr::GeometryProcessor::VertexOutput &out)
{
vec4x vertex;
vec4x color;
vec4x texcoord;
fixed16_t fog;

// fetch vertex
--------> vertex = ctx->derived_state.fetch_vertex(in[0]); <-------------------------

// fetch texture coordinate and transform it by the current texture matrix



Here is my code, well a bit of it (can't post the entire source, it's very large) I have commented out the glTexCoordPinter and glNormalPointer for testing.

CODE
glVertexPointer(3, GL_FLOAT, sizeof(Vertex), &(mesh->x));
// glNormalPointer(GL_FLOAT, sizeof(Vertex), &(mesh->normal.x));
// glTexCoordPointer(2, GL_FLOAT, sizeof(Vertex),&(mesh->tx) );
glDrawElements(GL_TRIANGLES, numFaces*3, GL_UNSIGNED_SHORT,vertIndices);
 
Post with some code to initialize a Fusion2X context

Are you using the "optimized" version or the default one? I noticed that there is a bug in the faster version that corrupts the graphics but with the slower version it worked. In my Fusion2X bases NFS3 Level renderer the "optimized" version works fine, so i think that bug is related to the use of the GL_COLOR_ARRAY and maybe other arrays.

You should try to use the other build and see if the bug is still there. In my tests I didn't hit that problem, so I don't know wheter it is in Fusion2X or in your code, I suspect it is in Fusion2X since it has not been tested very much and is still in alpha state and I don't have any plans on changing that in the near future.

When you enabled the various arrays are you sure that you also specified the correct pointer to use? And in your source example you use GL_FLOAT. I can't remeber to have included support for floating point vertex streams. Maybe you could also check for GL errors with glGetError. I think I also coded up some callback mechanism for errors which might be handy in such a case.

Hope that helps.
 
Last edited by a moderator:
Thanks, the problem was the GL_FLOAT, now I pass the array as GL_FIXED and seems to work, I say seems because transformation functions (glTranslatex,glRotatex..) doesn't work and glPushMatrix/glPopMatrix gives me the glGetError code 0x503, so I'm getting weird results on the screen (I think it's because the camera is inside the meshes)

I'm using the default one, not the optimized version.

I want to use Fusion2X to implement an Irrlicht backend, it's far easier than trying to implement a backend using your rasterizer without the opengl layer, because Irrlicht already have an opengl backend. It's sad that you will not longer develop it :(

Now that I think, I don't know how I will make Irrlicht to give me arrays on fixed point format without rewritting big part of the engine. Having a function that converts the array on the fly on the render loop is overkill. Perhaps I should continue working on my own engine..at least my engine uses your rasterizer directly, without the Fusion2X layer
 
efegea said:
Thanks, the problem was the GL_FLOAT, now I pass the array as GL_FIXED and seems to work, I say seems because transformation functions (glTranslatex,glRotatex..) doesn't work and glPushMatrix/glPopMatrix gives me the glGetError code 0x503, so I'm getting weird results on the screen (I think it's because the camera is inside the meshes)

I'm using the default one, not the optimized version.

I want to use Fusion2X to implement an Irrlicht backend, it's far easier than trying to implement a backend using your rasterizer without the opengl layer, because Irrlicht already have an opengl backend. It's sad that you will not longer develop it :(

Now that I think, I don't know how I will make Irrlicht to give me arrays on fixed point format without rewritting big part of the engine. Having a function that converts the array on the fly on the render loop is overkill. Perhaps I should continue working on my own engine..at least my engine uses your rasterizer directly, without the Fusion2X layer
I think for performance reasons it is far better to use the renderer/rasterizer directly and not through the Fusion2X GL interface since this gives far better performance. Fusion2X could be optimized with some template tricks and a profiler module that records which shader permutations will be needed. This would not be too hard if you can code but would still be a quite a bit of work.

If you wanted to integrate Fusion2X into Irrlicht you would have to convert floats to fixed point on the fly. This basically means you would have to add GL_FLOAT vertex array data support and then everything should work.

I don't know about the matrix stuff, the few functions I used in my tests seemed to work, but i did not try the matrix stack.
 
Last edited by a moderator:
Back
Top