Normally, what you will do is open a Console in the normal PTC fashion. What's different in X11 is that the format object you pass to the constructor or the open routine doesn't really matter. X servers don't allow a change of colour depth so PTC has to use what it gets anyway. What you should do is create the format object the way you want your offscreen surface afterwards and pass it to PTC.
An exception to this would be that you want to request a native video mode and draw directly to the console instead of a surface. In that case, look at the "native" example in the example directory.
A PTC console can be open using a custom constructor or the default constructor followed by a call to Console::open. For the X11 distribution you get the following options..
This is what you will normally use. PTC will then try to open a DGA mode of width*height. If that's not possible, it will fall back to MIT-Shm or worse, XImage. You can pass PTC_X11_NODGA as a flag.
Example: Console("Hello world",320,200,Format(8));
This one is easy, if you use it, nothing much happens, the console is not opened and you will have to use an open routine. It has its uses though because some open routines don't exist as constructors as we do not want a class overloaded with constructors.
Example: Console console;
Analogous to the constructor shown above (it is actually called by that constructor).
This is for supplying PTC with your own pre created window to render into. If you use this open routine, PTC will get the window's dimensions and fill it out. I suggest you use console.width() and console.height() to create your surface for that console afterwards.
The parameters you have to pass are:
Example: console.open(disp,DefaultScreen(disp),window,Format(8));
The more sophisticated version of the previous function. This will tell PTC not to fill the whole window but rather use your values. You pass the top left corner and the width and height of the area in the window you want to use (0x0 is in the top left, like in the X standard).
Although PTC is completely portable, there are some minor changes you can request in every environment in order to make it more useable and less stringent. In the X11 port, this is handled by flags you can pass to:
This is the only flag that cannot be passed with the flags function because it has to be known immediately at startup. It is used the following way:
Console console("Console name",x,y,format,PTC_X11_NODGA);You might want to use this if you insist on a windowed mode. It is pointless to use it on an architecture that does not support DGA (don't worry, PTC just won't try to initialise it then anyway ;).
If you pass this flag, PTC will try to initialise a DGA mode even if the videomode you requested cannot be matched exactly. PTC will try and initialise the next bigger mode and then center the console in the middle of the screen. Note that this has to be passed to the open routine.
You might need this if you just use PTC as a part of your application. If you pass it, PTC will not call XCloseDisplay upon exit, which will destroy your display pointer. This flag can be passed in the flags routine, but in time :)
Example: ptc.flags(PTC_X11_LEAVE_DISPLAY);
Look at the example in the unix/ directory for this flag in action.
If you used the open routine for user supplied windows to make PTC render into your own window, then you might want to pass this to flags if you want your window to still exist when PTC exits. A word of caution: You will have to pass PTC_X11_LEAVE_DISPLAY too or PTC will delete the display pointer you also passed to that open routine.
Example: ptc.flags(PTC_X11_LEAVE_DISPLAY|PTC_X11_LEAVE_WINDOW);
Look at the example in the unix/ directory for this flag in action.