Jump to content

  • Log In with Google      Sign In   
  • Create Account

Enerjak

Member Since 08 Nov 2007
Offline Last Active Yesterday, 10:20 AM

Posts I've Made

In Topic: Some help using vertex buffer with std::vector.

Yesterday, 12:13 AM

Your type naming is a little weird. Take for example:

VertexPC verts;

Shouldn't that be 'VertexPosColor'?

If 'VertexPosColor' is a vector, having it named in the singular sounds weird to me personally. I would named it VertexColorArray.

 

I'm going to assume 'verts' is supposed to be a vector, instead of a single vertex, so the rest of my post holds to that assumption.

 

sizeof() doesn't get the number of elements in an array or vector. std::vector.size() does that.

sizeof() gets the size, in bytes, of an object.

 

So this:

memcpy(data, &verts, sizeof(VertexPC));

Should be this:

memcpy(data, &verts[0], (sizeof(VertexPC) * verts.size()));

Starting at the address of the first vertex, not at the start of the vector class itself.

 

Unless I'm misreading your code. Which is likely, since I don't use DirectX. ohmy.png

 

Also this:

for (DemUINT x = 0; x < m_numVertices; ++x)
{
    verts = m_posColor[x];
}

Repeatedly assigns the same color to a single variable over and over again.

I love you..........what you suggested worked beautifully.....(sizeof(VertexPC) * vertex.size()) Thanks


In Topic: Generating a checkered pattern via dynamic textures in D3D9

22 October 2014 - 04:32 PM

Sorry to double post but I figured it out....

 

I just needed to do this: 

	D3DLOCKED_RECT lockRect;
		d3dText->LockRect(0, &lockRect, 0, D3DLOCK_DISCARD);

		BYTE* data = (BYTE*)lockRect.pBits;
		for (unsigned int i = 0; i < d3dText->Width ; ++i)
		{
			for (unsigned int j = 0; j < d3dText->Height  ; ++j)
			{
				
				int index = i * lockRect.Pitch / 4 + j;

				if ((i / 32 + j / 32 ) % 2 == 0)
				{
					*data++ = 255;
					*data++ = 0;
					*data++ = 0;
					*data++ = 255;
				}
				else
				{
					*data++ = 255;
					*data++ = 255;
					*data++ = 255;
					*data++ = 255;
				}
			}
		}
		d3dText->UnlockRect(0);

move the BYTE* data variable out of the for-loops..... stupid me.


In Topic: Generating a checkered pattern via dynamic textures in D3D9

22 October 2014 - 03:57 PM

Well, that didn't work......dang it. guess I'll wait a bit more for a good answer.


In Topic: Having a problem getting data from .obj file to render (index / Vertex buffer...

11 July 2014 - 06:04 AM

Also, check my dx9 c++ obj loader sample if you'd like: click

 

That helps a bit, but why use FVFs? I've noticed .X files (deprecated, yes), use vertex declarations (without loading effects). So it's possible to use vert decl without shaders, no?


In Topic: Getting rid of the pesky error C2027: Use of undefined type.

25 April 2014 - 01:10 AM

Thanks.


PARTNERS