• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0

D3D9 Is not rendering the whole mesh

0 posts in this topic

Right after I post it I found my mistake. I was not setting proper size of the index buffer... Didn't notice it take size instead of count. After whole day debugging.

So this is the result. I'm trying to render a cube.(The cube has 3x3x2 triangles each face, but it is rendering only first row from top. (If culling = none -> it renders also the bottom of the cube, but still half top and walls are missing)
Cube is loaded from .ASE file. (I've made simple level editor loading ASE files a year ago. it could render the cube as it shoud. => file is OK. NOTE: I'm using effects for first time. The shader is just taking matrix(WolrdViewProj) and multiply it to the vertex. Then pixel shader just returns white color)
I've have tripple checked the data I put into the buffers. It is ok.
I think I'm not passing the right parameter somewhere. The whole source code, like always, can be found here: [url="http://code.google.com/p/random-engine/source/browse/#svn%2Ftrunk%2F%20random-engine"]http://code.google.c.../ random-engine[/url]
However, I have tried to extract the code which I think is the problem, to make people's life easier:
D3DVERTEXELEMENT9 VertexPosElements[] =
}; // I'm using array of D3DXVECTOR3 for the vertices
void CALLBACK RandomEngineApp::OnRender( IDirect3DDevice9* pd3dDevice, double fTime, float fElapsedTime, void *pUserContext )
Mat4x4 proj, view, world, rot; static float r = 0; r+= 0.007;
world = Mat4x4::g_Identity;
D3DXMatrixRotationY(&rot, r);
Vec4 v(3,2,3,1);
D3DXVec4Transform(&v, &v, &rot);
D3DXMatrixLookAtLH( &view, &Vec3(v.x,v.y,v.z), &D3DXVECTOR3(0,0,0), &D3DXVECTOR3(0,1,0) );
D3DXMatrixPerspectiveFovLH( &proj, D3DX_PI / 4, 1.33f, 0.01f , 1000.0f);

//g_pApp->GetLogic()->VOnRender();//this will be used later when I know what I am doing
g_pApp->GetRenderer()->VSetDeclaration(VertexPosElements); // vertex element declaration, this is something I have no idea if I'm doing it right
AssetDataPtr mesh(AssetManager::Get()->GetAssetData(Resource("box.ase\\box.ase"))->front()); // get the first mesh, found in box.ase, don't worry it is not parsing or loading it here
void Renderer9::VSetDeclaration(D3DVERTEXELEMENT9 * vd)
IDirect3DVertexDeclaration9 * vdp;
DXUTGetD3D9Device()->CreateVertexDeclaration(vd, &vdp);
void Renderer9::VBeginScene()
void Renderer9::VEndScene()

void Renderer9::VDrawMesh(RE_Mesh * mesh)
D3DXMATRIXA16 WorldViewProj = m_World * m_View * m_Proj;
unsigned int passes;
hr = m_pREffect->SetTechnique("SimpleRender");
hr = m_pREffect->SetMatrix("c_WorldViewProj", &WorldViewProj);
hr = DXUTGetD3D9Device()->SetIndices(mesh->m_IB9);
hr = DXUTGetD3D9Device()->SetStreamSource(0, mesh->m_VB9, 0, sizeof(D3DXVECTOR3));
hr = m_pREffect->Begin(&passes, 0);
for(unsigned int iPass = 0; iPass < passes; iPass++)
hr = m_pREffect->BeginPass(iPass);
hr = ::DXUTGetD3D9Device()->DrawIndexedPrimitive(D3DPT_TRIANGLELIST, 0, 0, mesh->m_Vertices.size(), 0, mesh->m_Indeces.size() / 3);

hr = m_pREffect->EndPass();
hr = m_pREffect->End();

void Renderer9::VUpdateIndexBuffer(RE_Mesh * mesh)
if(mesh->m_IB9 == NULL)
hr = DXUTGetD3D9Device()->CreateIndexBuffer(mesh->m_Indeces.size(), D3DUSAGE_WRITEONLY, D3DFMT_INDEX32, D3DPOOL_DEFAULT, &mesh->m_IB9, 0);
unsigned int * indeces = NULL;
mesh->m_IB9->Lock(0, mesh->m_Indeces.size(), (void **)&indeces, 0);
std::copy( mesh->m_Indeces.begin(), mesh->m_Indeces.end(), indeces);
void Renderer9::VUpdateVertexBuffer(RE_Mesh * mesh)
if(mesh->m_VB9 == NULL)
hr = DXUTGetD3D9Device()->CreateVertexBuffer(mesh->m_Vertices.size() * sizeof(Vec3), D3DUSAGE_WRITEONLY, 0, D3DPOOL_DEFAULT, &mesh->m_VB9, 0);
Vec3 * vertices = NULL;
mesh->m_VB9->Lock(0, mesh->m_Vertices.size() * sizeof(Vec3), (void **)&vertices, 0);
std::copy( mesh->m_Vertices.begin(), mesh->m_Vertices.end(), vertices);
also RE_Mesh is keeping the indeces and vertices in std::vector,
If someone need more information and do not want to check the source cuz of the mess just ask. Thanks. Edited by Nickie

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  
Followers 0