Advertisement Jump to content
Sign in to follow this  

Drawing mesh freaks up everything?

This topic is 4878 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

I'm quite new to DirectX so my question may be stupid (damn those noobs!) ;-) The situation is the following: I'm rendering a simple triangle to screen. No problem. When the user presses a button a mesh (using the DX .x file system) should be rendered next to the triangle. But this does not happen! And it's even worse: When rendering the mesh is enabled, NOTHING is visible anymore (not even the triangle)...the scene is just empty. And when the button is pressed again (which turns the mesh off) the triangle doesn't come back :-( So one call of "mesh->DrawSubset(0);" seems to screw up EVERYTHING. What could be the reason for this? Changes DrawSubset some renderstates? (actually I don't believe that this could be the problem...) Any help is welcome :-D Thanks!

Share this post

Link to post
Share on other sites
There are many things that might cause this problem.
Check if the .X file is in the build directory.
Also run the debugger and check for errors there.
Check if D3DXLoadMeshFromX succeeds.

Do you have any kind of error check system to check for errors? If not try to use one, it will save a lot of your time.

[Edited by - Calin on September 14, 2005 2:44:26 PM]

Share this post

Link to post
Share on other sites
Hi there VanKurt,
How are you doing buddy?

The Problem
Rendering mesh and simple triangle are causing problem

The Solution
A few things to check.

Does your triangle have normals?
This may cause problems if you are rendering the mesh with lights and never
reset the light state back to false.
eg: Render triangle with lighting disabled (triangle renders)
Then you render the mesh when the key is pressed and enabling
lighting (triangle dissapears) and mesh is rendered.
Now you press the key again but you haven't disabled the light and now
nothing renders meaning that the triangle doesn't render since it doesn't
have normal information

So what you need to do is
Disable light when the triangle is rendered... or give the triangle some
normal information

PS : Also check if the mesh is loaded correctly like Calin suggested.

I hope this helps a bit buddy.

Share this post

Link to post
Share on other sites
Yo! Thank's a lot for your ideas.

AFAIK the mesh is loaded correctly. "mesh->GetNumFaces()" (and similar methods) all return correct information, and there are no errors.

Lighting is definately turned off because I'm calling "SetRenderState(D3DRS_LIGHTING,false);" every frame ;-)

Argh!! Any more ideas??

Share this post

Link to post
Share on other sites
Hi there buddy,
How are you doing (once again...)

The Problem
Rendering mesh and triangle.

The Solution
Follow the following checks
1) Try to get a mesh rendered.
2) Try to get a triangle rendered
3) Try and render both of these in the same begin/end scene calls

NOTE: Do not use the button to do the flipping/calling, just straight rendering. If you see that this is working. You know somewhere your input is messing with something and then let's move from there ;)

Take care buddy, Hope this helps.

Share this post

Link to post
Share on other sites
I have the same problem with my surface. It is working with the light on,..the normals were set all to up but when trying to render the mesh buf...only the mesh is rendered and the surface dissapears.

this is the way i'm rendering the mesh

For i = 0 To meshMaterials.Length - 1
' Set the material and texture for this subset
dev.Material = meshMaterials(i)
dev.SetTexture(0, meshTextures(i))

' Draw the mesh subset
Does the mesh have the normals set?ah

Share this post

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

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!