Hi,
I'm trying to make a game using Horde3D. I am trying to follow the tutorial. I am using code::blocks on windows with MinGW and I am using the prebuilt binaries. Here is the code:
Code:
#include <iostream>
#include <Horde3D.h>
#include <Horde3DUtils.h>
using namespace std;
H3DNode model = 0, cam = 0;
void initGame( int winWidth, int winHeight )
{
// Initialize engine
h3dInit();
h3dSetupViewport( 0, 0, winWidth, winHeight, true );
// Add pipeline resource
H3DRes pipeRes = h3dAddResource( H3DResTypes::Pipeline, "standard.pipeline.xml", 0 );
// Add model resource
H3DRes modelRes = h3dAddResource( H3DResTypes::SceneGraph, "character.scene.xml", 0 );
// Add animation resource
H3DRes animRes = h3dAddResource( H3DResTypes::Animation, "walk.anim.xml", 0 );
// Load added resources
h3dutLoadResourcesFromDisk( "" );
// Add model to scene
model = h3dAddNodes( H3DRootNode, modelRes );
// Apply animation
h3dSetupModelAnimStage( model, 0, animRes, 0, "", false );
// Add light source
H3DNode light = h3dAddLightNode( H3DRootNode, "Light1", 0, "LIGHTING", "SHADOWMAP" );
// Set light position and radius
h3dSetNodeTransform( light, 0, 20, 0, 0, 0, 0, 1, 1, 1 );
h3dSetNodeParamF( light, H3DLight::RadiusF, 0, 50.0f );
// Add camera
H3DNode cam = h3dAddCameraNode( H3DRootNode, "Camera", pipeRes );
}
void gameLoop( float fps )
{
static float t = 0;
// Increase animation time
t = t + 10.0f * (1 / fps);
// Play animation
h3dSetModelAnimParams( model, 0, t, 1.0f );
// Set new model position
h3dSetNodeTransform( model, t * 10, 0, 0, // Translation
0, 0, 0, // Rotation
1, 1, 1 ); // Scale
// Render scene
h3dRender( cam );
// Finish rendering of frame
h3dFinalizeFrame();
}
void releaseGame()
{
// Release engine
h3dRelease();
}
int main()
{
cout<<"Starting Felix!\n";
initGame(800,600);
gameLoop(24);
cin.get();
releaseGame();
return 0;
}
This however, build correctly but segfaults during runtime. GDB backtrace:
Code:
Program received signal SIGSEGV, Segmentation fault.
In h3dHasEmitterFinished () (D:\work\felix\Felix\bin\Debug\Horde3D.dll)
Regards,
James