Howdy folks, I recently bought dark shader and dark physics for the gdk and i've run into a few probs (most likely my fault being a noob) but I played around with a few things and thought i'd post my findings in hope that someone could tell me where i stuffed up.
http://forum.thegamecreators.com/?m=forum_view&t=123736&b=22&p=0 outlines my dark shader problem where the shaders don't seem to be working. I'm not trying to double post here but that problem kinda ties into my next which I thought deserved a new post as its not about shaders as much but more to do with both exp packs.
Ok, I got dark physics, tried to fire up the sample projects - didn't run at first straight outa the box (most likely my fault), after playing around with them I got them to work. Had to copy those 4 dlls into each sample folder and delete the demo .exe and recompile and they worked - so if your a noob and wondering, thats what i did.
Now the problem; dbPhyStart() and dbShaderDataStart() don't work together? I get 3 errors when compiling;
Quote: "1>DarkPhysics.lib(EngineSetup.obj) : error LNK2005: "char const * __cdecl GetDependencyID(int)" (?GetDependencyID@@YAPBDH@Z) already defined in shaderdata.lib(shaderdata.obj)
1>DarkPhysics.lib(EngineSetup.obj) : error LNK2005: "int __cdecl GetNumDependencies(void)" (?GetNumDependencies@@YAHXZ) already defined in shaderdata.lib(shaderdata.obj)
1> Creating library Debug\AshTek.lib and object Debug\AshTek.exp
1>Debug\AshTek.exe : fatal error LNK1169: one or more multiply defined symbols found"
I'm a noob, but guessing from the looks of that something is defined in both those functions/files that conflict with each other? If I comment out either function the program runs fine (other than my shader prob in the above post).
Also I'm using the 3d game template for visual C++ 2008 express and i had to change one or two settings in the project properties to get dark physics to compile without errors. Can't remember what they were off the top of my head, but i basically opened my templated project and the dark phys sample, pressed alt F7 in both and just flicked back and forward between the fields looking for whatever changes. Changed several fields in my project properties and dark physics worked - just mentioning it in case other noobs are reading with the same probs.
Heres my code;
// AshTek
// GDK Includes
#include "DarkGDK.h"
// MY Includes
#include "Main.h"
// LUA Includes
#include "lua_plugin.h"
#pragma comment ( lib, "Barnski'sLuaPlugin_debug.lib" )
// Dark Shader includes
#include "ShaderData.h"
#pragma comment ( lib, "shaderdata.lib" )
// Dark Physics
#include "DarkPhysics.h"
#pragma comment ( lib, "DarkPhysics.lib" )
// the main entry point for the application is this function
void DarkGDK(void)
{
// set up initial variables
// this MUST be at the top of the DarkGDK() function
Set_Initial_Variables();
// load main app settings
Load_App_Settings();
dbShaderDataStart();
MakeCube();
// now we come to our main loop, we call LoopGDK so some internal
// work can be carried out by the GDK
while (LoopGDK())
{
SpinCube();
dbSyncMask(0x001);
// update screen
//dbPhyUpdate();
dbSync();
// if the error report function sez theres an error, better to stop and report it rather than
// run with undesired effects.
if (true == Error_Report.bError) return;
}
// and now everything is ready to return back to Windows
return;
}
void MakeCube(void)
{
dbMakeObjectCube(1,50);
//dbLoadEffect("test.fx",1,1);
//dbSetObjectEffect(1,1);
dbSetEffectOn(1,"test.fx",1);
/*
dbMakeObjectBox( 10, 50, 1, 50 );
dbPositionObject( 10, 0, -10, 0 );
dbPhyMakeRigidBodyStaticBox ( 10 );
dbPhyMakeMaterial ( 1, "sticky" );
dbPhySetMaterialStaticFriction ( 1, 25.0 );
dbPhySetMaterialRestitution ( 1, 0.0 );
dbPhySetMaterialDynamicFriction ( 1, 1.0 );
dbPhyBuildMaterial ( 1 );
int phy = 0;
int y = 0;
int x = 0;
int z = 0;
int a = 0;
int b = 0;
// now lets create our objects
y = 20;
x = 0;
z = 0;
for ( a = 100; a <= 500; a++ )
{
b = dbRnd( 2 );
if ( b == 1 )
{
dbMakeObjectSphere( a, 5 );
}
else
{
dbMakeObjectCube( a, 2.5 );
}
dbPositionObject( a, x, y, z );
dbColorObject( a, dbRGB( dbRnd( 255 ), dbRnd( 255 ), dbRnd( 255 ) ) );
//dbSetObjectSpecular( a, dbRGB( dbRnd( 255 ), dbRnd( 255 ), dbRnd( 255 ) ) );
//dbSetObjectSpecularPower( a, 255 );
//dbSetObjectAmbient( a, 0 );
if ( b == 1 )
{
dbPhyMakeRigidBodyDynamicSphere ( a, 1 );
}
else
{
dbPhyMakeRigidBodyDynamicBox ( a, 1 );
}
x = -25 + dbRnd( 50 );
y = y + 5;
z = -25 + dbRnd( 50 );
}
// position and rotate the camera
dbPositionCamera( -46.8, 26.8, -49 );
dbRotateCamera( 34.7, 46.4, 0 );
*/
}
void SpinCube(void)
{
dbYRotateObject(1,dbWrapValue(dbObjectAngleY(1))+0.2);
}
// set up all initial variables and constructors for structures .ect
void Set_Initial_Variables(void)
{
// set up error reporting function
Error_Report.bError = false;
// remove the crash file.
Purge_Crash_File();
}
// function to find free gdk numbers
int Free_Number(int iType)
{
// set up intial increment variable
int iInc = 1;
// begin the loop
do
{
// if type is 0 (zero), then check to see if there is a free IMAGE number
if (0 == iType)
{
if (0 == dbImageExist(iInc)) return iInc;
}
// if type is 1 (one), then check to see if there is a free FILE number
if (1 == iType)
{
if (0 == dbFileOpen(iInc)) return iInc;
}
// increment the variable so we can check again
iInc++;
}
// if after searching for a free number nothing is found, then exit once the loop reaches the maximum
// search range - this prevents an infinite loop - i think.
while (iInc <= iMaxFreeNumberSearch);
// if the loop check fails to find a free number, then we have to return a default value of 0 (zero)
// and tell the user that we failed.
return 0;
}
// error reporting function
void Report_Error(char* cError, int iType)
{
// check to see if the error file exists, if so, delete it
int iFileExist = dbFileExist("crash.txt");
if (1 == iFileExist) dbDeleteFile("crash.txt");
// make the crash file
int iCrashFile = Free_Number(1);
dbOpenToWrite(iCrashFile, "crash.txt");
// write the error
dbWriteString(iCrashFile, cError);
// write additional error info
if (0 == iType)
{
dbWriteString(iCrashFile, "File does not exist!");
}
// close the file when we're finished
dbCloseFile(iCrashFile);
// let the main app loop know we have a problem so the program can exit
// this is because sometimes the error is defaulted by the gdk so the program still
// runs but with crappy results, this could trick us so its best to just exit and say what stuffed up
Error_Report.bError = true;
}
// error purge function to remove the crash file when the program loads
void Purge_Crash_File(void)
{
if (1 == dbFileExist("crash.txt")) dbDeleteFile("crash.txt");
}
// Set up the general application settings
void Load_App_Settings(void)
{
// get the screen resolution settings from the config file and set it
int iScreenResX = LUA_Get_Int("config.cfg", "Screen_Res_X");
int iScreenResY = LUA_Get_Int("config.cfg", "Screen_Res_Y");
int iScreenDepth = LUA_Get_Int("config.cfg", "Screen_Depth");
dbSetDisplayMode(iScreenResX, iScreenResY, iScreenDepth);
// position the app window at the top left
dbSetWindowPosition(0, 0);
// set window title
dbSetWindowTitle("AshTek - 0.0.1b");
// background on
dbBackdropOn();
// turn off autocam
dbAutoCamOff();
// turn on manual screen syncing
dbSyncOn();
dbSyncRate(0); // <--- set this to 60 in final, leave at 0 for developing
// randomize the timer so we get more random results when using it???
dbRandomize(dbTimer());
// PHYSX
dbPhyStart();
}
int LUA_Get_Int(char* cFile, char* cField)
{
// make the LUA interface
lua::make();
// check to see if the config file exists, otherwise exit and report error.
int iErrorCheck = dbFileExist(cFile);
if (1 == iErrorCheck)
{
// load the file
lua::load_file(cFile);
}
else
{
// report the error
Report_Error(cFile, 0);
return 0;
}
// get the value from the file variable
int iReturn = lua::get_int(cField);
// close the LUA interface
lua::terminate_lua();
// return the file variable value
return iReturn;
}
I was lazy and just commenting out/in either the shader or physics stuff in the MakeCube() function to try and get em to work. In the end dark physics seems to be working perfectly but my shader still doesn't work.
I've got all me files and includes .ect in the right dirs. Its prolly just something simple like calling a function in the wrong place. Any help?