Horde3D

Next-Generation Graphics Engine
It is currently 24.11.2024, 11:44

All times are UTC + 1 hour




Post new topic Reply to topic  [ 12 posts ] 
Author Message
PostPosted: 09.04.2019, 13:03 
Offline

Joined: 08.03.2018, 12:00
Posts: 23
Here's the sample program:
Code:
#include"Horde3D.h"
#include<GL/glew.h>
#include<GL/gl.h>
#include<SDL2/SDL.h>
#include"Horde3DUtils.h"

int main() {
   SDL_Window* window = SDL_CreateWindow("Window", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 640, 480, SDL_WINDOW_OPENGL);
   SDL_GLContext glctx = SDL_GL_CreateContext(window);
   
   glewExperimental = false;
   glewInit();
   
   h3dInit(H3DRenderDevice::OpenGL2);
   
   H3DRes pipeRes = h3dAddResource(H3DResTypes::Pipeline, "pipeline.xml", 0);
   h3dutLoadResourcesFromDisk("");
   
   H3DNode cam = h3dAddCameraNode(H3DRootNode, "Camera", pipeRes);

   h3dSetNodeParamI( cam, H3DCamera::ViewportXI, 0 );
   h3dSetNodeParamI( cam, H3DCamera::ViewportYI, 0 );
   h3dSetNodeParamI( cam, H3DCamera::ViewportWidthI, 640 );
   h3dSetNodeParamI( cam, H3DCamera::ViewportHeightI, 480 );
   h3dSetupCameraView( cam, 45.0f, (float)640 / 480, 0.5f, 2048.0f );
   h3dResizePipelineBuffers( pipeRes, 640, 480 );
   
   h3dRender(cam);
   h3dFinalizeFrame();
   
   SDL_GL_SwapWindow(window);
   
   SDL_Delay(1000);

   return 0;
}

The above is compiled with: "g++ h3d.cpp -lSDL2main -lSDL2 -lHorde3D -lHorde3DUtils -lGLEW -lGL"

When I mean "not rendering", I don't mean a black screen, not even that is rendered, it's a mangled version of what was behind the window before it was made. So not even the buffer is cleared.
The pipeline used is the exact same as "forward.pipeline.xml" used in the sample files.

Another strange thing is APITrace's output:
Code:
1149 glBindTexture(target = GL_TEXTURE_CUBE_MAP, texture = 0)
1150 glBindTexture(target = GL_TEXTURE_3D, texture = 0)
1151 glBindTexture(target = GL_TEXTURE_2D, texture = 0)
1152 glBindTexture(target = GL_TEXTURE_CUBE_MAP, texture = 0)
1153 glBindTexture(target = GL_TEXTURE_3D, texture = 0)
1154 glBindTexture(target = GL_TEXTURE_2D, texture = 0)
1155 glBindTexture(target = GL_TEXTURE_CUBE_MAP, texture = 0)
1156 glBindTexture(target = GL_TEXTURE_3D, texture = 0)
1157 glBindTexture(target = GL_TEXTURE_2D, texture = 0)
1158 glBindTexture(target = GL_TEXTURE_CUBE_MAP, texture = 0)
1159 glBindTexture(target = GL_TEXTURE_3D, texture = 0)
1160 glBindTexture(target = GL_TEXTURE_2D, texture = 0)
1161 glBindTexture(target = GL_TEXTURE_CUBE_MAP, texture = 0)
1162 glBindTexture(target = GL_TEXTURE_3D, texture = 0)
1163 glBindTexture(target = GL_TEXTURE_2D, texture = 0)
1164 glBindTexture(target = GL_TEXTURE_CUBE_MAP, texture = 0)
1165 glBindTexture(target = GL_TEXTURE_3D, texture = 0)
1166 glBindTexture(target = GL_TEXTURE_2D, texture = 0)
1167 glBindTexture(target = GL_TEXTURE_CUBE_MAP, texture = 0)
1168 glBindTexture(target = GL_TEXTURE_3D, texture = 0)
1169 glBindTexture(target = GL_TEXTURE_2D, texture = 0)
1170 glBindTexture(target = GL_TEXTURE_CUBE_MAP, texture = 0)
1171 glBindTexture(target = GL_TEXTURE_3D, texture = 0)
1172 glBindTexture(target = GL_TEXTURE_2D, texture = 0)
1173 glBindTexture(target = GL_TEXTURE_CUBE_MAP, texture = 0)
1174 glBindTexture(target = GL_TEXTURE_3D, texture = 0)
1175 glBindTexture(target = GL_TEXTURE_2D, texture = 0)
1176 glBindTexture(target = GL_TEXTURE_CUBE_MAP, texture = 0)
1177 glBindTexture(target = GL_TEXTURE_3D, texture = 0)
1178 glBindTexture(target = GL_TEXTURE_2D, texture = 0)
1179 glBindTexture(target = GL_TEXTURE_CUBE_MAP, texture = 0)
1180 glBindTexture(target = GL_TEXTURE_3D, texture = 0)
1181 glBindTexture(target = GL_TEXTURE_2D, texture = 0)
1182 glBindTexture(target = GL_TEXTURE_CUBE_MAP, texture = 0)
1183 glBindTexture(target = GL_TEXTURE_3D, texture = 0)
1184 glBindTexture(target = GL_TEXTURE_2D, texture = 0)
1185 glBindTexture(target = GL_TEXTURE_CUBE_MAP, texture = 0)
1186 glBindTexture(target = GL_TEXTURE_3D, texture = 0)
1187 glBindTexture(target = GL_TEXTURE_2D, texture = 0)
1188 glBindTexture(target = GL_TEXTURE_CUBE_MAP, texture = 0)
1189 glBindTexture(target = GL_TEXTURE_3D, texture = 0)
1190 glBindTexture(target = GL_TEXTURE_2D, texture = 0)
1191 glBindTexture(target = GL_TEXTURE_CUBE_MAP, texture = 0)
1192 glBindTexture(target = GL_TEXTURE_3D, texture = 0)
1193 glBindTexture(target = GL_TEXTURE_2D, texture = 0)
1194 glBindTexture(target = GL_TEXTURE_CUBE_MAP, texture = 0)
1195 glBindTexture(target = GL_TEXTURE_3D, texture = 0)
1196 glBindTexture(target = GL_TEXTURE_2D, texture = 0)
Seemingly unnecessary GL calls are being done every frame.


Top
 Profile  
Reply with quote  
PostPosted: 10.04.2019, 09:46 
Offline

Joined: 17.11.2009, 17:00
Posts: 205
Location: Russia, Moscow
Hi. It seems that you are doing glewInit that binds gl functions. Horde does it itself, so it can probably overlap. Try disabling glewInit. Also, you are not drawing in a loop, maybe everything is done too fast.
You can check my attempt to work with sdl: https://github.com/algts/Horde3D/tree/sdl
It will later be uploaded to develop branch. It already works, but cmakelists are not yet ready.


Top
 Profile  
Reply with quote  
PostPosted: 10.04.2019, 17:08 
Offline

Joined: 08.03.2018, 12:00
Posts: 23
It is just the minimum code. The actual project does draw in a loop.

Removing GLEW completely did not fix the issue, unfortunately. I don't think it's my code, since it worked before I switched from my own engine to Horde3D. Though I could've somehow built it wrongly, I doubt it though.

Here's how the (probably) minimum code looks like now:
Code:
#include"Horde3D.h"
#include<GL/gl.h>
#include<SDL2/SDL.h>
#include"Horde3DUtils.h"

int main() {
   SDL_Init(SDL_INIT_EVERYTHING);
   
   SDL_Window* window = SDL_CreateWindow("Window", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 640, 480, SDL_WINDOW_OPENGL);
   SDL_GLContext glctx = SDL_GL_CreateContext(window);
   
   h3dInit(H3DRenderDevice::OpenGL2);
   
   H3DRes pipeRes = h3dAddResource(H3DResTypes::Pipeline, "pipeline.xml", 0);
   h3dutLoadResourcesFromDisk("");
   
   H3DNode cam = h3dAddCameraNode(H3DRootNode, "Camera", pipeRes);

   h3dSetNodeParamI( cam, H3DCamera::ViewportXI, 0 );
   h3dSetNodeParamI( cam, H3DCamera::ViewportYI, 0 );
   h3dSetNodeParamI( cam, H3DCamera::ViewportWidthI, 640 );
   h3dSetNodeParamI( cam, H3DCamera::ViewportHeightI, 480 );
   h3dSetupCameraView( cam, 45.0f, (float)640 / 480, 0.5f, 2048.0f );
   h3dResizePipelineBuffers( pipeRes, 640, 480 );
   
   h3dRender(cam);
   h3dFinalizeFrame();
   
   SDL_GL_SwapWindow(window);
   
   SDL_Delay(1000);

   return 0;
}


Top
 Profile  
Reply with quote  
PostPosted: 10.04.2019, 18:11 
Offline

Joined: 17.11.2009, 17:00
Posts: 205
Location: Russia, Moscow
Please check whether horde is correctly initialized (add bool to h3dInit). Check the log - does it contain anything suspicious?
Currently the window is hidden - you can show it by adding SDL_WINDOW_OPENGL | SDL_WINDOW_SHOWN.
Surface parameters are not set in your code - maybe SDL is smart enough to setup default parameters, maybe not.

I set the following things:

// Set parameters for context and window
Code:
SDL_GL_SetAttribute( SDL_GL_RED_SIZE, params.redBits ); // 8
   SDL_GL_SetAttribute( SDL_GL_GREEN_SIZE, params.greenBits ); // 8
   SDL_GL_SetAttribute( SDL_GL_BLUE_SIZE, params.blueBits ); // 8
   SDL_GL_SetAttribute( SDL_GL_ALPHA_SIZE, params.alphaBits ); // 8
   SDL_GL_SetAttribute( SDL_GL_DEPTH_SIZE, params.depthBits ); // 24
   SDL_GL_SetAttribute( SDL_GL_MULTISAMPLESAMPLES, params.sampleCount ); // 0
   SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 );

   // Specify context parameters
   switch ( params.requestedAPI )
   {
      case RenderAPI::OpenGL2:
                SDL_GL_SetAttribute( SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_COMPATIBILITY );
                break;
   }


As for the api trace you asked - horde internally creates some default small sized textures (like 4x4) to revert to when normal textures are not available. So probably horde initializes correctly.

Also, please check the resource path. As far as I remember, h3dLoadResourceFromDisk likes absolute paths.


Top
 Profile  
Reply with quote  
PostPosted: 10.04.2019, 20:11 
Offline

Joined: 08.03.2018, 12:00
Posts: 23
SDL_WINDOW_SHOWN is a default, so it's not necessary :P.

h3dInit returns true, and the log seems fine:
Code:
[h3d] Initializing GL2 backend using OpenGL driver '3.0 Mesa 17.0.7' by 'Intel Open Source Technology Center' on 'Mesa DRI Intel(R) HD Graphics 530 (Skylake GT2) '
1
[h3d] Loading resource 'pipeline.xml'
[h3d] Loading resource 'pipelineSettings.material.xml'
[h3d] Loading resource 'ambientMap.dds'


Top
 Profile  
Reply with quote  
PostPosted: 10.04.2019, 20:54 
Offline

Joined: 17.11.2009, 17:00
Posts: 205
Location: Russia, Moscow
Maybe you've discovered a behavior that I've seen before on development boards - that horde may not correctly draw everything on the first frame, something is not yet initialized, and everything works fine only on the second frame and further. Please try to make a loop with at least two frames.
Basically, on the first frame horde always uses 320x240 framebuffer, and only on the second frame it is set to the window size.
Also, you can try to draw overlays with fps, that way you'll see if everything works or not.

Also, it seems rather odd that on intel hd 530 you get just gl 3.0. On the later mesa version you get opengl 4.5.


Top
 Profile  
Reply with quote  
PostPosted: 10.04.2019, 21:10 
Offline

Joined: 08.03.2018, 12:00
Posts: 23
Irdis wrote:
Maybe you've discovered a behavior that I've seen before on development boards - that horde may not correctly draw everything on the first frame, something is not yet initialized, and everything works fine only on the second frame and further. Please try to make a loop with at least two frames.
Basically, on the first frame horde always uses 320x240 framebuffer, and only on the second frame it is set to the window size.
Also, you can try to draw overlays with fps, that way you'll see if everything works or not.

Also, it seems rather odd that on intel hd 530 you get just gl 3.0. On the later mesa version you get opengl 4.5.


Me having GL3 is probably because I have Ubuntu 16.04, although I'm not sure on that.

The real project does draw on a loop, and it has the same problem. Here's a picture of what it looks like:
Image


Top
 Profile  
Reply with quote  
PostPosted: 11.04.2019, 07:17 
Offline

Joined: 17.11.2009, 17:00
Posts: 205
Location: Russia, Moscow
Can you try your project or horde's samples on other machine? Do Horde's samples (that use glfw) work on your machine?
It is just a guess, but try handling a resize event that SDL generates and resize the window a bit - does it change anything?
Currently I don't understand what could be the cause of this behavior. I also develop Horde with Intel HD 530 and it works fine (but I work on Windows).


Top
 Profile  
Reply with quote  
PostPosted: 12.04.2019, 12:32 
Offline

Joined: 08.03.2018, 12:00
Posts: 23
Irdis wrote:
Can you try your project or horde's samples on other machine? Do Horde's samples (that use glfw) work on your machine?
It is just a guess, but try handling a resize event that SDL generates and resize the window a bit - does it change anything?
Currently I don't understand what could be the cause of this behavior. I also develop Horde with Intel HD 530 and it works fine (but I work on Windows).


Here's a new development: The samples work. I even ported the sampleapp class to use SDL2 (your repo kept giving me errors, sorry :P), and it still kept on working. So it's apparently my code, somehow.


Top
 Profile  
Reply with quote  
PostPosted: 12.04.2019, 12:39 
Offline

Joined: 08.03.2018, 12:00
Posts: 23
I tried handling resize events. When it resizes, it becomes a black screen (like expected according to the pipeline). But, I'm still not sure if the issue's fixed, because if I resize it just right, similar artifacts just pop up.
Image


Top
 Profile  
Reply with quote  
PostPosted: 12.04.2019, 12:42 
Offline

Joined: 08.03.2018, 12:00
Posts: 23
I'm very sorry for any time I wasted, because as always.. it's the stupidest bugs that end up consuming most of the time.
Apparently, it was the pipeline that was bad.
The "ClearTarget" tag had a "colorBuf" attribute, I just had to switch it to a "colBuf0" attribute.

It works now. Thank you for sticking with me in my stupidest moments and being active on this forum!


Top
 Profile  
Reply with quote  
PostPosted: 12.04.2019, 13:03 
Offline

Joined: 17.11.2009, 17:00
Posts: 205
Location: Russia, Moscow
I'm glad that it works.
As for my sdl branch, it won't yet build as I had not enough time yet to make cmakelists.txt files. It was also only tested on Windows currently.


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

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 12 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