Ok got back to it...
I was able to compile Mista Wilson's code with no problems and it worked.
From comparing my code to his, I noticed everybody has thier own way to set the dbSyncMask value. That's probably what is confusing me the most and why my code or _Pauli_'s code isnt working for me.
_Paulie_: the C/C++ symbol ' ^ ' doesn't mean the "power of" like like in DBPro. In C/C++, it's a bitwise operator meaning Exclusive OR (XOR). But why it still works for you and not me is still a mystery to me.
Mista Wilson: I did the dbSyncMask like you did with the bit Left Shifting. That made Depth Texture completely black for me. So, I was able to see the rotating teapot and the box underneath it all textured, but no light, normal maps and shadow maps. Again,
So, I retried my method of OR'ing bits to the default MASK ( 0xFFFFFFFF) where I have this code:
dbSetCurrentCamera(0);
dbSetEffectTechnique(1,"DepthMap");
DWORD MASK=0xFFFFFFFF;
dbSyncMask(MASK |= (0x01 << 2)); dbFastSync();
if (dbKeyState(2)) dbPasteImage(4,0,0);
//Main Scene
dbSetEffectTechnique( 1,"ShadowMapping" );
MASK=0xFFFFFFFF;
dbSyncMask(MASK |= (0x01 << 1));
* As the DBPro docs explains ( Couldn't find it in the DGDK docs ) that in SyncMask bit 1 is camera 0, bit 2 is camera 1 and so on.
That ALMOST ran perfect for me!
Now, it runs at half speed ( or at 30 fps instead of 60fps ) and the whole screen flickers like from a white screen to the normal screen you are suppose to see... really bad. So, If ... some how ... I can figure that flickering out, then it will run exactly like evolves with that hexagon shape lighting/texturing or how ever it's doing that.
* It seems it all comes down on how to use dbSyncMask properly. I don't think I'm using it properly quite yet...
Here's my full updated code with the flickering problem...
#include "DarkGDK.h"
void DarkGDK ( void )
{
// For dynamic text
char *txt;
txt=new char[256];
//Set Up Display
int Sw=1024,Sh=768;
dbSetDisplayMode(Sw,Sh,32);
dbSetWindowPosition((dbDesktopWidth()/2)-(Sw/2),(dbDesktopHeight()/2)-(Sh/2));
dbSyncOn(); dbSyncRate(60);
dbHideMouse();
//Set Text
dbSetTextFont("Verdana");
dbSetTextSize(15);
dbSetTextToBold();
dbInk(dbRgb(200,200,0),0);
//Setup Camera
dbBackdropOn();
dbColorBackdrop(dbRgb(128,128,128));
dbAutoCamOff();
dbPositionCamera(0.0f,0.0f,-150.0f);
dbSetCameraFOV(100.0f);
dbXRotateCamera(30.0f);
float CamDis=-100.0f;
//Load Textures
int image=1;
dbLoadImage("Media\\Floor05.jpg",1);
dbLoadImage("Media\\Floor05n.jpg",2);
dbLoadImage("Media\\spotlight.bmp",3);
dbMakeCamera(1);
dbSetCameraToImage(1,4,512,512);
dbSetCameraFOV(1,80.0f);
dbSetCameraAspect(1,1.1f);
dbBackdropOff(1);
dbLoadImage("Media\\JitterMap.dds",5);
//Create Object
dbLoadEffect("FX\\ShadowMapping.fx",1,0);
int object=1;
dbLoadObject("Media\\t-pot.x",1);
dbScaleObject(1,4500.0f,4500.0f,4500.0f);
dbScaleObjectTexture(1,0,4.0f,3.0f);
dbTextureObject(1,0,1);
dbTextureObject(1,1,2);
dbTextureObject(1,2,3);
dbTextureObject(1,3,4);
dbTextureObject(1,4,5);
dbSetObjectEffect(1,1);
//Create floor
dbMakeObjectBox(2,500.0f,1.0f,500.0f);
dbPositionObject(2,0.0f,-65.0f,0.0f);
dbTextureObject(2,0,1);
dbTextureObject(2,1,2);
dbTextureObject(2,2,3);
dbTextureObject(2,3,4);
dbTextureObject(2,4,5);
dbScaleObjectTexture(2,0,5.0f,5.0f);
dbSetObjectEffect(2,1);
//Light
float LX=-56.0f, LY=200.0f, LZ=-26.0f;
float LaX=56.0f, LaY=83.0f, LaZ=0.0f;
bool Null=dbMakeMatrix4(1);
Null=dbMakeMatrix4(2);
Null=dbMakeMatrix4(3);
Null=dbMakeMatrix4(6);
// Declared Variables
int nopress=0, rotate=0;
//Start loop
while ( LoopGDK ( ) )
{
//Control Camera
dbPositionCamera(0.0f,0.0f,0.0f);
if (dbMouseClick()==0)
{
dbXRotateCamera( dbCameraAngleX()-(float)(dbMouseMoveY())*0.25f);
dbYRotateCamera( dbCameraAngleY()+(float)(dbMouseMoveX())*0.25f);
if (dbCameraAngleX()>80.0f) dbXRotateCamera(80.0f);
if (dbCameraAngleX()<-60.0f) dbXRotateCamera(-60.0f);
}
if (dbMouseClick()>0) CamDis=CamDis-(float)(dbMouseMoveY())*0.25f;
CamDis=CamDis+(float)(dbMouseMoveZ())*0.25f;
if (dbUpKey()) CamDis=CamDis+2.5f;
if (dbDownKey()) CamDis=CamDis-2.5f;
if (CamDis>-20.0f) CamDis=-20.0f;
if (CamDis<-300.0f) CamDis=-300.0f;
dbMoveCamera(CamDis);
if (dbCameraPositionY()<-60.0f) dbPositionCamera( dbCameraPositionX(),-60.0f, dbCameraPositionZ() );
//dbMouseMoveX()=0 // Function can NOT = something, but can return something...
//mousemovey()=0 // This is NOT setting mousemove to zero!
//Rotate object
if ((dbKeyState(19)) && (rotate==1) && (nopress==0)){ rotate=0; nopress=1; }
if ((dbKeyState(19)) && (rotate==0) && (nopress==0)){ rotate=1; nopress=1; }
if (rotate==0) dbRotateObject(1,0.0f,dbObjectAngleY(1)+0.5f,0.0f);
//Change Texture
if ((dbKeyState(20)) && (nopress==0))
{
dbDeleteImage(1); dbDeleteImage(2);
image+=1;
if (image>3) image=1;
if (image==1) { dbLoadImage("Media\\Floor05.jpg",1); dbLoadImage("Media\\Floor05n.jpg",2); }
if (image==2) { dbLoadImage("Media\\Floor29.jpg",1); dbLoadImage("Media\\Floor29n.jpg",2); }
if (image==3) { dbLoadImage("Media\\Mud.jpg",1); dbLoadImage("Media\\Mudn.jpg",2); }
dbTextureObject(1,0,1); dbTextureObject(1,1,2);
dbTextureObject(2,0,1); dbTextureObject(2,1,2);
nopress=1;
}
//Change Object
if ((dbSpaceKey()) && (nopress==0))
{
dbDeleteObject(1);
object+=1;
if (object>5) object=1;
if (object==1) { dbLoadObject("Media\\t-pot.x",1); dbScaleObject( 1,4500.0f,4500.0f,4500.0f ); dbScaleObjectTexture(1,0,4.0f,3.0f); }
if (object==2) { dbLoadObject("Media\\Tosus.x",1); dbScaleObjectTexture( 1,0,1.5f,1.0f ); }
if (object==3) dbMakeObjectBox(1,75.0f,75.0f,75.0f);
if (object==4) { dbMakeObjectSphere( 1,75.0f,40,40); dbScaleObjectTexture(1,0,2.0f,1.0f); }
if (object==5) { dbMakeObjectCylinder( 1,75.0f); dbScaleObjectTexture(1,0,3.0f,1.0f); }
dbTextureObject( 1,0,1 ); dbTextureObject( 1,1,2 ); dbTextureObject( 1,2,3 ); dbTextureObject( 1,3,4 ); dbTextureObject( 1,4,5 );
dbSetObjectEffect( 1,1 );
nopress=1;
}
if (dbScanCode()==0) nopress=0;
//Set spot Light to camera position
if (dbShiftKey())
{
LX=dbCameraPositionX(); LY=dbCameraPositionY(); LZ=dbCameraPositionZ();
LaX=dbCameraAngleX(); LaY=dbCameraAngleY(); LaZ=dbCameraAngleZ();
}
dbSetVector4( 6,LX,LY,LZ,0.0f );
dbSetEffectConstantVector( 1,"LightPosition",6 );
//Text
dbCenterText( Sw/2,15,"1 - Show Depth Texture Shift - Set Spot Light To Camera Space - Change Object T - Change Texture R - Rotate Object" );
sprintf_s(txt,256,"FPS %d",dbScreenFPS());
dbCenterText( Sw/2,40,txt);
//Set effects projection Matrix
dbSetCurrentCamera(1);
dbPositionCamera(1,LX,LY,LZ);
dbRotateCamera(1,LaX,LaY,LaZ);
dbViewMatrix4(1); dbProjectionMatrix4(2);
dbMultiplyMatrix4(3,1,2);
dbSetEffectConstantMatrix(1,"ProjMatrix",3);
dbSetCurrentCamera(0);
dbSetEffectTechnique(1,"DepthMap");
//dbSyncMask(1<<1);
//dbSyncMask(0);
DWORD MASK=0xFFFFFFFF;
dbSyncMask(MASK |= (0x01 << 2)); dbFastSync();
if (dbKeyState(2)) dbPasteImage(4,0,0);
//Main Scene
dbSetEffectTechnique( 1,"ShadowMapping" );
//dbSyncMask(1<<0);
//dbSyncMask(0);
MASK=0xFFFFFFFF;
dbSyncMask(MASK |= (0x01 << 1));
//End loop
dbSync();
}
delete [] txt;
return;
}