• Advertisement
Sign in to follow this  

Nothing is being drawn and I don't know why.

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

Oh blank screen, how I loathe you. There here 3D Engine of mine, written in C++ with the August 2006 SDK with Visual C++ 2005 Express Edition, is not displaying anything. I've gotten some help earlier with it, which ended up being something wrong with the model file I was loading. But this is a different, more confusing problem, and I have no idea what is wrong. As you can see, nothing is showing up. What should be showing up is three rectangles, set up using my engine a little like this:
Rectangle1->SetPosition( LXVECTOR4( 0.0f, 0.0f, 20.0f, 1.0f ) );
Rectangle2->SetPosition( LXVECTOR4( 0.0f, 2.0f, 20.0f, 1.0f ) );
Rectangle3->SetPosition( LXVECTOR4( 0.0f, -2.0f, 20.0f, 1.0f ) );

plxDevice->GetCamera()->SetPosition( 0.0f, 0.0f, -20.0f );
plxDevice->GetCamera()->SetClippingPlanes( 0.5f, 100.0f );
plxDevice->GetCamera()->LookAtPosition( Rectangle1->GetPosition() );
That's all there is in the scene. Nothing moves around, as this is merely a test program. Clearly my test is failing, thus far. Frankly, I am at a loss as to where this problem is occuring. I've tried many things, but nothing seems to fix it. The Debug Direct3D Runtime shows nothing out of the ordinary occuring, besides some redundant render state settings at the beginning. I thought it might have been the loading of my models and resources from disk. I do this neat thing where I put all of my models and shaders and textures into one file, and my engine extracts them out of it. All of that seems to work okay, but I thought it might be loading them malformed or something - I don't know. The loading code has worked fine in the past, maybe it was the files. So I hardcoded the model into the 3D Engine, and tried rendering that, and there was no change. I did the same for the vertex and pixel shaders I was using, and I get the same deal. I did not try doing both of these at the same time. I assume that the vertex and pixel shaders are loading fine, since the calls to make the IDirect3DVertexShader9 and IDirect3DPixelShader9 objects are returning successful. They are individual files created using a seperate compiler program I wrote that takes in an input file, uses D3DXAssembleShaderFromFile, and writes the output to a file, which the engine later loads. I believe that the vertex declaration is being set correctly. I'm calling BeginScene/EndScene/Present. I thought it might have been my view and projection matricies, since I've been implementing them myself instead of using the D3DX functions. I tried creating them through D3DX instead, but I still get the same blank screen. I did not try this in conjunction with hardcoding the shader or model. It shouldn't be the texture, since I've successfully loaded a texture using my engine before, even from my everything-in-one-big-file approach. I've looked through smaller, successful DirectX projects I've written before that draws stuff to the screen beautifully, and this newer, much larger, project isn't skipping any steps. So, really, I'm at a loss. If you have any ideas as to where and how a Direct3D application could potentially fail to draw it's scene, without any crashes or errors, I could use the help.

Share this post

Link to post
Share on other sites
First thing that pops to mind is that you're using a float4 for the position. Are you drawing Transformed vertices (POSITIONT)? If so, a z value of 20 may well clip them.

Here are a couple other possible issues:

- Make sure you're clearing the z-buffer
- Make sure you've got the cull mode set to None
- Make sure you set the World matrix to identity (or whatever)
- Make sure alphatesting, stencil testing, and clip planes are off
- Check the stream stride

That's about it, I think.
Hope this helps [smile].

Share this post

Link to post
Share on other sites
I made sure the render states are set as such, I'm clearing the Z-Buffer ( to 1.0f, pretty sure that is right.) Could it be something in the present parameters I used when I made the Direct3D device?

As for the float4, I've just been using float4's throughout just to be consistent - The shaders use float4's, matricies use float4's, etc. Figured I'd use them too - positions, rotations, etc, even if W is just set to 1.0f. My vertex format also uses a float4 for the position, normal, etc. Do you think that could be the problem?

EDIT: I used the Memory part of the debugger and confirmed that my model is loading correctly from disk - no weird numbers.

[Edited by - Kimani on October 16, 2006 8:21:02 PM]

Share this post

Link to post
Share on other sites
I found time to work on converting everything to use a vertex format that has a vec3 for the position. Still, nothing shows up.

I've tried hardcoding the following shader pair into my code:
dcl_position0 v0
dcl_texcoord0 v2
m4x4 oPos, v0, c6
mov oT0.xy, v2.xy

tex t0
mov r0, t0

The simplest thing possible. The worldviewproj matrix is in c6. And still nothing shows up.

I tried playing around with the worldviewproj matrix. Check to see if these calculations for the view and proj matricies are correct:

//m_vUpVector is the up vector for the camera
//m_vDirection is the normalized direction the camera is poiting
//m_vPosition is the position of the camera
//m_fYScale is 1.0f / tan( m_fFOV * 0.5f ) with m_fFOV being the field of vision.
//m_fXScale is m_fYScale * windowheight/windowwidth.
//m_fFarOverDiff is m_fFarClip / ( m_fFarClip - m_fNearClip ) with farclip and near clip being the far and near clipping plane values.
//m_fNegNearFarOverDiff is -1.0f * m_fNearClip * m_fFarOverDiff;

xAxis.Cross( m_vUpVector, m_vDirection ).Normalize();
yAxis.Cross( m_vDirection, xAxis );

m_mViewMatrix._11 = xAxis.x;
m_mViewMatrix._21 = xAxis.y;
m_mViewMatrix._31 = xAxis.z;
m_mViewMatrix._41 = - ( xAxis * m_vPosition );

m_mViewMatrix._12 = yAxis.x;
m_mViewMatrix._22 = yAxis.y;
m_mViewMatrix._32 = yAxis.z;
m_mViewMatrix._42 = - ( yAxis * m_vPosition );

m_mViewMatrix._13 = m_vDirection.x;
m_mViewMatrix._23 = m_vDirection.y;
m_mViewMatrix._33 = m_vDirection.z;
m_mViewMatrix._43 = - ( m_vDirection * m_vPosition );

m_mViewMatrix._14 = 0.0f;
m_mViewMatrix._24 = 0.0f;
m_mViewMatrix._34 = 0.0f;
m_mViewMatrix._44 = 1.0f;

// Update View Proj Matrix
// =======================


mProj._11 = m_fXScale;
mProj._21 = 0.0f;
mProj._31 = 0.0f;
mProj._41 = 0.0f;

mProj._12 = 0.0f;
mProj._22 = m_fYScale;
mProj._32 = 0.0f;
mProj._42 = 0.0f;

mProj._13 = 0.0f;
mProj._23 = 0.0f;
mProj._33 = m_fFarOverDiff;
mProj._43 = m_fNegNearFarOverDiff;

mProj._14 = 0.0f;
mProj._24 = 0.0f;
mProj._34 = 1.0f;
mProj._44 = 0.0f;

m_mViewProjMatrix = m_mViewMatrix * mProj;

Again, the DirectX Debug Runtime is showing nothing wrong. No errors. Is there something I'm missing? Maybe I'm forgetting to set something somewhere.

Perhaps my present parameters are off? Although I have a bunch of decision making code depending on how you want to initialize the 3D engine, I cut out all that just to get the meat of how I'm setting my parameters, except for some little bit. This should be what my D3DPRESENT_PARAMETERS looks like:

ZeroMemory( &d3dpp, sizeof( d3dpp ) );

d3dpp.BackBufferWidth = 800;
d3dpp.BackBufferHeight = 600;
d3dpp.BackBufferCount = 1;
d3dpp.BackBufferFormat = D3DFMT_UNKNOWN;
d3dpp.MultiSampleType = D3DMULTISAMPLE_NONE;

DWORD QualityLevels;
m_pd3d->CheckDeviceMultiSampleType( D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, D3DFMT_A8R8G8B8,
true, d3dpp.MultiSampleType, &QualityLevels );

d3dpp.MultiSampleQuality = ( (QualityLevels - 1) > 0 ? (QualityLevels - 1) : 0 );

d3dpp.hDeviceWindow = m_hWindowHandle;
d3dpp.Windowed = true;
d3dpp.EnableAutoDepthStencil = true;
d3dpp.AutoDepthStencilFormat = D3DFMT_D24S8; // 24 bit depth buffer, 8 bit stencil buffer
d3dpp.FullScreen_RefreshRateInHz = 0;
d3dpp.PresentationInterval = D3DPRESENT_INTERVAL_ONE;

Is there anything anyone sees as being wrong? Is it because I'm loading the engine from a DLL, perhaps?

[Edited by - Kimani on October 21, 2006 7:20:11 PM]

Share this post

Link to post
Share on other sites
Try using the PIX utility that comes with the DirectX SDK. It's a great tool for helping you figure out why you're not rendering what you expect.

The new version of PIX supports shader debugging now.

Share this post

Link to post
Share on other sites
This is indeed one hell of a tool. After fiddling with it to see how it works, I found some anomalies. What is this -1.#IO thing?


The first picture shows on the bottom right my floating point vertex shader registers. 6-9 is my world view proj matrix, set with:

m_pd3dDevice->SetVertexShaderConstantF( 6, (float*)&( m_pOpaqueNormalGroups[x].Objects[y]->m_mWorldViewProj.TransposeOf() ), 4 );

That gets the matrix it does. I'm pretty sure I have to transpose it, as I've done such D3DXMATRIX's when I made my test programs a while back. Most of it is this weird -1.#IO value, although some of them seem valid.


This shows the output of drawing my rectangle in the bottom corner - what each vertex is getting outputted as. It's clearly being output as this -1.#IO value, and I dont think I like that very much >:(

Any ideas?

Share this post

Link to post
Share on other sites


Well, it would seem that after further inspection, -1.#IO is like infinity or something. More specifically, it is what you get when you take 0 / ( 0-0 ).

I calculate the scaling for my objects. In the file for the model, I neglected to put in data for the overall AABB bounding box for the model that lets me know how many units tall it is, in order to scale it. I also never set the height for the object. So height / ( maxpoint - minpoint ) ended up being infinity or whatever, and messed up my matricies. Very strange that it didn't crash, with the whole dividing by zero thing and all.

But yes, PIX was highly instrumental in the narrowing down of this problem which has haunted me for weeks. I thank you for your help.

And yes, the rectangles are supposed to be white, they have a plain white texture on them. Now that it's working, the real fun begins : )

Share this post

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

  • Advertisement