Jump to content
  • Advertisement
Sign in to follow this  
Medo Mex

Rendering .obj Model in DirectX 11

This topic is 1224 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello,

 

I'm trying to render a box model (.obj file) but I don't see anything, I have attached the project file.

Share this post


Link to post
Share on other sites
Advertisement
What is it you think is going to happen here? Do you think someone is going to download your project, set it up on their system, investigate and fix the issue then send back the fixed project, all from the goodness of their hearts?

What have you tried? What isn't working? Specific questions will get answers.

Share this post


Link to post
Share on other sites

@Aardvajk: The problem is: I don't see the model on the screen even I'm loading the vertices and setting up the vertex and index buffer

 

So, the best thing here is to post the code that I'm using.

 

FYI: This is just a simple project and it won't take 5 minutes to look it up.

 

Do you think someone is going to download your project, set it up on their system, investigate and fix the issue then send back the fixed project, all from the goodness of their hearts?

 

 

Yes, I'm expecting people here will help.

Edited by Medo3337

Share this post


Link to post
Share on other sites

If you would like someone to help you need to list what you've tried already, and what you think the problem might be. Narrow down the code shared to just the part where you think the problem is, and maybe try isolating problem parts in a stand alone test case.

 

Finally, voting down people for stating the brutally honest truth is a bit low, i wouldn't do it if I were you because the mods can see it...

Edited by braindigitalis

Share this post


Link to post
Share on other sites

@braindigitalis: What If I don't know where the problem is?

 

The only thing I see is that dev->CreateBuffer() is returning false when creating vertex or index buffer even both buffers was created successfully.

 

However, I'm not sure if the box is drawn or not (I see nothing on the screening)

int indexCount = vertexCount;
// Create vertex buffer
D3D11_BUFFER_DESC bd;
ZeroMemory(&bd, sizeof(D3D11_BUFFER_DESC));
bd.Usage = D3D11_USAGE_DYNAMIC;
bd.BindFlags = D3D11_BIND_VERTEX_BUFFER;
bd.ByteWidth = vertexCount * sizeof(VertexType);
bd.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
bool r = dev->CreateBuffer(&bd, NULL, &pVertexBuffer);

D3D11_MAPPED_SUBRESOURCE ms;
devcon->Map(pVertexBuffer, NULL, D3D11_MAP_WRITE_DISCARD, 0, &ms);
memcpy(ms.pData, &vertices, sizeof(vertices));
devcon->Unmap(pVertexBuffer, NULL);

// Create index buffer
D3D11_BUFFER_DESC indexBufferDESC;
//ZeroMemory(&indexBufferDESC, sizeof(indexBufferDESC));
indexBufferDESC.Usage = D3D11_USAGE_DEFAULT;
indexBufferDESC.ByteWidth = sizeof(unsigned long) * indexCount;
indexBufferDESC.BindFlags = D3D11_BIND_INDEX_BUFFER;
indexBufferDESC.CPUAccessFlags = 0;
indexBufferDESC.MiscFlags = 0;
indexBufferDESC.StructureByteStride = 0;


D3D11_SUBRESOURCE_DATA indexData;
indexData.pSysMem = indices;
indexData.SysMemPitch = 0;
indexData.SysMemSlicePitch = 0;

// Create the index buffer
result = dev->CreateBuffer(&indexBufferDESC, &indexData, &pIndexBuffer);
Edited by Medo3337

Share this post


Link to post
Share on other sites

Thanks, any idea why the zeromemory call is commented out? There are other fields in the index buffer you aren't filling that should all be zeroed. Does uncommenting that help at all?

Share this post


Link to post
Share on other sites

@braindigitalis: The 6 structure properties are filled, I even tried to uncomment the ZeroMemory() call but still nothing happens.

Share this post


Link to post
Share on other sites

You removed most of temp files from your project, I'll give you that. Usually people are unable to do even that.

 

I am unable to compile your project because I don't have D3DX, but there is something I have noticed:

  1. you aren't doing any transformations in your vertex shader, meaning it's not being transformed into the screen;
  2. your box is relatively far from (0, 0, 0) point, it won't be visible with 'default' camera transform.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!