1 | #include "OgreStableHeaders.h" |
---|
2 | |
---|
3 | #include "OgreException.h" |
---|
4 | #include "OgreLogManager.h" |
---|
5 | #include "OgreRoot.h" |
---|
6 | #include "OgreStringConverter.h" |
---|
7 | |
---|
8 | #include "OgreGLRenderSystem.h" |
---|
9 | |
---|
10 | #include "OgreOSXRenderTexture.h" |
---|
11 | #include "OgreOSXCarbonContext.h" |
---|
12 | |
---|
13 | #include <OpenGL/gl.h> |
---|
14 | #define GL_EXT_texture_env_combine 1 |
---|
15 | #include <OpenGL/glext.h> |
---|
16 | #include <OpenGL/glu.h> |
---|
17 | #include <AGL/agl.h> |
---|
18 | |
---|
19 | namespace Ogre |
---|
20 | { |
---|
21 | OSXPBuffer::OSXPBuffer( PixelComponentType format, size_t width, size_t height ) : GLPBuffer( format, width, height ), mContext( NULL ) |
---|
22 | { |
---|
23 | LogManager::getSingleton().logMessage( "OSXPBuffer::OSXPBuffer()" ); |
---|
24 | createPBuffer(); |
---|
25 | // Create context |
---|
26 | mContext = new OSXCarbonContext( mAGLContext ); |
---|
27 | } |
---|
28 | |
---|
29 | OSXPBuffer::~OSXPBuffer() |
---|
30 | { |
---|
31 | LogManager::getSingleton().logMessage( "OSXPBuffer::~OSXPBuffer()" ); |
---|
32 | delete mContext; |
---|
33 | destroyPBuffer(); |
---|
34 | } |
---|
35 | |
---|
36 | GLContext* OSXPBuffer::getContext() |
---|
37 | { |
---|
38 | LogManager::getSingleton().logMessage( "OSXPBuffer::getContext()" ); |
---|
39 | return mContext; |
---|
40 | } |
---|
41 | |
---|
42 | void OSXPBuffer::createPBuffer() |
---|
43 | { |
---|
44 | LogManager::getSingleton().logMessage( "OSXPBuffer::createPBuffer()" ); |
---|
45 | |
---|
46 | GLint attrib[] = { AGL_NO_RECOVERY, GL_TRUE, AGL_ACCELERATED, GL_TRUE, AGL_RGBA, AGL_NONE }; |
---|
47 | AGLPixelFormat pixelFormat = aglChoosePixelFormat(NULL, 0, attrib); |
---|
48 | mAGLContext = aglCreateContext(pixelFormat, NULL); |
---|
49 | |
---|
50 | //mAGLContext = aglGetCurrentContext(); |
---|
51 | aglCreatePBuffer( mWidth, mHeight, GL_TEXTURE_2D, GL_RGBA, 0, &mPBuffer ); |
---|
52 | |
---|
53 | GLint vs = aglGetVirtualScreen( mAGLContext ); |
---|
54 | aglSetPBuffer( mAGLContext, mPBuffer, 0, 0, vs ); |
---|
55 | } |
---|
56 | |
---|
57 | void OSXPBuffer::destroyPBuffer() |
---|
58 | { |
---|
59 | LogManager::getSingleton().logMessage( "OSXPBuffer::destroyPBuffer()" ); |
---|
60 | aglDestroyPBuffer( mPBuffer ); |
---|
61 | } |
---|
62 | } |
---|
63 | |
---|