I have DarkGDK commercial (single-seat license)2.0RC4.
VC++ 2010 and winXP, win7
I have error on this :
typedef void (__cdecl *ProtodbSync_2)(int32_t fastSync, int32_t updateAnimations);
void dbSync(int32_t fastSync, int32_t updateAnimations) {
static ProtodbSync_2 Ptr;
if (!Ptr && !GDKLoadPtr(&Ptr,"darkgdk.dll","dbSync"))
return;
if (GDKWaitFunction()) {
Ptr(fastSync, updateAnimations);
GDKCleanupFunctionCall();
}
return;
}
I make C++ code for water DB example (shader reflection):
This work fine in DB!
Rem ***** Main Source File *****
Autocam OFf
Sync On
Backdrop On
Set Camera Range 0, 0.1, 50000
`Make Skybox
load object "data/skybox.x",6
set object light 6,0
scale object 6,20000,15000,20000
set object texture 6,2,1
set object cull 6,0
cameraCreateClipping(15000, 128)
shdrWater = freeEffect() : Load Effect "FX/Fresnel Water.fx", shdrWater, 0
Set Effect Constant Float shdrWater, "WaterBump", 0.1
Set Effect Constant Float shdrWater, "FresnelBias", 0.1
Set Effect Constant Float shdrWater, "FresnelScale", 2.5
null = Make Vector4(1)
Set Vector4 1, 10.0, 10.0, 0.0, 0.0 : Set Effect Constant Vector shdrWater, "WaterScale", 1
Set Vector4 1, -0.05, 0.0, 0.0, 0.0 : Set Effect Constant Vector shdrWater, "Speed1", 1
Set Vector4 1, 0.2, -0.02, 0.0, 0.0 : Set Effect Constant Vector shdrWater, "Speed2", 1
Set Vector4 1, 0.01, 0.01, 0.0, 0.0 : Set Effect Constant Vector shdrWater, "Speed3", 1
water = shdrCreateWaterPlain(50000, 50000, 270, shdrWater)
obj = freeObject()
Make Object Sphere obj, 50
Position Object obj, 0, 100, 100
Do
ax# = WrapValue(ax# + mouseMoveY())
ay# = WrapValue(ay# + mouseMoveX())
Rotate Camera ax#, ay#, 0.0
If MouseClick()=1
Move Camera 1
endif
If MouseClick()=2
Move Camera -1
endif
`Show Textures
if shiftkey()=1 then paste image imgClipCam1,0,0
if controlkey()=1 then paste image imgClipCam2,0,0
shdrUpdateWaterPlain(shdrWater, water, 0, 0, 0)
Position Object water, CAMERA POSITION X(), 0, CAMERA POSITION Z()
Sync
Loop
Function cameraCreateClipping(camRange As Integer, camImgSize As Byte)
For cam = 30 To 31
Make Camera cam
Set Camera Range cam, 1, camRange
Set Camera Aspect cam, 1.325
Set Camera Fov cam, 65
Backdrop Off cam
Next cam
GLOBAL imgClipCam1
GLOBAL imgClipCam2
imgClipCam1 = freeImage()
imgClipCam2 = imgClipCam1+1
// Set Camera To Image 30, imgClipCam1, camImgSize, camImgSize
Set Camera To Image 31, imgClipCam2, camImgSize, camImgSize
EndFunction
Function shdrCreateWaterPlain(w As Integer, h As Integer, ang As Word, effect As Integer)
img = freeImage() : Load Image "FX/waves.dds", img
obj = freeObject() : Make Object Plain obj, w, h
Texture Object obj, 0, img
// Texture Object obj, 1, imgClipCam1
Texture Object obj, 2, imgClipCam2
xRotate Object obj, ang
Set Object Effect obj, effect
Set Object Transparency obj, 1
`Ghost Object On obj, 0
EndFunction obj
Function shdrUpdateWaterPlain(shdrWater As Integer, obj As Integer, x As Float, y As Float, z As Float)
Position Object obj, x, y, z
camWaterY# = Camera Position Y() - y
Set Effect Technique shdrWater, "Reflect"
Hide Object obj
Position Camera 31, Camera Position X(), y-camWaterY#, Camera Position Z()
Rotate Camera 31, -Camera Angle X(), Camera Angle Y(), Camera Angle Z()
`Clip Camera
clipY# = camWaterY#
If clipY# > 100 Then clipY# = 100
//If camWaterY# => 0.0 Then clipIt = 1
//If camWaterY# < 0.0 Then clipIt = -1
` Set Camera Clip 31, 1, 0, y-(1+(clipY#/25)), 0, 0, 1, 0
Set Camera Clip 31, 1, 0, y-5, 0, 0, 1, 0
// Set Camera Clip 30,0,0,0,0,0,0,0
`Only sync Camera 31
Sync Mask 1<<31
`0x80000000
FastSync
Show Object obj
Sync Mask 0x3fffffff
EndFunction
My C++ code crash every time:
#ifndef WATER_CPP
#define WATER_CPP
#include <include/darkgdk/core/darkgdk.h>
#include <include/darkgdk/initDarkGDK.h>
#include <include/darkgdk/simpleWindow.h>
#include <include/darkgdk/plugins/dgdk-blitzterrain.h>
#include <include/darkgdk/plugins/dgdk-darkimposters.h>
#include <include/strutil/toStr.h>
#include <cstdlib>
#include <windows.h>
#include <iostream>
#include <fstream>
#include "water.h"
#include "object_id.h"
Vector4 WaterScale={100.0, 100.0, 0.0, 0.0};
Vector4 Speed1={-0.05, 0.0, 0.0, 0.0};
Vector4 Speed2={0.2, -0.02, 0.0, 0.0};
Vector4 Speed3={0.01, 0.01, 0.0, 0.0};
void CameraCreateClipping(int camRange , int camImgSize )
{
dbCreateBitmap ( camImgSize,camImgSize, WATER_TEXTURE );
dbCreateCamera(CamReflect);
int Sw = dbScreenWidth();
int Sh = dbScreenHeight();
dbSetCameraRange ( 1.0f, camRange, CamReflect );
dbSetCameraAspect ((Sw / Sh), CamReflect);
dbSetCameraFOV ( 85, CamReflect );
dbBackdropOff(CamReflect);
dbSetCameraToImage(CamReflect, WATER_TEXTURE, camImgSize, camImgSize);
dbSetCurrentBitmap (0);
}
void CreateWater(int objwater)
{
dbLoadImage ( "Resource/FX/waves.dds",0, WATER_BUMP);
//dbLoadImage ( "Resource/Textures/water1.jpg",0, WATER_TEXTURE);
dbLoadEffect("Resource/FX/FresnelWater.fx",0,0,WaterFX);
dbSetEffectConstantFloat(WaterFX ,"WaterBump", 0.1);
dbSetEffectConstantFloat(WaterFX ,"FresnelBias", 0.1);
dbSetEffectConstantFloat(WaterFX ,"FresnelScale", 0.2);
dbSetEffectConstantVector ( WaterFX, "WaterScale", &WaterScale);
dbSetEffectConstantVector ( WaterFX, "Speed1", &Speed1 );
dbSetEffectConstantVector ( WaterFX, "Speed2", &Speed2 );
dbSetEffectConstantVector ( WaterFX, "Speed3", &Speed3);
// dbSetEffectConstantFloat ( WaterFX, "WaterFogRange", 26000.0f );
dbCreateObjectPlane( 60000.0f, 60000.0f, 0, objwater);
//dbScaleObjectTexture ( objwater , 100 , 100);
dbTextureObject(objwater, WATER_TEXTURE ,2);
dbTextureObject(objwater, WATER_BUMP ,0);
dbXRotateObject( objwater,270);
dbSetObjectEffect(objwater,WaterFX);
dbSetObjectTransparency(objwater,1);
}
void UpdateWaterPlain( float x, float y, float z)
{
dbPositionObject(WATER_MODEL, x, y, z);
dbHideObject(WATER_MODEL);
dbSetEffectTechnique( WaterFX, "Reflect");
//====================================
dbPositionCamera(dbCameraPositionX(),y-(dbCameraPositionY()-y),dbCameraPositionZ(),CamReflect);
dbRotateCamera(-dbCameraAngleX(),dbCameraAngleY(),dbCameraAngleZ(),CamReflect);
dbSetCameraClip(CamReflect,1,0,y-5,0,0,1,0);
dbSyncMask(1 << CamReflect);
dbSync(true,false);
dbShowObject(WATER_MODEL);
dbSyncMask(1<<0);
}
#endif
help me please
zzz!