RenderingContext - OpenGL context

This commit is contained in:
Gregory Pierce 2002-09-08 06:20:19 +00:00
parent ef84e6de85
commit a27f7dc6d0
2 changed files with 112 additions and 0 deletions

View File

@ -0,0 +1,83 @@
/*
* RenderingContext.cpp
* lwjgl
*
* Created by Gregory Pierce on Wed Sep 04 2002.
* Copyright (c) 2002 __MyCompanyName__. All rights reserved.
*
*/
#include "RenderingContext.h"
RenderingContext::RenderingContext()
{
}
RenderingContext::~RenderingContext()
{
}
/*
** OpenGL Setup
*/
//GetWindowPort(win)
bool RenderingContext::setupAGL( AGLDrawable pAGLDrawable )
{
AGLPixelFormat fmt;
GLboolean ok;
GLint attrib[] = { AGL_RGBA, AGL_NONE };
/* Choose an rgb pixel format */
fmt = aglChoosePixelFormat(NULL, 0, attrib);
if(fmt == NULL)
{
return false;
}
/* Create an AGL context */
aglContext = aglCreateContext(fmt, NULL);
if(aglContext == NULL)
{
return false;
}
/* Attach the window to the context */
ok = aglSetDrawable(aglContext, pAGLDrawable );
if(!ok)
{
return false;
}
/* Make the context the current context */
ok = aglSetCurrentContext(aglContext);
if(!ok)
{
return false;
}
/* Pixel format is no longer needed */
aglDestroyPixelFormat(fmt);
return true;
}
void RenderingContext::destroy(void)
{
cleanupAGL();
// cleanup the window
//
DisposeWindow( windowPtr );
}
/*
** OpenGL Cleanup
*/
void RenderingContext::cleanupAGL()
{
aglSetCurrentContext(NULL);
aglSetDrawable(aglContext, NULL);
aglDestroyContext(aglContext);
}

View File

@ -0,0 +1,29 @@
/*
* RenderingContext.h
* lwjgl
*
* Created by Gregory Pierce on Wed Sep 04 2002.
* Copyright (c) 2002 __MyCompanyName__. All rights reserved.
*
*/
#pragma once
#include <Carbon/Carbon.h>
#include <AGL/agl.h>
#include <DrawSprocket/DrawSprocket.h>
class RenderingContext
{
AGLContext aglContext;
Rect rect;
WindowPtr windowPtr;
public:
RenderingContext();
~RenderingContext();
void RenderingContext::cleanupAGL(void);
void RenderingContext::destroy(void);
bool RenderingContext::setupAGL( AGLDrawable pAGLDrawable );
};