Screenshot
Chapter 4 – Part 1/1: http://www.youtube.com/watch?v=VPHzKhGtS-E
For those who said VS2010 is really slow at startup:
Screenshot
Chapter 3 – Part 1/3: http://www.youtube.com/watch?v=9elzCvQw7WM
Chapter 3 – Part 2/3: http://www.youtube.com/watch?v=H3xMWM_QPtQ
Chapter 3 – Part 3/3: http://www.youtube.com/watch?v=J46wREWtQW8
This is a sample program i made for a friend of mine. It simply overlays an OpenGL program with an FPS counter, but can also be modified to display geometry as well.
YouTube
http://www.youtube.com/watch?v=CFucIgCg6K8
Source code and binaries
Screenshot
Chapter 2 -Part 1/1: http://www.youtube.com/watch?v=LdL4bRc101M
Screenshot
Chapter 1 -Part 1/4: http://www.youtube.com/watch?v=_mcs1pR2vLw
Chapter 1 -Part 2/4: http://www.youtube.com/watch?v=AOXlihXC0yY
Chapter 1 -Part 3/4: http://www.youtube.com/watch?v=JsN-affqqR4
Chapter 1 -Part 4/4 http://www.youtube.com/watch?v=bk6piV6FGX0
I’m going to release some videos about Blender. This is not meant to be a tutorial (since i’m still a newbie), i just thought i could share my first attempts
Here’s a screenshot of the model built in the part 4:
Those are the first four parts of the whole set of videos i’m going to release:
Part 1: http://www.youtube.com/watch?v=_2KJSayJuCM
Part 2: http://www.youtube.com/watch?v=vL-Dnh83Xw8
Part 3: http://www.youtube.com/watch?v=CC8s5VSuiVs
Part 4: http://www.youtube.com/watch?v=7bIJ3tkqTRQ
Blender’s home: http://www.blender.org/
Here’s the hotkeys reference: http://download.blender.org/documentation/BlenderHotkeyReference.pdf
Official tutorials: http://www.blender.org/education-help/tutorials/
I’ve been asked many times to create a remote control utility for Urban Terror, so i think i’ll make one. I don’t know if i’m going to make a linux version yet, but i don’t think it would be a problem to run it through something like Wine or Cedega.
I would like to be able to easily automate RCon sessions with the aid of a batch script, so i’ll surely need to make a CLI version too.
Basically, a vertex buffer is a piece of memory that is either located in system memory or video memory, and as the name may suggest you, it holds the vertex informations for the object you want to draw. Starting from the first DirectX 9 release, it is possible to store more than one entity in the same vertex buffer, because the support functions accepts an offset parameters that let you choose from which vertex you want to start to operate.
To create a vertex buffer, the CreateVertexBuffer method is used. Here’s its prototype:
HRESULT IDirect3DDevice9::CreateVertexBuffer ( // Length of the vertex buffer UINT Length, // Usage flags DWORD Usage, // Vertex format DWORD FVF, // Memory pool D3DPOOL Pool, // Pointer to a vertex buffer interface object pointer IDirect3DVertexBuffer9** ppVertexBuffer, // Reserved, must be null HANDLE* pSharedHandle );
The Usage parameter is used to tell DirectX what we’re going to do with the object we want to create. If i had created a software vertex processing device, i would have to add the D3DUSAGE_SOFTWAREPROCESSING flag; since i’ve specified hardware processing instead, this flag is not set, and the default approach (hardware) will be used. The next flag i’ve specified into the source code (D3DUSAGE_WRITEONLY) will be explained later when i speak about the memory pools.
The FVF (Flexible Vertex Format) parameter can be set to a valid FVF identifier in case you want to use a standard vertex format. Here’s the one i used in the source code:
DWORD g_dwVertexFormat = D3DFVF_XYZ | D3DFVF_DIFFUSE;
It tells DirectX that for each vertex stored in the buffer, 3 float data types will be reserved for the XYZ coordinates, and a double-word (4 bytes) will be used to define the color. I will not explain here what happen when you set it to zero; refer to the documentation or wait for the next tutorials.
Now that we have decided the format we want to use, we must create a vertex structure.
// Structure of a D3DFVF_XYZ | D3DFVF_DIFFUSE vertex
typedef struct __VERTEX
{
// Position
FLOAT fX, fY, fZ;
// Color
DWORD dwDiffuseColor;
} VERTEX, *LPVERTEX;
Note that DirectX expects to find the structure fields in a specific order; if you swap two variables, the vertex buffer will not be read in the correct way, and the geometry will appear corrupted. This is the order you must use:
The memory pool field defines where the created object will be stored; valid values are:
The vertex buffer has been created but it doesn’t contains anything yet; in order to fill it with our vertices, we first need to define them in some way. Here’s where the vertex structure we created before comes in handy:
VERTEX g_a_vxVertices[] =
{
// First vertex (red) of the first triangle
-5.0f, 5.0f, 0.0f, 0xFFFF0000,
// Second vertex (blue) of the first triangle
5.0f, 5.0f, 0.0f, 0xFF0000FF,
// Third vertex (green) of the first triangle
-5.0f, -5.0f, 0.0f, 0xFF00FF00,
// First vertex (yellow) of the second triangle
5.0f, 5.0f, 0.0f, 0xFFFFF200,
// Second vertex (purple) of the second triangle
5.0f, -5.0f, 0.0f, 0xFF8F00FF,
// Third vertex (orange) of the second triangle
-5.0f, -5.0f, 0.0f, 0xFFFF8F00
};
Now that we have defined the geometry for our object, we need to store it inside the vertex buffer. The vertices have to be copied to the buffer returned from the Lock method; here’s the prototype:
HRESULT IDirect3DVertexBuffer9::Lock ( // Offset into the vertex data UINT OffsetToLock, // Size of the vertex data to lock UINT SizeToLock, // Pointer to a memory buffer containing the returned vertex data VOID **ppbData, // Flags DWORD Flags );
A simple memcpy call will do the job:
memcpy(ReturnedPointer, ArrayOfVertices, sizeof(ArrayOfVertices))
The vertex buffer is ready to be drawn, we just need to call the Unlock() method; this will update the vertex data with the user-supplied buffer and release the lock. Everything i’ve explained now takes place inside the vInitializeDeviceObjects function.
Before we can render the vertices, we need to call BeginScene and tell DirectX the format we used to declare the vertices:
DirectX9Device->SetFVF(g_D3DFVF_XYZ | D3DFVF_DIFFUSE)
The last step is to set the stream source and call the draw method:
DirectX9Device->SetStreamSource ( // Stream number 0, // Vertex buffer VertexBuffer, // Offset into the vertex buffer 0, // Can be used for instancing, we will set this to the vertex size sizeof(VERTEX) ) DirectX9Device->DrawPrimitive ( // Type of primitive to render D3DPT_TRIANGLELIST, // First vertex to draw 0, // Primitive count sizeof(g_a_vxVertices) / sizeof(VERTEX) )
The scene can now be drawn to screen calling EndScene and Present.
Source code: http://insanedevelopers.net/downloads/Sources/DirectX9Tutorials/02 – Vertex Buffers.zip