Hello all,
I'm having a problem where Horde3D causes a segfault in
Horde3D::init() in Ubuntu Jaunty. Tracing it in GDB is a bit mysterious, as GDB reports that the segfault occurs in '
Horde3DEngine/egMain.cpp:87', which is the fairly innocuous line:
Code:
if( !Modules::renderer().init() ) return false;
This segfault occurs in my code in linux, but not in the demo programs, which compile and run just fine. Also, my code is cross platform, and works perfectly fine in Windows when compiled in VS2008.
Horde3D::init() is almost the first thing called in the program, just after the code to create an OpenGL window. I played around with modifying the Horde3D code to try to get it working, and found that removing the 'virtual' keywords from the
RendererBase::init() function in '
Horde3DEngine/egRendererBase.h' fixed the original segfault, but led to another in '
Horde3DEngine/egRendererBase.cpp:72'.
With basic functions segfaulting, I'm thinking it might be a bad compiler setting or something, but I'm not using any strange settings in my compilation. Any ideas?
The relevant sections of code are below.
H3d::init() is the first thing called in the main program, right after a H3d object is created (nothing in the constructor).
Code:
void H3d::init(int w, int h)
{
_cpath = "/home/******/Desktop/k3engine/build/";
// initialize sdl
k3SDL::init();
resetVideoMode(w, h, false);
// Initialize engine
if( !Horde3D::init() ) // <--- This is exactly where it fails
{
LOG(logERROR) << "Horde3D init error";
}
...
// Other stuff, but it's already crashed by here
}
void k3SDL::init()
{
if(_initted)
return;
// SDL Initialization
int error;
error = SDL_Init(SDL_INIT_EVERYTHING);
_initted = true;
}
int H3d::resetVideoMode(int screenWidth, int screenHeight, bool fullscreen)
{
// SDL/OpenGL initialization (doublebuffered, depthbuffered, 32 bit color)
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 16);
SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8);
SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8);
SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8);
SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, 8);
SDL_Surface* drawContext;
Uint32 flags;
if(fullscreen)
flags = SDL_OPENGL | SDL_HWSURFACE | SDL_FULLSCREEN;
else
flags = SDL_OPENGL | SDL_HWSURFACE;
drawContext = SDL_SetVideoMode(screenWidth, screenHeight, 0, flags);
_screenW = screenWidth;
_screenH = screenHeight;
return 1;
}