nbsp;

EdenCGL (updated 2008-11-24)

From the readme (included inside the archive):

Readme for EdenCGL.
===================

Copyright (c) 2001-2008, Philip Lamb, phil at eden dot net dot nz.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

General
-------
This file includes a portion of my library, libeden, for setting up full screen OpenGL rendering contexts using the Mac OS X CGL API.

EdenCGL defines some fairly simple interfaces to Mac OS X's CGDirectDisplay facilities (for capturing the screen(s) and turning off the window server) and CGL OpenGL facilities for basic full screen OpenGL context management.

Building
--------
The file(s) which need to be compiled are

EdenCGL.c

and you should include these with your project. You will also need to place the header files:

Eden.h
EdenCGL.h

into a folder or directory named "Eden" and place the Eden folder on the include path for your project.

Usage:
------
Reference documentation on the API can be found in included HTML documentation in the doc/ directory of the archive.

Basically, you use these interfaces at a few different places in your software.

At the point where you'd normally create your (fullscreen) window, you instead do something like that demonstrated in the snippet below:

// BEGIN SNIPPET.
#include <Eden/EdenCGL.h>

EDEN_CGL_DISPLAY_MODE displayModes[NUMBER_OF_DISPLAYS_WANTED];
EDEN_BOOL ok;
int i;

for (i = 0; i < NUMBER_OF_DISPLAYS_WANTED; i++) {
displayModes[i].width = 640;
displayModes[i].width = 480;
displayModes[i].depth = 32;
displayModes[i].refresh = (CGRefreshRate)60.0;
displayModes[i].display = i;
displayModes[i].syncToVBL = TRUE;
}
ok = EdenCGLSetup(NUMBER_OF_DISPLAYS_WANTED, displayModes, TRUE);
if (!ok) exit(-1);
// END SNIPPET.

Then, where you'd normally do your OpenGL drawing, you'd do something like this:

// BEGIN SNIPPET.
#include <Eden/EdenCGL.h>

EDEN_BOOL ok;
int i;

for (i = 0; i < NUMBER_OF_DISPLAYS_WANTED; i++) {
ok = EdenCGLContextSelect(i);
if (!ok) exit(-1);

glDrawBuffer(GL_BACK);
// Here do normal OpenGL drawing.

// etc.

ok = EdenCGLContextFlush(i);
if (!ok) exit(-1);
}
// END SNIPPET.

Finally, when you're done with your fullscreen(s), cleanup is done thus:

// BEGIN SNIPPET.
#include <Eden/EdenCGL.h>

EDEN_BOOL ok;

ok = EdenCGLCleanup();
if (!ok) exit(-1);
// END SNIPPET.

Bear in mind that if you're currently using some other system for your OpenGL context management, such as GLUT, AGL, or GLX, you may still use parts of that system, to handle e.g. keyboard and mouse events.

Click here to download EdenCGL v1.2 (in .zip format) .

Click here to download EdenCGL v1.1 (in .sit format) .