Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
HauntedRobot
Jun 22, 2002

an excellent mod
a simple map to my heart
now give me tilt shift
Kind of a vague question, sorry.

Lets say I'm working on an outdoor first person game in OpenGL. I want a large view distance, so I'm assuming I'm going to be drawing very large, very simple geometry on the horizon, and small complicated geometry close up. For whatever reason, some way of cheating with a 2 pass skybox rendering method isn't going to work.

What are the performance considerations of doing this? For instance, does it poo poo all over my z buffer precision if in the same scene I'm drawing a 4 poly pyramid on the horizon that's hundreds of units tall and doing detail work close up? Also in that kind of situation, what's an acceptable scale for our coordinates? Is it worth spending time worrying about whether making my map extents minfloat to maxfloat rather than something arbitrary like +- 1024.

Adbot
ADBOT LOVES YOU

HauntedRobot
Jun 22, 2002

an excellent mod
a simple map to my heart
now give me tilt shift

Hubis posted:

You're going to run into signficant z-buffer precision problems leading to Z-fighting for things that are near one another (within one exponential precision value from one another) unless they are drawn in strict back-to-front order, including sub-draw call triangle order.

Thanks. That won't be a problem, the way my data's organised, nothing but simlar size polys at similar distances.

HauntedRobot
Jun 22, 2002

an excellent mod
a simple map to my heart
now give me tilt shift
Well, using TRIANGLE_STRIP or TRIANGLE_FAN each quad becomes 4 vertices, for a start.

HauntedRobot
Jun 22, 2002

an excellent mod
a simple map to my heart
now give me tilt shift
When I mentioned Triangle Strips I was explicitly talking about drawing one rectangle at a time, obviously they won't work over multiple rectangles because of the texturing thing. I was addressing the fact that the lack of quads led him to complain about using 6 vertices per quad, where a tri strip uses 4.

HauntedRobot
Jun 22, 2002

an excellent mod
a simple map to my heart
now give me tilt shift
You could do

code:
A--C--+--+--+
|*/|\ | /|\ |
|/*|*\|/ | \|
B--D--E--+--+
|\ |*/|\ | /|
| \|/*| \|/ |
+--F--G--I--+
| /|\*|*/|\ |
|/ | \|/*|*\|
+--+--H--J--K
|\ | /|\ |*/|
| \|/ | \|/*|
+--+--+--L--M
ABCDEFGHIJKLM to get the * triangles, and then you just have to deal with BDF, EGI HJL etc. Any reason you'd not use fans though?

HauntedRobot fucked around with this message at 10:11 on May 5, 2010

HauntedRobot
Jun 22, 2002

an excellent mod
a simple map to my heart
now give me tilt shift
Aigh, what in the hell. Having a fun time trying to ditch immediate mode, and having a hell of a time trying to draw 3 sides of a goddamn cube. Scene is basically set up so I'm looking at the cube corner-on. That means 7 vertices, 4 floats per vertex, elements are setup:

code:
static const GLushort e_cube[] = { 0, 1, 2, 3, 1, 4, 3, 5, 2, 6 };
The first 4 elements are the top face, the next 6 are the front left and front right faces, so as far as I can tell I need to do two calls to render that as two tristrips.

Shaders set up OK and do nothing much. Then in my rendering code (where vpos is the vertex position passed to the vertex shader as an attribute):

code:
glBindBuffer(GL_ARRAY_BUFFER, v_cube_buf);
glVertexAttribPointer(vpos,4,GL_FLOAT,GL_FALSE,sizeof(GLfloat)*4,0);
glEnableVertexAttribArray(vpos);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, e_cube_buf);
glDrawElements(GL_TRIANGLE_STRIP,4,GL_UNSIGNED_SHORT,0);
glDrawElements(GL_TRIANGLE_STRIP,6,GL_UNSIGNED_SHORT,4);
glDisableVertexAttribArray(vpos);
The first call to glDrawElements seems to go OK, as I see the top face but I can't then get the second to work, it looks like it's displaying the wrong face. Anything shine out as obviously wrong there?

Edit: doing just the one DrawElements call with all 10 elements works, but then I am redrawing one of my triangles...

Edit2: FIXED Indices is an offset in bytes, and a short is 2 bytes. That 4 should therefore be an 8. Always the simple things.

HauntedRobot fucked around with this message at 15:06 on Jul 29, 2010

HauntedRobot
Jun 22, 2002

an excellent mod
a simple map to my heart
now give me tilt shift
Trying to enable multisampling in OpenGL and I'm missing something. I am using glew elsewhere, but I know that all this stuff has to be initialised before glew, so there's been no glewInit() yet. This is the (I think) minimal failing code in my window setup routine.

code:
  (snipped)
Everything goes great up until the call to wglChoosePixelFormatARB which crashes with a segfault, though it appears to be pointing at a valid function. Why am I crashing out here?

Edit: Answer - it's NOT crashing there, the debugger just can't cope with functions defined that way and skips a bit, crashing in a perfectly sensible place later. Carry on.

HauntedRobot fucked around with this message at 16:11 on May 3, 2011

HauntedRobot
Jun 22, 2002

an excellent mod
a simple map to my heart
now give me tilt shift
Edit: Once again, stupid problem that had nothing to do with the code I posted.

HauntedRobot fucked around with this message at 14:37 on May 16, 2011

HauntedRobot
Jun 22, 2002

an excellent mod
a simple map to my heart
now give me tilt shift
It's also a problem of documentation. People have had years to write tutorials and examples for OpenGL 1.1 glBegin/glEnd stuff, the new stuff, not so much. I mean yeah, plenty of "here's how you get a triangle up on screen with VBOs" but it falls off in quality when you get beyond that, like how your approach would change if you had a list of triangle meshes, how you would handle camera stuff, etc etc. But it'll catch up.

HauntedRobot
Jun 22, 2002

an excellent mod
a simple map to my heart
now give me tilt shift
I have a world defined as a bunch of polygon meshes and I'm using VBOs at the moment to render them. Currently the setup is
code:
        glBindBufferARB  ( GL_ARRAY_BUFFER_ARB, (*mi).vbo );
        glVertexPointer  ( 3, GL_FLOAT, 32, (char *)NULL + 0 );
        glTexCoordPointer( 2, GL_FLOAT, 32, (char *)NULL + 12 );
        glColorPointer   ( 3, GL_FLOAT, 32, (char *)NULL + 20 );
and then I go through with DrawArrays... this gives me 3d textured geometry with really basic vertex lighting. (I know this is way behind the curve but I've been out of the loop so I'm relearning from the naive glBegin, glEnd stuff forward here, and diving right in to shaders was too much to take in at once)

The thing with that is that the lighting is baked in and static, and I want to move on to dynamic lighting. Is there a way to accomplish that through loading the vbo -> *doing something where dynamic light values get added* -> DrawArrays? Or have I hit the limitation of rendering that way there?

If so, where would I go next from there? Is the next thing to do it all in shaders or is there some kind of intermediate step? Something with a deferred lighting pass maybe? I've learnt a ton of stuff doing things this way that I'd sort of handwaved over before.

Adbot
ADBOT LOVES YOU

HauntedRobot
Jun 22, 2002

an excellent mod
a simple map to my heart
now give me tilt shift

HiriseSoftware posted:

If you want to still use VBOs with dynamic lighting instead of shaders, you could put the color values into another VBO and modify them each frame:

You'll have to remove the color data from your interleaved vertex information of course.

Oh, that's a pretty good idea. Disentangling them from the other vertex info isn't ideal, but I already have a similar thing in the loader for generating a simplified collision mesh for the physics.

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply