Menu

[r357]: / trunk / LWJGL / src / native / macosx / RenderingContext.cpp  Maximize  Restore  History

Download this file

83 lines (68 with data), 1.5 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
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);
}
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.