gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

DS development > OpenGL Outlining

#160236 - JYC376 - Sat Jul 12, 2008 3:56 pm

I've looked into outlining for NDS (glEnable(GL_OUTLINE), glSetOutlineColor, blah blah blah), but I want something like this:

[Images not permitted - Click here to view it]

Instead of having an outline around the whole group of polygons. The code I used (on Linux/Win/OSX):

Code:
// Push the GL attribute bits so that we don't wreck any settings

glPushAttrib( GL_ALL_ATTRIB_BITS );
// Enable polygon offsets, and offset filled polygons forward by 2.5

glEnable( GL_POLYGON_OFFSET_FILL );
glPolygonOffset( -2.5f, -2.5f );
// Set the render mode to be line rendering with a thick line width

glPolygonMode( GL_FRONT_AND_BACK, GL_LINE );
glLineWidth( 3.0f );
// Set the colour to be white

glColor3f( 1.0f, 1.0f, 1.0f );
// Render the object

RenderMesh3();
// Set the polygon mode to be filled triangles

glPolygonMode( GL_FRONT_AND_BACK, GL_FILL );
glEnable( GL_LIGHTING );
// Set the colour to the background

glColor3f( 0.0f, 0.0f, 0.0f );
// Render the object

RenderMesh3();
// Pop the state changes off the attribute stack

// to set things back how they were

glPopAttrib();


When I just have GL_OUTLINE and one group of polygons, the whole image would look flat, as if the the center pillar is a bridge between the two sides (sorry, my cam isn't working right now).

I've made the game figure out different polyIDs for each square/pillar, but I would like a better solution.

Thanks.

Oh, and the code and binaries.

The NDS stuff are named n-echo and the Linux/Win/OSX are named l-echo.

#160242 - tepples - Sat Jul 12, 2008 7:28 pm

You could always try using white textures with black borders.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#160254 - silent_code - Sat Jul 12, 2008 10:03 pm

There should be no problem, if you split the parts that need an outline and assing each part a different polygon ID (iIrc, that was required to make it work correctly, but I might be wrong.)

PS: You might want to check the quad lying flat on the ground, there's some depth fighting.
Also, I think it's possible to make screenshots on emulators (I have just tested it on hardware)... and this looks interesting. :^)
_________________
July 5th 08: "Volumetric Shadow Demo" 1.6.0 (final) source released
June 5th 08: "Zombie NDS" WIP released!
It's all on my page, just click WWW below.

#160262 - Holland - Sun Jul 13, 2008 1:03 am

i'm not sure how the videoGL api works for the DS because i haven't gotten that far really...but for a good outline (like in cell shading) you can do this on the computer (using normal OpenGL)...

cull front face
scale the model up a bit
draw it all black
cull back face
scale model back to normal
draw it with normal color

the outline looks really nice actually, and it's an outline around the entire model instead of along each edge (like wireframe might be).

i think this method is more efficient thatn using GL_LINE too..soemthing about GL_LINE messing with the pixel work done in the rasterizer..but i'm probably wrong. :D

i'm curious now to see how this method looks on the NDS using videoGL..someone try it and show me!! haha

#160275 - JYC376 - Sun Jul 13, 2008 10:34 am

silent_code wrote:
There should be no problem, if you split the parts that need an outline and assing each part a different polygon ID (iIrc, that was required to make it work correctly, but I might be wrong.)

PS: You might want to check the quad lying flat on the ground, there's some depth fighting.
Also, I think it's possible to make screenshots on emulators (I have just tested it on hardware)... and this looks interesting. :^)


damn desmume doesn't work with linux (at least the 3d part...it's having troubles with opengl).

@tepples: hmms...mapping it to this guy would be tough, though.

@Holland: I'll try it later...

and it's GL_OUTLINE (play phantom hourglass and you can see it), not GL_LINE(no line drawing in NDS, have to make thin triangle).