Home > C++, ClanLib C++ Game Engine > Show window using ClanLib in C++

Show window using ClanLib in C++



#include "precomp.h"
#include "program.h"
#include <ClanLib/application.h>
#include <ClanLib/display.h>
#include <ClanLib/gl.h>


CL_ClanApplication clanapp(&Program::main);

int Program::main(const std::vector<CL_String> &args)
{
	CL_SetupCore setup_core;
	CL_SetupDisplay setup_display;
	CL_SetupGL setup_gl;
	try{
		CL_DisplayWindow window("Welcome to ClanLib GUI",640,480);
		CL_GraphicContext gc=window.get_gc();
		CL_InputDevice keyboard=window.get_ic().get_keyboard();
		CL_Font font(gc,"Tahoma",30);
		while(!keyboard.get_keycode(CL_KEY_ESCAPE)){
			gc.clear(CL_Colorf::blue);
			CL_Draw::line(gc,0,100,100,100,CL_Colorf::aliceblue);
			font.draw_text(gc,200,200,"Hello clanlib C++ GUI",CL_Colorf::green);
			// Make the stuff visible:
			window.flip();
 
			// Read messages from the windowing system message queue, if any are available:
			CL_KeepAlive::process();
 
			// Avoid using 100% CPU in the loop:
			CL_System::sleep(10);

		}

	}
	catch(CL_Exception ex){
		CL_ConsoleWindow console("Console",80,160);
		CL_Console::write("Error"+ex.get_message_and_stack_trace());
		console.display_close_message();
	}
	return 0;
}

  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: