Original Post
🔒 Locked
2d rendering
Advertisement
Hi theer asafpolt,
How are you doing buddy?
The Problem
Rendering 2D screen coordinates.
The Solution
The vertex format that you will use to create your vertices will be the D3DFVF_XYZRHW vertex format.
This will tell direct3d that you will be rendering screenspace coordinates.
e.g. CUSTOM_VERTEX using D3DFVF_XYZRHW
Then you will just define your vertices with 4 floats and a color for example...
Remember though that screen space coordinates relates to your window and the top left coordinates will be (0.0f, 0.0f, 0.0f) and the bottom right coordinates will be (window_width, window_height, 0.0f)
I hope this helps buddy.
Take care.
How are you doing buddy?
The Problem
Rendering 2D screen coordinates.
The Solution
The vertex format that you will use to create your vertices will be the D3DFVF_XYZRHW vertex format.
This will tell direct3d that you will be rendering screenspace coordinates.
e.g. CUSTOM_VERTEX using D3DFVF_XYZRHW
//your structurestruct CUSTOM_VERTEX{ float x, y, z, rhw, u, v; enum { FVF = D3DFVF_XYZRHW | D3DFVF_DIFFUSE };};//creation of your vertex buffer and definition of your verticesCUSTOM_VERTEX* pData;CUSTOM_VERTEX data[] = {//define your vertices here}};pDevice->CreateVertexBuffer(sizeof(CUSTOM_VERTEX) * 4, D3DUSAGE_WRITEONLY, CUSTOM_VERTEX::FVF, D3DPOOL_MANAGED, &pVB, NULL);pVB->Lock(0, 0, (void**)&pData, 0);memcpy(pData, data, sizeof(CUSTOM_VERTEX) * 4);pVB->Unlock();//how to render your verticespDevice->SetStreamSource(0, pVB, 0, sizeof(CUSTOM_VERTEX));pDevice->SetFVF(CUSTOM_VERTEX::FVF);pDevice->DrawPrimitive(D3DPT_TRIANGLESTRIP, 0, 2);Then you will just define your vertices with 4 floats and a color for example...
Remember though that screen space coordinates relates to your window and the top left coordinates will be (0.0f, 0.0f, 0.0f) and the bottom right coordinates will be (window_width, window_height, 0.0f)
I hope this helps buddy.
Take care.
Topic Locked
This topic has been locked by a moderator. New replies are not allowed.
Sign in to reply to this topic.
Advertisement