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
Eponym
Dec 31, 2007
I have a question about DirectX9:

I am trying to read vertex data from a mesh loaded from a file. My issue is that I don't know what the vertex data looks like aside from the fact that it has position data and a normal. My knowledge of DirectX isn't that extensive, so I'm sorry if the answer is obvious, but I haven't come across it.

code:
struct VERTEX
{
	// empty right now
};

	//stuff

VERTEX* pVert = NULL;
if (SUCCEEDED(this->associatedMesh->pMesh->LockVertexBuffer(D3DLOCK_DISCARD,(VOID **) &pVert)))
{
	// empty right now
}
Ideally, I'd like to do something like D3DVector3 normal = pVert[index].Normal. My issue is that I don't know what to define struct VERTEX with or what order in which to define its elements. How do I find out the vertex format?

Adbot
ADBOT LOVES YOU

Eponym
Dec 31, 2007
I'm a beginner, and have 2 questions...

About the coordinates of lines

I have an application where I'm trying to draw lines on a 512x512 texture. The texture is mapped to a screen aligned quad with vertices (-1.0f, -1.0f), (1.0f, -1.0f), (1.0f, 1.0f), (-1.0f, 1.0f).

Suppose I want to draw a line. I don't have any problem drawing lines in world space, but if I want the lines to start and end at particular pixel positions (eg. (48,48) to (72,72)), I get confused. Is it up to me to scale and transform those endpoints so that they are mapped to the appropriate world-space coordinates? Is there anything I can do so that I don't have to perform that transformation?

About the width of lines
I am using OpenGL 2.1, so glLineWidth can be set to values greater than 1 pixel. I read that in OpenGL 3.1, glLineWidth can't be set greater than 1. In that environment, what do people do instead?

Eponym
Dec 31, 2007
I am trying to draw anti-aliased lines, and this is how to do it, or so I've read:

code:
     // Enable line antialiasing
     glEnable(GL_LINE_SMOOTH);
     glEnable(GL_BLEND);
     glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
     glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);
However, I am trying to draw antialiased lines into a framebuffer object. Without the above, my lines draw fine. With the above, nothing draws.

I'm not sure what other details to provide. I am using textures and shaders.

Eponym
Dec 31, 2007

Spite posted:

What OS, what GPU? AA lines are an odd duck.
Does it work if you draw to GL_BACK?

Mac OS X 10.6.4, using an Nvidia 9400m.

Nothing changed when I rendered using GL_BACK. However, I did manage to fix things, although I don't know why it worked.

code:
     // This was here before I decided to add antialiased lines
     glClearColor (125.0f/255.0f, 219.0f/255.0f, 127.0f/255.0f, 0.0f);
     glShadeModel(GL_SMOOTH);
     glEnable(GL_MULTISAMPLE);

     // Enable line antialiasing
     glEnable(GL_LINE_SMOOTH);

     // Apparently this not needed to enable line anti aliasing
     //glEnable(GL_BLEND);
     //glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
     //glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);
When I had the bottom 3 lines uncommented, nothing rendered. In fact, it didn't even look like the OpenGL commands were running correctly. When my program first runs, the viewport should be filled with the clear color, but instead garbage is displayed. However, gluErrorString wasn't printing out any errors. Even when I drew to GL_BACK, the same garbage displayed.

On a whim, I commented the bottom 3 lines, and my lines render, antialiased.

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