I am trying to build plug-in wrappers for Dark GDK.NET. But I need a C++ GURU to look at what I am doing and help me figure out what I am doing wrong. I have DARK GDK.NET and using it with Visual Studio 2010, 2012, etc. Functions should be callable from C# and VB.NET.
When I try copying the finished .DLL to the project BIN directory, none of the functions are listed. Tried different things I am finding with Google searching but keep getting compiler errors.
I am very new to C++ programming and will only be using to make these wrappers so DARK GDK.NET can make use of plug-ins. If we can figure it out, it may be more profitable to those that make plug-ins.
There seems to be a serious lack of support to get DarkGDK.NET to work with Visual Studio.
C++ Code Snippets
Stdafx.cpp
// stdafx.cpp : source file that includes just the standard includes
// MyDll.pch will be the pre-compiled header
// stdafx.obj will contain the pre-compiled type information
#include "stdafx.h"
BlitzTerrain.h
#ifndef _BLITZWERKSTERRAIN_INCLUDED
#define _BLITZWERKSTERRAIN_INCLUDED
//#ifdef __cplusplus
// extern "C"
//{
//#endif
//Functions
void BT_Init();
extern "C"
__declspec(dllexport) unsigned long BT_MakeTerrain(void);
__declspec(dllexport) void BT_SetTerrainHeightmap(unsigned long terrainid,unsigned long image);
__declspec(dllexport) void BT_SetTerrainTexture(unsigned long terrainid,unsigned long image);
__declspec(dllexport) void BT_SetTerrainExclusion(unsigned long terrainid,unsigned long image);
__declspec(dllexport) void BT_SetTerrainExclusionThreshold(unsigned long terrainid,unsigned long threshold);
__declspec(dllexport) void BT_SetTerrainDetail(unsigned long terrainid,unsigned long image);
__declspec(dllexport) void BT_SetTerrainDetailBlendMode(unsigned long terrainid,unsigned char mode);
__declspec(dllexport) void BT_SetTerrainEnvironment(unsigned long terrainid,unsigned long image);
__declspec(dllexport) unsigned long BT_AddTerrainEnvironment(unsigned long terrainid,unsigned long Colour);
__declspec(dllexport) void BT_SetTerrainLOD(unsigned long terrainid,unsigned char LODLevels);
__declspec(dllexport) void BT_SetTerrainSplit(unsigned long terrainid,unsigned long Split);
__declspec(dllexport) void BT_SetTerrainDetailTile(unsigned long terrainid,float Tile);
__declspec(dllexport) void BT_SetTerrainQuadReduction(unsigned long terrainid,float Amount);
__declspec(dllexport) void BT_SetTerrainQuadRotation(unsigned long terrainid,bool Enabled);
__declspec(dllexport) void BT_SetTerrainSmoothing(unsigned long terrainid,unsigned long Amount);
__declspec(dllexport) void BT_SetTerrainScale(unsigned long terrainid,float Scale);
__declspec(dllexport) void BT_SetTerrainYScale(unsigned long terrainid,float YScale);
__declspec(dllexport) void BT_SetTerrainLODDistance(unsigned long terrainid,unsigned char LODLevel,float value);
__declspec(dllexport) void BT_BuildTerrain(unsigned long terrainid,unsigned long ObjectID);
__declspec(dllexport) void BT_BuildTerrain(unsigned long terrainid,unsigned long ObjectID,bool GenerateTerrain);
__declspec(dllexport) int BT_ContinueBuild(void);
__declspec(dllexport) unsigned long BT_TerrainExist(unsigned long TerrainID);
__declspec(dllexport) void BT_DeleteTerrain(unsigned long TerrainID);
__declspec(dllexport) float BT_GetGroundHeight(unsigned long terrainid,float x,float z);
__declspec(dllexport) float BT_GetTerrainSize(unsigned long terrainid);
__declspec(dllexport) unsigned long BT_GetPointExcluded(unsigned long terrainid,float x,float z);
__declspec(dllexport) unsigned long BT_GetPointEnvironment(unsigned long terrainid,float x,float z);
__declspec(dllexport) char* BT_GetVersion(void);
__declspec(dllexport) void BT_SetBuildStep(unsigned long step);
__declspec(dllexport) void BT_SetATMode(bool ATMode);
__declspec(dllexport) void BT_EnableAutoRender(bool AutoRender);
__declspec(dllexport) unsigned long BT_GetStatistic(unsigned long code);
__declspec(dllexport) unsigned long BT_GetTerrainObjectID(unsigned long terrainid);
__declspec(dllexport) void BT_MakeSectorObject(unsigned long terrainid,unsigned long LODLevel,unsigned long SectorID,unsigned long ObjectID);
__declspec(dllexport) void BT_MakeTerrainObject(unsigned long terrainid,unsigned long LODLevel,unsigned long ObjectID);
__declspec(dllexport) float BT_GetSectorPositionX(unsigned long terrainid,unsigned long LODLevel,unsigned long SectorID);
__declspec(dllexport) float BT_GetSectorPositionY(unsigned long terrainid,unsigned long LODLevel,unsigned long SectorID);
__declspec(dllexport) float BT_GetSectorPositionZ(unsigned long terrainid,unsigned long LODLevel,unsigned long SectorID);
__declspec(dllexport) unsigned long BT_GetSectorCount(unsigned long TerrainID,unsigned long LODLevel);
__declspec(dllexport) float BT_GetSectorSize(unsigned long TerrainID,unsigned long LODLevel);
__declspec(dllexport) unsigned long BT_GetSectorExcluded(unsigned long terrainid,unsigned long LODLevel,unsigned long SectorID);
__declspec(dllexport) unsigned long BT_GetSectorRow(unsigned long terrainid,unsigned long LODLevel,unsigned long SectorID);
__declspec(dllexport) unsigned long BT_GetSectorCollumn(unsigned long terrainid,unsigned long LODLevel,unsigned long SectorID);
__declspec(dllexport) void BT_SetCurrentCamera(unsigned long CameraID);
__declspec(dllexport) void BT_UpdateTerrainLOD(unsigned long TerrainID);
__declspec(dllexport) void BT_UpdateTerrainCull(unsigned long TerrainID);
__declspec(dllexport) void BT_UpdateTerrain(unsigned long TerrainID);
__declspec(dllexport) void BT_RenderTerrain(unsigned long TerrainID);
__declspec(dllexport) unsigned long BT_LoadTerrain(char* FileName,unsigned long ObjectID);
__declspec(dllexport) unsigned long BT_LoadTerrain(char* FileName,unsigned long ObjectID,bool GenerateTerrain);
__declspec(dllexport) void BT_SaveTerrain(unsigned long TerrainID,char* FileName);
//RTTMS functions
#ifdef BT_USINGRTTMS
void BT_LockVertexdataForSector(unsigned long TerrainID,unsigned long LODLevelID,unsigned long SectorID);
unsigned long BT_LockedASector();
unsigned long BT_GetLockedTerrain();
unsigned long BT_GetLockedLODLevel();
unsigned long BT_GetLockedSector();
void BT_UnlockVertexData();
unsigned short BT_GetVertexCount();
unsigned long BT_GetIndexCount();
unsigned short BT_GetIndex(unsigned long IndexID);
__declspec(dllexport) float BT_GetVertexPositionX(unsigned short VertexID);
__declspec(dllexport) float BT_GetVertexPositionX(unsigned short Vrow,unsigned short Vcol);
__declspec(dllexport) float BT_GetVertexPositionY(unsigned short VertexID);
__declspec(dllexport) float BT_GetVertexPositionY(unsigned short Vrow,unsigned short Vcol);
__declspec(dllexport) float BT_GetVertexPositionZ(unsigned short VertexID);
__declspec(dllexport) float BT_GetVertexPositionZ(unsigned short Vrow,unsigned short Vcol);
__declspec(dllexport) void BT_SetVertexHeight(unsigned short VertexID,float Height);
__declspec(dllexport) void BT_SetVertexHeight(unsigned short Vrow,unsigned short Vcol,float Height);
__declspec(dllexport) void BT_SetPointHeight(unsigned long TerrainID,unsigned long TVrow,unsigned long TVcol,float Height);
__declspec(dllexport) void BT_SetGroundHeight(unsigned long TerrainID,float X,float Z,float Height);
__declspec(dllexport) void BT_RaiseTerrain(unsigned long TerrainID,float X,float Z,float Radius,float Amount);
__declspec(dllexport) void BT_FlattenTerrain(unsigned long TerrainID,float X,float Z,float Radius);
__declspec(dllexport) void BT_PaintTerrain(unsigned long TerrainID,float X,float Z,float Radius,unsigned long Colour);
__declspec(dllexport) void BT_PaintTerrain(unsigned long TerrainID,float X,float Z,float Radius,unsigned long MinColour,unsigned long MaxColour);
__declspec(dllexport) void BT_SetPointColour(unsigned long TerrainID,float X,float Z,unsigned long Colour);
__declspec(dllexport) void BT_UpdateTerrainTexture(unsigned long TerrainID);
#endif
//Libraries
#pragma comment(lib,"BlitzTerrain.lib")
#pragma comment(lib,"BlitzTerrainRTTMS.lib")
//Classes
namespace BT {
public class BT_Terrain
{
public:
BT_Terrain() {ItsID=BT_MakeTerrain();}
BT_Terrain(char* FileName,unsigned long ObjectID) {ItsID=BT_LoadTerrain(FileName,ObjectID);}
BT_Terrain(char* FileName,unsigned long ObjectID,bool BuildFully) {ItsID=BT_LoadTerrain(FileName,ObjectID,BuildFully);}
~BT_Terrain() {BT_DeleteTerrain(ItsID);}
unsigned long GetID() {return ItsID;}
void SetHeightmap(unsigned long image) {BT_SetTerrainHeightmap(ItsID,image);}
void SetTexture(unsigned long image) {BT_SetTerrainTexture(ItsID,image);}
void SetExclusion(unsigned long image) {BT_SetTerrainExclusion(ItsID,image);}
void SetExclusionThreshold(unsigned long threshold) {BT_SetTerrainExclusionThreshold(ItsID,threshold);}
void SetDetail(unsigned long image) {BT_SetTerrainDetail(ItsID,image);}
void SetDetailBlendMode(unsigned char mode) {BT_SetTerrainDetailBlendMode(ItsID,mode);}
void SetEnvironment(unsigned long image) {BT_SetTerrainEnvironment(ItsID,image);}
unsigned long AddEnvironment(unsigned long Colour) {return BT_AddTerrainEnvironment(ItsID,Colour);}
void SetLOD(char LODLevels) {BT_SetTerrainLOD(ItsID,LODLevels);}
void SetSplit(unsigned long Split) {BT_SetTerrainSplit(ItsID,Split);}
void SetDetailTile(float Tile) {BT_SetTerrainDetailTile(ItsID,Tile);}
void SetQuadReduction(float Amount) {BT_SetTerrainQuadReduction(ItsID,Amount);}
void SetQuadRotation(bool Enabled) {BT_SetTerrainQuadRotation(ItsID,Enabled);}
void SetSmoothing(unsigned long Amount) {BT_SetTerrainSmoothing(ItsID,Amount);}
void SetScale(float Scale) {BT_SetTerrainScale(ItsID,Scale);}
void SetYScale(float YScale) {BT_SetTerrainYScale(ItsID,YScale);}
void SetLODDistance(unsigned char LODLevel,float value) {BT_SetTerrainLODDistance(ItsID,LODLevel,value);}
void Build(unsigned long ObjectID) {BT_BuildTerrain(ItsID,ObjectID);}
void Build(unsigned long ObjectID,bool BuildFully) {BT_BuildTerrain(ItsID,ObjectID,BuildFully);}
unsigned long Exists() {return BT_TerrainExist(ItsID);}
float GetGroundHeight(float x,float z) {return BT_GetGroundHeight(ItsID,x,z);}
float GetTerrainSize() {return BT_GetTerrainSize(ItsID);}
unsigned long GetPointExcluded(float x,float z) {return BT_GetPointExcluded(ItsID,x,z);}
unsigned long GetPointEnvironment(float x,float z) {return BT_GetPointEnvironment(ItsID,x,z);}
unsigned long GetObjectID() {return BT_GetTerrainObjectID(ItsID);}
void MakeSectorObject(unsigned long LODLevel,unsigned long SectorID,unsigned long ObjectID) {BT_MakeSectorObject(ItsID,LODLevel,SectorID,ObjectID);}
void MakeObject(unsigned long LODLevel,unsigned long ObjectID) {BT_MakeTerrainObject(ItsID,LODLevel,ObjectID);}
float GetSectorPositionX(unsigned long LODLevel,unsigned long SectorID) {return BT_GetSectorPositionX(ItsID,LODLevel,SectorID);}
float GetSectorPositionY(unsigned long LODLevel,unsigned long SectorID) {return BT_GetSectorPositionY(ItsID,LODLevel,SectorID);}
float GetSectorPositionZ(unsigned long LODLevel,unsigned long SectorID) {return BT_GetSectorPositionZ(ItsID,LODLevel,SectorID);}
unsigned long GetSectorCount(unsigned long LODLevel) {return BT_GetSectorCount(ItsID,LODLevel);}
float GetSectorSize(unsigned long LODLevel) {return BT_GetSectorSize(ItsID,LODLevel);}
unsigned long GetSectorExcluded(unsigned long LODLevel,unsigned long SectorID) {return BT_GetSectorExcluded(ItsID,LODLevel,SectorID);}
unsigned long GetSectorRow(unsigned long LODLevel,unsigned long SectorID) {return BT_GetSectorRow(ItsID,LODLevel,SectorID);}
unsigned long GetSectorCollumn(unsigned long LODLevel,unsigned long SectorID) {return BT_GetSectorCollumn(ItsID,LODLevel,SectorID);}
void UpdateLOD() {BT_UpdateTerrainLOD(ItsID);}
void UpdateCull() {BT_UpdateTerrainCull(ItsID);}
void UpdateAll() {BT_UpdateTerrain(ItsID);}
void Render() {BT_RenderTerrain(ItsID);}
//RTTMS functions
#ifdef BT_USINGRTTMS
void LockVertexdataForSector(unsigned long LODLevelID,unsigned long SectorID) {BT_LockVertexdataForSector(ItsID,LODLevelID,SectorID);}
void SetPointHeight(unsigned long TVrow,unsigned long TVcol,float Height) {BT_SetPointHeight(ItsID,TVrow,TVcol,Height);}
void SetGroundHeight(float X,float Z,float Height) {BT_SetGroundHeight(ItsID,X,Z,Height);}
void Raise(float X,float Z,float Radius,float Amount) {BT_RaiseTerrain(ItsID,X,Z,Radius,Amount);}
void Flatten(float X,float Z,float Radius) {BT_FlattenTerrain(ItsID,X,Z,Radius);}
void Paint(float X,float Z,float Radius,unsigned long Colour) {BT_PaintTerrain(ItsID,X,Z,Radius,Colour);}
void Paint(float X,float Z,float Radius,unsigned long MinColour,unsigned long MaxColour) {BT_PaintTerrain(ItsID,X,Z,Radius,MinColour,MaxColour);}
void SetPointColour(float X,float Z,unsigned long Colour) {BT_SetPointColour(ItsID,X,Z,Colour);}
void UpdateTexture() {BT_UpdateTerrainTexture(ItsID);}
#endif
private:
unsigned long ItsID;
};
public class BT_Main
{
public:
BT_Main() {BT_Init();}
BT_Terrain* MakeTerrain() {return new BT_Terrain;}
BT_Terrain* LoadTerrain(char* FileName,unsigned long ObjectID) {return new BT_Terrain(FileName,ObjectID);}
BT_Terrain* LoadTerrain(char* FileName,unsigned long ObjectID,bool BuildFully) {return new BT_Terrain(FileName,ObjectID,BuildFully);}
int ContinueBuild() {return BT_ContinueBuild();}
char* GetVersion() {return BT_GetVersion();}
void SetBuildStep(unsigned long step) {BT_SetBuildStep(step);}
void SetATMode(bool ATMode) {BT_SetATMode(ATMode);}
unsigned long GetStatistic(unsigned long code) {return BT_GetStatistic(code);}
void EnableAutoRender(bool Enabled) {BT_EnableAutoRender(Enabled);}
void SetCurrentCamera(unsigned long CameraID) {BT_SetCurrentCamera(CameraID);}
#ifdef BT_USINGRTTMS
unsigned long LockedASector() {return BT_LockedASector();}
unsigned long GetLockedTerrain() {return BT_GetLockedTerrain();}
unsigned long GetLockedLODLevel() {return BT_GetLockedLODLevel();}
unsigned long GetLockedSector() {return BT_GetLockedSector();}
void UnlockVertexData() {BT_UnlockVertexData();}
unsigned short GetVertexCount() {return BT_GetVertexCount();}
unsigned long GetIndexCount() {return BT_GetIndexCount();}
unsigned short GetIndex(unsigned long IndexID) {return BT_GetIndex(IndexID);}
float GetVertexPositionX(unsigned short VertexID) {return BT_GetVertexPositionX(VertexID);}
float GetVertexPositionX(unsigned short Vrow,unsigned short Vcol) {return BT_GetVertexPositionX(Vrow,Vcol);}
float GetVertexPositionY(unsigned short VertexID) {return BT_GetVertexPositionY(VertexID);}
float GetVertexPositionY(unsigned short Vrow,unsigned short Vcol) {return BT_GetVertexPositionY(Vrow,Vcol);}
float GetVertexPositionZ(unsigned short VertexID) {return BT_GetVertexPositionZ(VertexID);}
float GetVertexPositionZ(unsigned short Vrow,unsigned short Vcol) {return BT_GetVertexPositionZ(Vrow,Vcol);}
void SetVertexHeight(unsigned short VertexID,float Height) {BT_SetVertexHeight(VertexID,Height);}
void SetVertexHeight(unsigned short Vrow,unsigned short Vcol,float Height) {BT_SetVertexHeight(Vrow,Vcol,Height);}
#endif
};
#endif
}
// #ifdef __cplusplus
// }
// #endif
MyDLL.cpp
// This is the main DLL file.
#include "stdafx.h"
#include "MyDll.h"
#include "BlitzTerrain.h"
Stdafx.h
// stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently,
// but are changed infrequently
#pragma once