vertex buffer, index buffer

Win32 Programming

    Next

  • 1. Copying surfaces in DirectX 9?
    Hi, I'd like to know how I can copy surfaces from sysmem to vidmem. Like, I got a background surface in sysmem and want to copy specific rects to a vidmem surface for scrolling. thanks, chewie
  • 2. Changing screen resoultion
    I have resolved my problems with reset device after switching between windowed/fullscreen mode, but I have question now about changing screen resolution during aplication run-time. It should be device recreated after it or there is some simple and similiar way as switching windowed/fullscreen mode?
  • 3. Transparent blitting... HELP!
    I'm using the new Managed DirectX 9 to program in VisualBasic.NET. I think I'm doing everything OK to blit an image to the BackBuffer with one of its colors as transparent. Here's the code: Dim desc As New DirectDraw.SurfaceDescription() Dim transp As New DirectDraw.ColorKey() transp.ColorSpaceLowValue = RGB(209, 29, 53) transp.ColorSpaceHighValue = RGB(209, 29, 53) desc.Clear() desc.SourceDraw = transp desc.SurfaceCaps.OffScreenPlain = True desc.Height = 309 desc.Width = 305 Dedo1 = New DirectDraw.Surface("dedo1.bmp", desc, Device) BackBuffer.Draw(Dedo1, DirectDraw.DrawFlags.KeySource) PrimarySurf.Flip(BackBuffer, DirectDraw.FlipFlags.Wait) ---------------------------------------------------------------------------- ---------------- But when I run the code, the transparent color is visible!! :-S I've also seen in the documentation they use CLR_INVALID as a color key, and this makes that the colorkey is the first pixel in the image, but I don't know the equivalent in Managed DirectX... Can anyone help me, please?
  • 4. saving screenshots
    Is there any helper functions for saving a screenshot to a file or do I have to write one myself? Using Directx 8. Thanks in advance, Lem
  • 5. directx9: mixing color with alpha-texture
    hi all ( first, sorry for my bad english) i try to mixing a diffuse-color with a texture that have alpha-values. the goal is that the background-color (diffuse) is show through the alpha-values of the texture. i've tryed the following: - enable alphablending: (*m_dev)->SetRenderState( D3DRS_ALPHABLENDENABLE, TRUE ); (*m_dev)->SetRenderState( D3DRS_SRCBLEND, D3DBLEND_SRCALPHA ); (*m_dev)->SetRenderState( D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA ); - mixing diffuse and texture (*m_dev)->SetTextureStageState(0,D3DTSS_COLORARG1, D3DTA_CURRENT); (*m_dev)->SetTextureStageState(0,D3DTSS_COLOROP, D3DTOP_MODULATE); (*m_dev)->SetTextureStageState(0,D3DTSS_COLORARG2, D3DTA_TEXTURE); (*m_dev)->SetTextureStageState(0,D3DTSS_ALPHAARG1, D3DTA_DIFFUSE); (*m_dev)->SetTextureStageState(0,D3DTSS_ALPHAOP, D3DTOP_MODULATE); (*m_dev)->SetTextureStageState(0,D3DTSS_ALPHAARG2, D3DTA_TEXTURE); unfortunately that does not work. the texture appears black and diffuse-color is colludes. whats wrong on that ? i work with directx 9.0 and ati 9500pro. ---- Remo

Re: vertex buffer, index buffer

Postby Phil Taylor » Fri, 05 Nov 2004 03:04:22 GMT

there is setup time internally both for a VB and for a particular 
FVF/components. its less if you stay with the same format/stride, but there 
is still some cost with switching just the VB.

minimize it if you can without heroic rewriting, but dont worry about it if 
its a huge rewrite unless you measure thats a significant factor in your 
particular performance signature.

tools are required for measurement. VTune or other static performance 
analysis tool and a dynamic analysis tool like Pix that shows your API usage 
per frame is good, you can zero in on most issues that way.








vertex buffer, index buffer

Postby Hanna-Barbera » Fri, 05 Nov 2004 05:36:14 GMT

Hi,

Does switching VB and IBs a lot cost too much?
Is it better to store multiple things to be rendered in one VB/IB?
Is it considered one of the costliest things, that must be dealt with.
What about the size of the buffers.
I know 16 bit indices are recommended, which is what I use.

I know my question is abstract, but I would like to know in relative terms,
compared to swithcing textures, switching shaders, and so on.

Right now, my engine may be switching texture, and VB and IB per object.
Shader are not switched so often cause the object's share the same shader.

Thanks



Similar Threads:

1.Changing vertex color after vertex buffer and index buffer definition

Hi,

Say you have this custom vertex structure:

struct CUSTOMVERTEX
{
	float x, y, z;
	DWORD color;
};

Is it possible once you've defined values for a vertex 
buffer using that structure to subsequently change the 
color for a vertex that you defined? If so, how?

Thanks :)

2.memory-loss when locking & unlocking vertex/index buffers

Hi,

I am finding that memory is being consumed at the rate of 1 to 6
megabytes per lock/unlock on my vertex and index buffer. The memory
does not get released until my application exits, which means that the
longer my app runs the more memory is consumed, so at a low 20fps
that's an awful lot of memory being consumed per second. Surely this
should not happen?

I am running VB .Net and Managed Direct X.

Cheers, code is posted below,

Richy

' I lock my buffers:

_vbdata = _vb.Lock(0, 0)
_ibdata = _ib.Lock(0, 0)

_lmvbdata = _lmvb.Lock(0, 0)
_lmibdata = _lmib.Lock(0, 0)

' and then I unlock it all:

_vb.Unlock()
_ib.Unlock()
_lmib.Unlock()
_lmvb.Unlock()

' and then I set the variables to nothing

_vbdata = Nothing
_ibdata = Nothing

_lmvbdata = Nothing
_lmibdata = Nothing

3.Vertex and Index Buffer - color updating after definition

Andy wrote:
> I realized that my earlier question was not complete...
> 
> Given a defined vertex structure, a defined set of 
> vertices in a vertex buffer, and a defined index buffer 
> that has referenced those vertices, can you then change 
> vertex color as you use items being referenced by the 
> index buffer? If so, how?
> 
> (Simply put I'm trying to reuse vertex data that needs to 
> vary in color at different index buffer values... is there 
> a smarter way to do this?)
> 
> Thanks :)

If you mean you're trying to save duplicating vertices that have the 
same position but different colour, just duplicate them. There's no 
good way to reuse them.

	Eyal

4.Filling vertex and index buffers

I am trying to do indexed rendering, and have a question. The book I am
going through (Zen of Direct 3D Game Programming) uses the following method
to fill a vertex buffer:  (I have changed some variable names to make their
use more obvious in such a small snippet)

LPDIRECT3DVERTEXBUFFER8 pVB = 0;
hresult = g_pDevice->CreateVertexBuffer( sizeof (CustomVertex) * iNumVerts,
D3DUSAGE_WRITEONLY,

CUSTOMVERTEXTYPE, D3DPOOL_DEFAULT, &pVB);


BYTE* pVertexData = 0;

hResult = pVB->Lock(0,0,&pVertexData,0);

///////////////////////////////////////////////////
//Here is the bit that gives me trouble
/////////////////////////////////////////////////

CopyMemory( pVertexData, (void *)&m_Vertices, sizeof(m_Vertices));
pVB->Unlock();

I have 2 questions about the use of CopyMemory(). First, what protection do
I have against a memory overrun? I think I am having this problem, and if I
understand the Copymemory() function correctly, there  is nothing that says
the block of memory pointed to by pVertexData is going to safely hold what
I'm trying to copy to it? Is this how it is usually done? It just seems
wrong to me.

Also, and this is really a C++ question, but it is relevant to this task, In
this example m_Vertices is an array of Vertices. So doesn't
sizeof(m_Vertices) only give me the size of the first element of the array?
I think I must not understand arrays as I thought I did, because I though
you couldn't use "sizeof" to find the size of an entire array.

Thanks!




5.index and vertex buffers

Hey,

I'm new to MDX and i had a question regarding index and vertex buffers.  I have code set up to read in vertex data and store it into a VB.  I also have an index buffer set up for building a cube, so if you pass the VB 8 vertices, use the index buffer, it renders the image correctly.  The question i have, is that although usually i will have a shape with 8 vertices, sometimes i will have more, i.e. a 3d pentagon as oppossed to a cube.  how do you create a "universal" index buffer to handle a varying number of vertices. 

As i said I'm very new at this, and maybe I'm going at it the wrong way.  Any help or suggestions you can give would be great!

Note: I set up the vertex and index buffer according to Tom Miller's book.

Thanks in advance
Aaron

6. Indexed Vertex Buffer with noraml

7. optimizing vertex/index buffer use

8. Sprite or big vertex & index buffers?



Return to Win32 Programming

 

Who is online

Users browsing this forum: No registered users and 32 guest