PDA

View Full Version : cl_displaywindow refuses to display a window



dwune
10-01-2007, 02:18 PM
Hi, I read about ClanLib a while back and recently decided to try it. I love the way the API is laid out. Anyway my problem is that CL_DisplayWindow doesn't work.

this is my code:


#include <ClanLib/core.h>
#include <ClanLib/application.h>
#include <ClanLib/display.h>
#include <ClanLib/gl.h>
#include <iostream>

using namespace std;
class MyApp : public CL_ClanApplication
{
public:
virtual int main(int, char**);

} app;


int MyApp::main(int argc, char **argv)
{
CL_SetupCore sc;
CL_SetupDisplay sd;

CL_DisplayWindowDescription desc;
CL_Size sz(640,480);
desc.set_title("test");
desc.set_size(sz);

try
{
CL_DisplayWindow window(desc);
}
catch (CL_Error err)
{
cout << err.message.c_str() << endl;
}

/*while (!CL_Keyboard::get_keycode(CL_KEY_ESCAPE))
{
//CL_Display::flip();
CL_System::keep_alive(20);
}*/

return 0;
}


I can compile and link this just fine, and if I remove the CL_DisplayWindow it runs through, ofc since it doesn't do anything hehe.

I get this error though if I include displaywindow:

You need to create a display target first.

Any idea what's up here? I've checked countless examples and the display overview among others. The code checks out afaik. Oh, and I've tried using the dipslaywindow constructor as well, to no avail.

Thanks.

dwune
10-01-2007, 04:01 PM
Alright, I got an update on this problem now. I managed to solve it on my own.

Oh and before I get to the solution, I should mention that I'm doing everything on a linux computer, I reckon that could be important :)

It seems I cannot create a window without specifying the underlying renderer as either SDL or OpenGL. I assume the default is X11 or something which I apparantly couldn't do without some additional mods.

By writing CL_SetupSDL sdl; OR CL_SetupGL gl; I can get the window to show.

Maybe this'll help someone else, now I'm moving on to doing something useful with the window.