Archived

This topic is now archived and is closed to further replies.

Dave2001

Programming WEIRDNESS

Recommended Posts

Ok, I''m can''t figure out what is wrong with my code. Here it is: D3DTLVERTEX square2[4]; x3 = 216; y3 = 280; // ... set the values (x3 and y3 are NOT set again and no memory operations are being done)... // Then, it comes here: square2[0].sx = x3; square2[1].sx = x3+200; square2[2].sx = x3; square2[3].sx = x3+200; square2[0].sy = y3; square2[1].sy = y3; square2[2].sy = y3+200; square2[3].sy = y3+200; lpd3dDev->SetTexture (0, GetTexture("3P")); lpd3dDev->DrawPrimitive (D3DPT_TRIANGLESTRIP, D3DFVF_TLVERTEX, square2, 4, 0); This is the problem: square2[3] does not render at the coordinates (216+200,280+200)! I can''t debug because every time I open a file for writing it starts working! What could I be doing wrong? Dave2001, MAILTO(Forrester6@msn.com);

Share this post


Link to post
Share on other sites
I''m not sure, but I think you did it backwards.

It''s supposed to be like this

1 3
2 4

That''s the order in which you''re supposed to render a square. (I could be wrong) Why don''t you try setting the Culling renderstate to False for debugging?

------------------------
Captured Reality

Share this post


Link to post
Share on other sites
Ok, the weirdness just got weirder! I just found out that if I set square[3], it changes NOTHING! I tried setting square[3].sy to 0, but the coordinate was still at the same point on the screen! (by the way, the way that you wanted me to render my polygons seems to require a counterclockwise culling.)

Dave2001,
MAILTO(Forrester6@msn.com);

Share this post


Link to post
Share on other sites
Actually, I''m pretty sure that you both have your vertices reversed. Remember that D3D is left-handed (by default culls faces with counterclockwise vertices). Try this:

1 3
0 2

(basically it needs to look like either an "N" or a "Z" (which is just a rotated ("N") to be visible.

However, the fact that things start working when you open a file is strange... Do you have culling turned off? If not, then you shouldn''t ever be seeing anything. Strange.

Share this post


Link to post
Share on other sites
Ok, this is REALLY MESSED UP! If I use the constructor for D3DTLVERTEX, it has a random chance of working. If I set the values myself, then it works all the time! WHY!?

Here's the complete code of that section:

[SOURCE]
lpd3dDev->SetRenderState (D3DRENDERSTATE_ALPHABLENDENABLE, FALSE);
lpd3dDev->SetRenderState (D3DRENDERSTATE_CULLMODE, D3DCULL_NONE);
D3DTLVERTEX square[4];


// THIS DOESN'T WORK:
/*square[0] = D3DTLVERTEX (D3DVECTOR(0,0,0), 1.0f, RGBA_MAKE(0,128,255,BYTE(alpha+alphaplus)), RGB_MAKE(0,0,0), 0.0f, 1.0f);
square[1] = D3DTLVERTEX (D3DVECTOR(0,0,0), 1.0f, RGBA_MAKE(0,128,255,BYTE(alpha+alphaplus)), RGB_MAKE(0,0,0), 0.0f, 0.0f);
square[2] = D3DTLVERTEX (D3DVECTOR(0,0,0), 1.0f, RGBA_MAKE(0,128,255,BYTE(alpha+alphaplus)), RGB_MAKE(0,0,0), 1.0f, 1.0f);

// When I use this, square[3] on the first triangle is set to whatever I set it to here! Why doesn't it get reset below?
square[3] = D3DTLVERTEX (D3DVECTOR(0,0,0), 1.0f, RGBA_MAKE(0,128,255,BYTE(alpha+alphaplus)), RGB_MAKE(0,0,0), 1.0f, 0.0f);*/

// This always works:
square[0].color = RGBA_MAKE(0,128,255,BYTE(alpha+alphaplus));
square[1].color = RGBA_MAKE(0,128,255,BYTE(alpha+alphaplus));
square[2].color = RGBA_MAKE(0,128,255,BYTE(alpha+alphaplus));
square[3].color = RGBA_MAKE(0,128,255,BYTE(alpha+alphaplus));
square[0].sz = 0;
square[1].sz = 0;
square[2].sz = 0;
square[3].sz = 0;
square[0].rhw = 1;
square[1].rhw = 1;
square[2].rhw = 1;
square[3].rhw = 1;
square[0].specular = RGB_MAKE(0,0,0);
square[1].specular = RGB_MAKE(0,0,0);
square[2].specular = RGB_MAKE(0,0,0);
square[3].specular = RGB_MAKE(0,0,0);
square[0].tu = 0.0f;
square[0].tv = 1.0f;
square[1].tu = 0.0f;
square[1].tv = 0.0f;
square[2].tu = 1.0f;
square[2].tv = 1.0f;
square[3].tu = 1.0f;
square[3].tv = 0.0f;

square[0].sx = x2;
square[1].sx = x2;
square[2].sx = x2+200;
square[3].sx = x2+200;
square[0].sy = y2+200;
square[1].sy = y2;
square[2].sy = y2+200;
square[3].sy = y2;
lpd3dDev->SetTexture (0, GetTexture("2P"));
lpd3dDev->SetTextureStageState (0, D3DTSS_COLOROP, D3DTOP_SELECTARG1);
lpd3dDev->SetTextureStageState (0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
lpd3dDev->SetTextureStageState (1, D3DTSS_COLOROP, D3DTOP_DISABLE);
lpd3dDev->DrawPrimitive (D3DPT_TRIANGLESTRIP, D3DFVF_TLVERTEX, square, 4, 0);

square[0].sx = x3;
square[1].sx = x3;
square[2].sx = x3+200;
square[3].sx = x3+200;
square[0].sy = y3+200;
square[1].sy = y3;
square[2].sy = y3+200;
square[3].sy = y3;

lpd3dDev->SetTexture (0, GetTexture("3P"));
lpd3dDev->DrawPrimitive (D3DPT_TRIANGLESTRIP, D3DFVF_TLVERTEX, square, 4, 0);

square[0].sx = x4;
square[1].sx = x4;
square[2].sx = x4+200;
square[3].sx = x4+200;
square[0].sy = y4+200;
square[1].sy = y4;
square[2].sy = y4+200;
square[3].sy = y4;
lpd3dDev->SetTexture (0, GetTexture("4P"));
lpd3dDev->DrawPrimitive (D3DPT_TRIANGLESTRIP, D3DFVF_TLVERTEX, square, 4, 0);
[\SOURCE]


Edited by - Dave2001 on July 25, 2000 12:35:53 PM

Share this post


Link to post
Share on other sites