There is no square

Started by
14 comments, last by Evil Steve 19 years ago
...and no unhappy icon either. [sad] Disclaimer: Yes, I know the code is a mess, so on and so forth. There are a lot of things I could have done differently yadda yadda it doesn't conform to the standard blah blah and if anyone had to use this code professionally they'd probably sue because their eyes melted upon viewing it. Anyway; I'm trying to render in 3D. Right now I can render in 2D fine, however, when I attempt to use matrices and go into 3D, nothing gets rendered. Well, it renders (no error codes), you just can't see it. Naturally, this is bad. So, I've been preening over it with a bunch of different people, but still can't seem to figure out what's going wrong. The problem must be either in the FVF or the matrices, because that's the only thing that is changed between the 2D and 3D rendering.. modes? You get the drift. Anyway, it'd be too tedious for me to post the code here. So I packed it all away into a handy zip (DOWNLOAD NOW, 21.7KB) In the code, you'll see that a vertex buffer is set up, but its actually bypassed (Evil Steve wanted to rule out any problems in the VB) with a call to DrawPrimitiveUP. What else did we rule out... bah, I can't remember. Yeah, I know the code's a mess, but I'd really appreciate it if you could just take a look at it. At this point, I really don't expect anyone to find the problem, just because I tend to be a pessimestic bastard. But yeah, it pointless to code anything else at this point if nothing (3D) actually renders... Thanks for your help guys. EDIT: It has been brought to my attention that it doesn't even compile in modern compilers. I guess that's what I get for getting stuck with MSVC6, huh? EDIT2:
Quote:<Evil Steve> Direct3D8: (ERROR) :*** Exception in d:\builds\nt32_chk\multimedia\directx\dxg\d3d8\fe\vshader.cpp Line: 666 Evil Steve... <Evil Steve> Wtf <Mushu> lol 666 <Raymondo> oh my. <Mushu> in the vertex shader too <Raymondo> The antichrist knome is in your code. <Evil Steve> Ok, it errors at: <Evil Steve> if(FAILED(myDx->getDev()->DrawPrimitiveUP(D3DPT_TRIANGLESTRIP,2,verts,sizeof(sVertex_UL))))
Advertisement
Quote:Original post by Mushu
EDIT: It has been brought to my attention that it doesn't even compile in modern compilers. I guess that's what I get for getting stuck with MSVC6, huh?


To fix that all you (People helping out using VS7) need to do is make (cStateManager.h):
class cStateManager {	typedef struct sState {		void (*function)(cStateManager*, void*);		sState* next; 

Into:
class cStateManager {	protected:	typedef struct sState {		void (*function)(cStateManager*, void*);


Then it will compile at least. Now there will be one linker error so you need to go to Project->Properties->Linker and add "libci.lib" to the "Ignore Specific Library".

It will now compile, link, and run. As for the reason it is messed up, can't offer much help there since I don't have any DX skills, but if anything does come up...[wink]
Yes, this is the debug output it gives:

Direct3D8: (ERROR) :Stream 0 stride should match the stride, implied by the current vertex shader

The other thing I found was that your camera position is a bit shady. You have an eye position of (0, 20, 0) and are looking at (0,-1,0). But your rectangle is set up in 3D space at (0, 0, 100) to (200, 200, 100). It's definetly not going to be in view, because you are looking straight at the ground.
Dustin Franklin ( circlesoft :: KBase :: Mystic GD :: ApolloNL )
Quote:Original post by circlesoft
Yes, this is the debug output it gives:

Direct3D8: (ERROR) :Stream 0 stride should match the stride, implied by the current vertex shader
On my machine I just get the exception posted in Mushu's excerpt.
And setting the FVF just before the DPUP() call doesn't seem to help either, even though the FVF matches the stride...
Quote:Original post by circlesoft
The other thing I found was that your camera position is a bit shady. You have an eye position of (0, 20, 0) and are looking at (0,-1,0). But your rectangle is set up in 3D space at (0, 0, 100) to (200, 200, 100). It's definetly not going to be in view, because you are looking straight at the ground.

Oh, yeah, Steve had me change the z-values from 0 to 100 to check the z-buffer. Regardless, setting them back to 0 and putting the primitives back in the viewing region makes no difference, they still can't be seen. Nice catch, though.
Interesting... Trying to draw 0 primitives gives:
Quote:Direct3D8: (ERROR) :*** Exception in d:\builds\nt32_chk\multimedia\directx\dxg\d3d8\fe\d3dbase.cpp Line: 3455
Quote:Original post by Evil Steve
On my machine I just get the exception posted in Mushu's excerpt.

Do you have the debug runtime selected and output turned up?

Quote:And setting the FVF just before the DPUP() call doesn't seem to help either, even though the FVF matches the stride...

The vertex structure doesn't match the FVF, though. The FVF is:

D3DFVF_XYZ|D3DFVF_TEX0|D3DFVF_DIFFUSE

But the vertex structure is:

struct sVertex_UL {
D3DXVECTOR3 p;
D3DCOLOR c;
D3DXVECTOR2 t;
};

The vertex structure should be:

struct sVertex_UL {
D3DXVECTOR3 p;
D3DXVECTOR2 t;
D3DCOLOR c;
};
Dustin Franklin ( circlesoft :: KBase :: Mystic GD :: ApolloNL )
I think I figured it out [grin] I looked at NeHe's DX 9 code and did a little comparing.

In your: virtual void setState3D_UL(D3DXVECTOR3 eye=D3DXVECTOR3(0.0f,3.0f,-5.0f), D3DXVECTOR3 at=D3DXVECTOR3(0.0f,0.0f,0.0f)) { function in cDX.h I made these changes and it works now.
virtual void setState3D_UL(D3DXVECTOR3 eye=D3DXVECTOR3(0.0f,3.0f,-5.0f), D3DXVECTOR3 at=D3DXVECTOR3(0.0f,0.0f,0.0f)) {		D3DDevice->SetVertexShader(FVF_Vertex_UL);		D3DDevice->SetRenderState(D3DRS_LIGHTING, false);		D3DDevice->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE);		D3DDevice->SetRenderState(D3DRS_ZENABLE,  true);				/*D3DXMatrixIdentity(&matWorld);		D3DDevice->SetTransform(D3DTS_WORLD, &matWorld);		D3DXMatrixLookAtLH(&matView, &eye, &at, &D3DXVECTOR3(0.0f, 1.0f, 0.0f));		D3DDevice->SetTransform(D3DTS_VIEW, &matView);		D3DXMatrixPerspectiveFovLH(&matProj, D3DX_PI/4.0f, 1.0f, 1.0f, 1000.0f );		D3DDevice->SetTransform(D3DTS_PROJECTION, &matProj);*/		D3DXMATRIXA16 matProjection;						// Create A Projection Matrix		// Calculate The Aspect Ratio Of The Window		D3DXMatrixPerspectiveFovLH(&matProj, 45.0f, (float)640/(float)480, 0.1f, 100.0f );		D3DDevice->SetTransform( D3DTS_PROJECTION, &matProj );		D3DXMatrixIdentity(&matProj);	}


Here's the image. Don't ask me to explain [lol].
Quote:Original post by circlesoft
The vertex structure should be:

struct sVertex_UL {
D3DXVECTOR3 p;
D3DXVECTOR2 t;
D3DCOLOR c;
};

I'm pretty sure color comes before texture in Dx8.

Testing Drew_Benton's fixes.
Quote:Original post by circlesoft
Do you have the debug runtime selected and output turned up?
I found that if I click "continue" at the breakpoint, it carries on and gives the error you said.

I see the problem - circlesoft was right(ish). The FVF says TEX0 - no texture coords, but theres 1 set in the vertex struct.

I thought that colour comes before texture coords?

This topic is closed to new replies.

Advertisement