Horde3D

Next-Generation Graphics Engine
It is currently 14.05.2024, 04:12

All times are UTC + 1 hour




Post new topic Reply to topic  [ 20 posts ]  Go to page 1, 2  Next
Author Message
PostPosted: 11.01.2011, 18:46 
Offline

Joined: 11.01.2011, 18:36
Posts: 13
Location: England
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

_________________
\James


Top
 Profile  
Reply with quote  
PostPosted: 11.01.2011, 21:41 
Offline

Joined: 15.06.2008, 11:21
Posts: 166
Location: Germany
I think the first thing you should do would be to compile with debug infos and post a full stack trace with line numbers.

This time the solution is simple though: You are not initializing any OpenGL context/render window before using horde3d. Horde3D does not create its own window!


Top
 Profile  
Reply with quote  
PostPosted: 11.01.2011, 22:44 
Offline

Joined: 11.01.2011, 18:36
Posts: 13
Location: England
Can you give an example of how to do that?

Thanks,

James

_________________
\James


Top
 Profile  
Reply with quote  
PostPosted: 11.01.2011, 23:08 
Offline

Joined: 15.06.2008, 11:21
Posts: 166
Location: Germany
The tutorials all do that, look at their glfw* function calls.

You can use any other OpenGL window toolkit though - glfw, sdl, sfml, Qt, gtk+, whatever you want.


Top
 Profile  
Reply with quote  
PostPosted: 13.01.2011, 22:33 
Offline

Joined: 11.01.2011, 18:36
Posts: 13
Location: England
Ok,

Where does Horde3D search for the resources? I have them currently in the same directory as the executable file but it complains in the log file that it cannot find them.

Thanks,
James

_________________
\James


Top
 Profile  
Reply with quote  
PostPosted: 14.01.2011, 15:14 
Offline
Tool Developer

Joined: 13.11.2007, 11:07
Posts: 1150
Location: Germany
Do you load them with h3dutLoadResourcesFromDisk? If yes, you can specify the content directory there.


Top
 Profile  
Reply with quote  
PostPosted: 14.01.2011, 18:26 
Offline

Joined: 11.01.2011, 18:36
Posts: 13
Location: England
How can this be formed? Is it like "./"?

_________________
\James


Top
 Profile  
Reply with quote  
PostPosted: 18.01.2011, 05:08 
Offline

Joined: 08.11.2006, 03:10
Posts: 384
Location: Australia
jamesl22 wrote:
Where does Horde3D search for the resources? I have them currently in the same directory as the executable file but it complains in the log file that it cannot find them.
What is the working directory when you run your executable?


Top
 Profile  
Reply with quote  
PostPosted: 22.01.2011, 17:49 
Offline

Joined: 22.06.2010, 19:21
Posts: 26
DarkAngel wrote:
jamesl22 wrote:
Where does Horde3D search for the resources? I have them currently in the same directory as the executable file but it complains in the log file that it cannot find them.
What is the working directory when you run your executable?


Sadly that depends on your OS and compiler. In case of Visual Studio on Windows, if you start your project with the debugger, the working directory is "YourProjectDirectory\Debug\Bin" and you have to place your files there or alter some variable in the compilation options.

The proper cross-platform way to handle this would be to check argv[0] in your main() when starting your project. But then again what you get from that variable is not standardized in any way and depends on the OS. Check the procedures that parse argv[0] in the Horde3D examples, they seem to work pretty well for me.


Top
 Profile  
Reply with quote  
PostPosted: 23.01.2011, 13:16 
Offline

Joined: 11.01.2011, 18:36
Posts: 13
Location: England
Ok, I've gotten the program to find the resources but I cant seem to get it to render anything. I just get a black window. I have posted the source code.

\James


Attachments:
Felix.zip [4.09 KiB]
Downloaded 725 times

_________________
\James
Top
 Profile  
Reply with quote  
PostPosted: 27.01.2011, 20:29 
Offline

Joined: 11.01.2011, 18:36
Posts: 13
Location: England
Anyone?

_________________
\James


Top
 Profile  
Reply with quote  
PostPosted: 28.01.2011, 00:22 
Offline
Tool Developer

Joined: 13.11.2007, 11:07
Posts: 1150
Location: Germany
I would suggest to start with the samples. If they are working you can adjust them step by step to get your things running. Another thing that would often help if you have problems with rendering anything, is to have a look at the log output. Check the samples to find out how you can output the log into a HTML file.


Top
 Profile  
Reply with quote  
PostPosted: 28.01.2011, 17:58 
Offline

Joined: 11.01.2011, 18:36
Posts: 13
Location: England
The samples don't work for me as I can't find the resources mentioned it them.

_________________
\James


Top
 Profile  
Reply with quote  
PostPosted: 28.01.2011, 21:14 
Offline
Tool Developer

Joined: 13.11.2007, 11:07
Posts: 1150
Location: Germany
Are you able to use a debugger, to check what's the path that is used when loading the resources, and then compare it to the working directory you are using? Maybe we're then able to fix the problem.


Top
 Profile  
Reply with quote  
PostPosted: 28.01.2011, 22:29 
Offline

Joined: 11.01.2011, 18:36
Posts: 13
Location: England
The program finds the resources folder but the resources metioned in the tutorial are not present in the Horde3D SDK download.

_________________
\James


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 20 posts ]  Go to page 1, 2  Next

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 10 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group