Horde3D

Next-Generation Graphics Engine
It is currently 20.05.2022, 14:52

All times are UTC + 1 hour




Post new topic Reply to topic  [ 7 posts ] 
Author Message
PostPosted: 23.10.2012, 22:06 
Offline

Joined: 23.10.2012, 21:53
Posts: 1
Hello h3d forums,

I've recently taken the plunge and started working with 3D graphics programming and have decided to try my hand at horde3d rather than working with raw OpenGL API calls and I am having an issue with the tutorial in (http://www.horde3d.org/docs/manual.html). This tutorial references resources that don't exist and aren't really mentioned in the tutorial how to create, so I copied the civilian1.material.xml, man.anim, man.geo, man.scene.xml, and forward.pipeline.xml and used those.

However, while the code compiles and runs, I just see a blank screen. Doing some troubleshooting, I added in a few h3dIsRedLoaded(res) lines; I have the resource files in the same dir as the executable, but when running with those resloaded lines, the resource loading failed. I then plugged in the absolute path to the executable. After I did that, h3dIsResLoaded no longer produced errors... but I continue to get nothing more than a black screen on execution.

What am I doing wrong and is there a step by step tutorial for creating basic resources, loading them into h3d, and displaying them? Code I am using included below.

Code:
#include <iostream>
#include <cstdlib>

#include "glfw.h"
#include "Horde3D.h"
#include "Horde3DUtils.h"

using namespace std;

H3DNode model = 0, cam = 0;

bool initWindow();
void initGame(int winHeight, int winWidth);
void gameLoop(float fps);
void releaseGame();

int main(int argc, char* argv[]){
    cout << "Hello world!\n";


    if(!initWindow()){return 666;}
    initGame(800,600);

    for(int x=0;x<=2000;x++){
        gameLoop(20);
    }
    releaseGame();
    glfwCloseWindow();
    glfwTerminate();
    return 0;
}

bool initWindow(){
    glfwInit();
    if(!glfwOpenWindow(800,600,8,8,8,8,24,8,GLFW_WINDOW)){
        glfwTerminate();
        return false;
    }
    return true;
}

void initGame(int winHeight, int winWidth){
    h3dInit();

    //Add pipeline
    H3DRes pipeRes = h3dAddResource(H3DResTypes::Pipeline, "forward.pipeline.xml",0);
    //Add a model resource
    H3DRes modelRes = h3dAddResource(H3DResTypes::SceneGraph, "man.scene.xml",0);
    //Add an animation resource
    H3DRes animRes = h3dAddResource(H3DResTypes::Animation, "man.anim",0);
    //Now load added resources
    if(!h3dutLoadResourcesFromDisk("")){cout << "Failed to load a resource!\n";}

    if(!h3dIsResLoaded(pipeRes)){cout << "Failed to load pipeline!\n";}
    if(!h3dIsResLoaded(modelRes)){cout << "Failed to load model!\n";}
    if(!h3dIsResLoaded(animRes)){cout << "Failed to load animation!\n";}

    //Add the model to the scene
    model = h3dAddNodes(H3DRootNode, modelRes);
    //Apply the animation to the model
    h3dSetupModelAnimStage(model,0,animRes,0,"",false);

    //Add a light source
    H3DNode light = h3dAddLightNode(H3DRootNode,"Light1",0,"LIGHTING","SHADOWMAP");
    //Set the light position and radius
    h3dSetNodeTransform(light,0,20,0,0,0,0,1,1,1);
    h3dSetNodeParamF(light,H3DLight::RadiusF,0,50.0f);

    //Add in the camera
    H3DNode cam = h3dAddCameraNode(H3DRootNode,"Camera",pipeRes);

    //Setup tviewport and render target sizes
    h3dSetNodeParamI(cam,H3DCamera::ViewportXI,0);
    h3dSetNodeParamI(cam,H3DCamera::ViewportYI,0);
    h3dSetNodeParamI(cam,H3DCamera::ViewportWidthI, winWidth);
    h3dSetNodeParamI(cam,H3DCamera::ViewportHeightI, winHeight);
    h3dSetupCameraView(cam,45.0f,(float)winWidth/winHeight,0.5f,2048.0f);
    h3dResizePipelineBuffers(pipeRes,winWidth,winHeight);

}

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,0,0,0,1,1,1);

    //Render the scene
    h3dRender(cam);

    //Finish rendering
    h3dFinalizeFrame();

    glfwSwapBuffers();

}

void releaseGame(){
    h3dRelease();
}


Top
 Profile  
Reply with quote  
PostPosted: 24.10.2012, 06:59 
Offline
Tool Developer

Joined: 13.11.2007, 11:07
Posts: 1149
Location: Germany
I guess the samples shipped with the SDK are working, aren't they? So maybe you have better luck, when you try to adjust them step by step to your needs, so you can better follow what happens when calling all the h3d specific functions.

Regarding creation of Resources. Shaders have to be written by yourself, if those that were shipped with the SDK don't fit your needs. The geometry resources have to be created by some 3D tools, like Blender, 3Ds Max, Maya, etc. and then they have to be exported to Collada and converted using Horde3D's collada converter. The conversion process can be done by command line or using the editor.

Assembling the scene can be done manually by creating an XML file with the object's transformations manually or by using the editor.


Top
 Profile  
Reply with quote  
PostPosted: 29.03.2022, 12:40 
Offline

Joined: 02.01.2017, 02:59
Posts: 11
There's a bug in the tutorial:

//Add in the camera
H3DNode cam = h3dAddCameraNode(H3DRootNode,"Camera",pipeRes);


it should just be :
cam = h3dAddCameraNode(H3DRootNode,"Camera",pipeRes);

to use the global cam.


However I'm still getting a black screen, I've tried moving the camera and the model, still black :/
I was hoping the tutorial would just work :/
I noticed the camera and the model aren't being initialized, I assume the models are set to 0,0,0 by default, but it's unclear where the camera is face...

Can the full tutorial source code be put somewhere?


If anyone is curious here's my hacked up SDL2 code.

Code:

#include <stdio.h>
#include <SDL2/SDL.h>
#include <SDL2/SDL_image.h>
#include <SDL2/SDL_timer.h>

#include "Horde3D.h"
#include "Horde3DUtils.h"


H3DNode model = 0, cam = 0;

void initGame( int winWidth, int winHeight )
{
    // Initialize engine
    h3dInit( H3DRenderDevice::OpenGL4 );
   
    // Add pipeline resource
    H3DRes pipeRes = h3dAddResource( H3DResTypes::Pipeline, "pipelines/forward.pipeline.xml", 0 );
    // Add model resource
    H3DRes modelRes = h3dAddResource( H3DResTypes::SceneGraph, "models/man/man.scene.xml", 0 );
    // Add animation resource
    H3DRes animRes = h3dAddResource( H3DResTypes::Animation, "animations/man.anim", 0 );
    // Load added resources
    h3dutLoadResourcesFromDisk( "../Horde3D/Binaries/Content" );
   
    // 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
    cam = h3dAddCameraNode( H3DRootNode, "Camera", pipeRes );

    // Setup viewport and render target sizes
    h3dSetNodeParamI( cam, H3DCamera::ViewportXI, 0 );
    h3dSetNodeParamI( cam, H3DCamera::ViewportYI, 0 );
    h3dSetNodeParamI( cam, H3DCamera::ViewportWidthI, winWidth );
    h3dSetNodeParamI( cam, H3DCamera::ViewportHeightI, winHeight );
    h3dSetupCameraView( cam, 45.0f, (float)winWidth / winHeight, 0.05f, 2048.0f );
    h3dResizePipelineBuffers( pipeRes, winWidth, winHeight );

   h3dutDumpMessages();


    if ( !cam || !model)
        return;

   printf("initGame good\n");
}


void gameLoop( float fps )
{
    static float t = 0;
   
   

    // Increase animation time
    t = t + 10.0f * (1 / fps);
   
   printf("%f\n", t);

    // Play animation
    h3dSetModelAnimParams( model, 0, t * 0.10, 1.0f );
    h3dUpdateModel( model, H3DModelUpdateFlags::Animation | H3DModelUpdateFlags::Geometry );
   
    // Set new model position
    h3dSetNodeTransform( model, t * 0.10, 0, 0,  // Translation
                         0, 0, 0,              // Rotation
                         2, 2, 2 );            // Scale
            

// Set camera parameters
   h3dSetNodeTransform(cam, 0, 0, t * 0.10, 0 ,0, 0, 1, 1, 1 );

                     
    // Render scene
    h3dRender( cam );
   
    // Finish rendering of frame
    h3dFinalizeFrame();
}


void releaseGame()
{
    // Release engine
    h3dRelease();
}



 

int main(int argv, char** args)
{
 
   int w= 640, h=480;


    // returns zero on success else non-zero
    if (SDL_Init(SDL_INIT_EVERYTHING) != 0) {
        printf("error initializing SDL: %s\n", SDL_GetError());
    }



SDL_GL_LoadLibrary(NULL); // Default OpenGL is fine.


#if 1

// Request an OpenGL 4.5 context (should be core)
SDL_GL_SetAttribute(SDL_GL_ACCELERATED_VISUAL, 1);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 4);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 0);
// Also request a depth buffer
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
//SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24);

#endif


    SDL_Window* win = SDL_CreateWindow("GAME",
                                       SDL_WINDOWPOS_CENTERED,
                                       SDL_WINDOWPOS_CENTERED,
                                       w, h, SDL_WINDOW_OPENGL );

// Check that the window was successfully created
    if (win == NULL) {
        // In the case that the window could not be made...
        printf("Could not create window: %s\n", SDL_GetError());
        return 1;
    }


SDL_GLContext maincontext = SDL_GL_CreateContext(win);
if (maincontext == NULL)
  {
 printf("Could not create maincontext: %s\n", SDL_GetError());
        return 1;
}


  // The window is open: could enter program loop here (see SDL_PollEvent())

   


   initGame( w, h );


    SDL_Event event;
  bool quit = false;
  while (!quit) {

    gameLoop(20);
SDL_Delay(300);  // Pause execution for 3000 milliseconds, for example


    SDL_GL_SwapWindow(win);
    while (SDL_PollEvent(&event)) {
      if (event.type == SDL_QUIT) {
        quit = true;
      }
    }
  }
       


   releaseGame();



    // Close and destroy the window
    SDL_DestroyWindow(win);

    // Clean up
    SDL_Quit();
 
    return 0;
}


my build
cmake -DHORDE3D_FORCE_DOWNLOAD_SDL=OFF -DHORDE3D_USE_SDL=TRUE -DSDL2_LIBRARY=/usr/local/lib/ ..

LD_LIBRARY_PATH=$LD_LIBRARY_PATH:
export LD_LIBRARY_PATH

g++ -c -o test.o test.cpp
g++ -o test.run test.o `sdl2-config --libs --cflags` -ggdb3 -O0 -Wall -lSDL2_image -lm -L. libHorde3D.so libHorde3DUtils.so


Last edited by gwald on 18.04.2022, 10:55, edited 1 time in total.

Top
 Profile  
Reply with quote  
PostPosted: 01.04.2022, 10:49 
Offline

Joined: 17.11.2009, 17:00
Posts: 202
Location: Russia, Moscow
Hello.
I'll look into the issue with tutorial, but you should probably try samples that are shipped with the engine, they should have no issues.
Also, mind that tutorial was written for horde3d version 1, and was not updated for version 2 of the engine, so it may have some problems.

Please check the generated log, were resources loaded correctly?
Also take a look at your gameloop function, you are constantly transforming the model in the x axis, so it is constantly moving somewhere.


Top
 Profile  
Reply with quote  
PostPosted: 02.04.2022, 02:21 
Offline

Joined: 02.01.2017, 02:59
Posts: 11
Thanks for the reply :)
> you should probably try samples that are shipped with the engine, they should have no issues.
Yes the samples demos compile fine.

> Also, mind that tutorial was written for horde3d version 1, and was not updated for version 2 of the engine, so it may have some problems.
The tutorial is linked from the main site: http://horde3d.org/docs/html/_tutorial.html and wiki: http://horde3d.org/wiki/index.php?title ... ello_World

The tutorial is great! it's simple and understandable without going through the OOP samples, which is great to develop and show off, not so great for learning IMO.


> Please check the generated log, were resources loaded correctly?

Logs look fine, the resources load fine also :)

> Also take a look at your gameloop function, you are constantly transforming the model in the x axis, so it is constantly moving somewhere.

That's the intended out come I was expecting, something moving past the camera, as per the tutorial.

It's probably a SDL2 issue or I'm not understanding the defaults of the camera (pos/direction, or setup).
I will try again and post it work or not working with more details :D

Thanks again for your reply :)


Top
 Profile  
Reply with quote  
PostPosted: 03.04.2022, 09:43 
Offline

Joined: 02.01.2017, 02:59
Posts: 11
I got it working, with a lot of trial and error.
My main issue was picking the Chicago man, it's a very small coordinate system... I guess it makes sense the man modeled to a human size lol.
I hope it helps others looking at horde3d for the first time, it's a great little rendering framework!



Code:
#include <stdio.h>
#include <SDL2/SDL.h>
#include <SDL2/SDL_image.h>
#include <SDL2/SDL_timer.h>

#include "Horde3D.h"
#include "Horde3DUtils.h"


H3DNode model = 0, cam = 0;

void initGame( int winWidth, int winHeight )
{
    // Initialize engine
    h3dInit( H3DRenderDevice::OpenGL4 );
   
    // Add pipeline resource
    H3DRes pipeRes = h3dAddResource( H3DResTypes::Pipeline, "pipelines/forward.pipeline.xml", 0 );
    // Add model resource
    H3DRes modelRes = h3dAddResource( H3DResTypes::SceneGraph, "models/man/man.scene.xml", 0 );
    // Add animation resource
    H3DRes animRes = h3dAddResource( H3DResTypes::Animation, "animations/man.anim", 0 );
    // Load added resources

   // ISSUE: assume current folder is inside the root Horde3D folder.
   // Or somewhere else, its more helpful having a folder pointing to the sample content.
   h3dutLoadResourcesFromDisk( "../Horde3D/Binaries/Content" );
   
    // 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
    //ISSUE: 20 +Y is too much for the man model!
    h3dSetNodeTransform( light, 0, 2, 0,   0, 0, 0, 1, 1, 1 );
    h3dSetNodeParamF( light, H3DLight::RadiusF, 0, 50.0f );
   
    // Add camera
    // ISSUE: no not instanciate new H3DNode cam, use the global one!
    cam = h3dAddCameraNode( H3DRootNode, "Camera", pipeRes );

    // Setup viewport and render target sizes
    h3dSetNodeParamI( cam, H3DCamera::ViewportXI, 0 );
    h3dSetNodeParamI( cam, H3DCamera::ViewportYI, 0 );
    h3dSetNodeParamI( cam, H3DCamera::ViewportWidthI, winWidth );
    h3dSetNodeParamI( cam, H3DCamera::ViewportHeightI, winHeight );
    h3dSetupCameraView( cam, 45.0f, (float)winWidth / winHeight, 0.5f, 2048.0f );
    h3dResizePipelineBuffers( pipeRes, winWidth, winHeight );

   // ISSUE: camera needs to be place correctly for the model, default is 0,0,0 looking down -Z
   h3dSetNodeTransform( cam, 0, 1.0, -0.05,   0, 0, 0, 1, 1, 1 );


   // ISSUE: check if model, light or cam failed!
    if ( !cam || !model || !light)
      printf("initGame cam or model failed!\n");

   

}
void gameLoop( float fps )
{
    static float t = 0;
   
    // Increase animation time
    t = t + 10.0f * (1 / fps);

   // ISSUE: print something useful?   
   printf("%f\n", t);

    // Play animation
    h3dSetModelAnimParams( model, 0, t, 1.0f );   
    h3dUpdateModel( model, H3DModelUpdateFlags::Animation | H3DModelUpdateFlags::Geometry );
   
    // Set new model position
    // ISSUE: move down the -Z spinning around Y makes more sense then
   h3dSetNodeTransform( model,
                   0, 0, t * -0.01,  // Translation - walk down -Z
                         0, t, 0,              // Rotation - around Y
                         1, 1, 1 );            // Scale - none
         
    // Render scene
    h3dRender( cam );
   
    // Finish rendering of frame
    h3dFinalizeFrame();
}


void releaseGame()
{
    // Release engine
    h3dRelease();
}


 

int main(int argv, char** args)
{
 
   int w= 640, h=480;


    // returns zero on success else non-zero
    if (SDL_Init(SDL_INIT_EVERYTHING) != 0) {
        printf("error initializing SDL: %s\n", SDL_GetError());
    }



SDL_GL_LoadLibrary(NULL); // Default OpenGL is fine.


#if 1

// Request an OpenGL 4.5 context (should be core)
SDL_GL_SetAttribute(SDL_GL_ACCELERATED_VISUAL, 1);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 4);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 0);
// Also request a depth buffer
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
//SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24);

#endif


    SDL_Window* win = SDL_CreateWindow("GAME",
                                       SDL_WINDOWPOS_CENTERED,
                                       SDL_WINDOWPOS_CENTERED,
                                       w, h, SDL_WINDOW_OPENGL );

// Check that the window was successfully created
    if (win == NULL) {
        // In the case that the window could not be made...
        printf("Could not create window: %s\n", SDL_GetError());
        return 1;
    }


SDL_GLContext maincontext = SDL_GL_CreateContext(win);
if (maincontext == NULL)
  {
        printf("Could not create maincontext: %s\n", SDL_GetError());
        return 1;
}


  // The window is open: could enter program loop here (see SDL_PollEvent())

   


   initGame( w, h );


    SDL_Event event;
  bool quit = false;

  while (!quit) {

    gameLoop(20);
   //SDL_Delay(30);  // Pause execution for 30 milliseconds, for example


    SDL_GL_SwapWindow(win);
    while (SDL_PollEvent(&event)) {
      if (event.type == SDL_QUIT) {
        quit = true;
      }
    }
  }
       


   releaseGame();



    // Close and destroy the window
    SDL_DestroyWindow(win);

    // Clean up
    SDL_Quit();
 
    return 0;
}




And working in +Z ;)


Code:
#include <stdio.h>
#include <SDL2/SDL.h>
#include <SDL2/SDL_image.h>
#include <SDL2/SDL_timer.h>

#include "Horde3D.h"
#include "Horde3DUtils.h"


H3DNode model = 0, cam = 0;

void initGame( int winWidth, int winHeight )
{
    // Initialize engine
    h3dInit( H3DRenderDevice::OpenGL4 );
   
    // Add pipeline resource
    H3DRes pipeRes = h3dAddResource( H3DResTypes::Pipeline, "pipelines/forward.pipeline.xml", 0 );
    // Add model resource
    H3DRes modelRes = h3dAddResource( H3DResTypes::SceneGraph, "models/man/man.scene.xml", 0 );
    // Add animation resource
    H3DRes animRes = h3dAddResource( H3DResTypes::Animation, "animations/man.anim", 0 );
    // Load added resources

   // ISSUE: assume current folder is inside the Samples folder.
   // Or somewhere else, it more helpful having a folder pointing to the sample content.
   h3dutLoadResourcesFromDisk( "../Horde3D/Binaries/Content" );
   
    // 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
    //ISSUE: 20 +Y is too much for the man model!
    h3dSetNodeTransform( light, 0, 2, 0,   0, 180, 0, 1, 1, 1 );
    h3dSetNodeParamF( light, H3DLight::RadiusF, 0, 50.0f );
   
    // Add camera
    // ISSUE: no not instanciate new H3DNode cam, use the global one!
    cam = h3dAddCameraNode( H3DRootNode, "Camera", pipeRes );

    // Setup viewport and render target sizes
    h3dSetNodeParamI( cam, H3DCamera::ViewportXI, 0 );
    h3dSetNodeParamI( cam, H3DCamera::ViewportYI, 0 );
    h3dSetNodeParamI( cam, H3DCamera::ViewportWidthI, winWidth );
    h3dSetNodeParamI( cam, H3DCamera::ViewportHeightI, winHeight );
    h3dSetupCameraView( cam, 45.0f, (float)winWidth / winHeight, 0.5f, 2048.0f );
    h3dResizePipelineBuffers( pipeRes, winWidth, winHeight );

   // ISSUE: camera needs to be place correctly for the model, default is 0,0,0 looking down -Z
   h3dSetNodeTransform( cam, 0, 1.0, 0.05,   0, 180, 0, 1, 1, 1 );


   // ISSUE: check if model, light or cam failed!
    if ( !cam || !model || !light)
      printf("initGame cam or model failed!\n");

   

}
void gameLoop( float fps )
{
    static float t = 0;
   
    // Increase animation time
    t = t + 10.0f * (1 / fps);

   // ISSUE: print something useful?   
   printf("%f\n", t);

    // Play animation
    h3dSetModelAnimParams( model, 0, t, 1.0f );   
    h3dUpdateModel( model, H3DModelUpdateFlags::Animation | H3DModelUpdateFlags::Geometry );
   
    // Set new model position
    // ISSUE: move down the -Z spinning around Y makes more sense then
   h3dSetNodeTransform( model,
                   0, 0, t * 0.01,  // Translation - walk down -Z
                         0, t, 0,              // Rotation - around Y
                         1, 1, 1 );            // Scale - none
         
    // Render scene
    h3dRender( cam );
   
    // Finish rendering of frame
    h3dFinalizeFrame();
}


void releaseGame()
{
    // Release engine
    h3dRelease();
}


 

int main(int argv, char** args)
{
 
   int w= 640, h=480;


    // returns zero on success else non-zero
    if (SDL_Init(SDL_INIT_EVERYTHING) != 0) {
        printf("error initializing SDL: %s\n", SDL_GetError());
    }



SDL_GL_LoadLibrary(NULL); // Default OpenGL is fine.


#if 1

// Request an OpenGL 4.5 context (should be core)
SDL_GL_SetAttribute(SDL_GL_ACCELERATED_VISUAL, 1);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 4);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 0);
// Also request a depth buffer
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
//SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24);

#endif


    SDL_Window* win = SDL_CreateWindow("GAME",
                                       SDL_WINDOWPOS_CENTERED,
                                       SDL_WINDOWPOS_CENTERED,
                                       w, h, SDL_WINDOW_OPENGL );

// Check that the window was successfully created
    if (win == NULL) {
        // In the case that the window could not be made...
        printf("Could not create window: %s\n", SDL_GetError());
        return 1;
    }


SDL_GLContext maincontext = SDL_GL_CreateContext(win);
if (maincontext == NULL)
  {
        printf("Could not create maincontext: %s\n", SDL_GetError());
        return 1;
}


  // The window is open: could enter program loop here (see SDL_PollEvent())

   


   initGame( w, h );


    SDL_Event event;
  bool quit = false;

  while (!quit) {

    gameLoop(20);
   //SDL_Delay(30);  // Pause execution for 30 milliseconds, for example


    SDL_GL_SwapWindow(win);
    while (SDL_PollEvent(&event)) {
      if (event.type == SDL_QUIT) {
        quit = true;
      }
    }
  }
       


   releaseGame();



    // Close and destroy the window
    SDL_DestroyWindow(win);

    // Clean up
    SDL_Quit();
 
    return 0;
}



Top
 Profile  
Reply with quote  
PostPosted: 06.04.2022, 09:42 
Offline

Joined: 17.11.2009, 17:00
Posts: 202
Location: Russia, Moscow
Hello. Glad that it worked out for you. I'll post your fixes in the engine documentation on github. Unfortunately, website will remain with old tutorial as I cannot modify it...


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 3 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:  
cron
Powered by phpBB® Forum Software © phpBB Group