00001 #ifndef __FBOGLWRAP_H__
00002 #define __FBOGLWRAP_H__
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039 #include <kaydaradef.h>
00040 #ifndef FBSDK_DLL
00041
00044 #define FBSDK_DLL K_DLLIMPORT
00045 #endif
00046
00047 #ifdef KARCH_ENV_WIN
00048 #include <windows.h>
00049 #include <kgl/glew.h>
00050 #elif defined(KARCH_ENV_MACOSX)
00051 #include <AGL/Agl.h>
00052 #include <OpenGL/OpenGL.h>
00053 #endif
00054
00055 #ifdef FBSDKUseNamespace
00056 namespace FBSDKNamespace {
00057 #endif
00058
00059 __FB_FORWARD(FBOGLContextWrapper);
00060 FB_DEFINE_COMPONENT(FBSDK_DLL, OGLContextWrapper);
00061
00062 #ifdef KARCH_ENV_WIN
00063 typedef PIXELFORMATDESCRIPTOR FBPlatformPixelFormat;
00064 typedef HGLRC FBPlatformGLContext;
00065 typedef HDC FBPlatformDisplayContext;
00066 #elif defined (KARCH_ENV_MACOSX)
00067 typedef GLint * FBPlatformPixelFormat;
00068 typedef AGLContext FBPlatformGLContext;
00069 typedef AGLDrawable FBPlatformDisplayContext;
00070 #else
00071 typedef int FBPlatformPixelFormat;
00072 typedef int FBPlatformGLContext;
00073 typedef int FBPlatformDisplayContext;
00074 #endif
00075 typedef bool (* TIsPFD2EquivalentToPFD1)(const FBPlatformPixelFormat &, const FBPlatformPixelFormat &);
00076 typedef void (* TRenderOperation)(FBPlatformDisplayContext, int, int, int, int, FBPlatformDisplayContext, int, int, int, int, void *, const void *);
00077
00085 class FBSDK_DLL FBOGLContextWrapper : public FBComponent
00086 {
00087 __FBClassDeclare(FBOGLContextWrapper, FBComponent);
00088
00089 public:
00094 FBOGLContextWrapper(FBPlatformGLContext pHGLC, bool pAutoDelete);
00099 FBOGLContextWrapper(bool pShareLists = true, TIsPFD2EquivalentToPFD1 pPFDsComparator = NULL);
00100
00101 public:
00110 bool Allocate(FBPlatformDisplayContext pDC, FBPlatformPixelFormat & pPFD, int pW = -1, int pH = -1, bool pTryPBuffer = true, bool pTrySWContext = true);
00118 bool AllocateForcingPBuffer(FBPlatformDisplayContext pDC, FBPlatformPixelFormat & pPFD, int pW, int pH, bool pTrySWContext = true);
00125 bool AllocateForcingSWContext(FBPlatformDisplayContext pDC, FBPlatformPixelFormat & pPFD, int pW, int pH);
00126
00128 void Free();
00129
00130 public:
00135 bool BeginRender(FBPlatformDisplayContext pDC);
00140 void EndRender(TRenderOperation pOperation = RenderOperationBlit, void * pData = NULL);
00145 bool MakeCurrent(FBPlatformDisplayContext pDC);
00146
00147 public:
00151 bool IsAllocated() const;
00155 bool IsPBufferAllocated() const;
00159 bool IsSWContextAllocated() const;
00163 bool IsRendering() const;
00171 bool GetMaxPBufferSize(FBPlatformDisplayContext pDC, const FBPlatformPixelFormat & pPFD, int & pW, int & pH) const;
00172
00173 public:
00177 FBPlatformGLContext GetOGLContext() const;
00181 FBPlatformDisplayContext GetAllocatedDC() const;
00185 FBPlatformDisplayContext GetPBufferBitmapDC() const;
00189 FBPlatformDisplayContext GetSWContextBitmapDC() const;
00190
00191 public:
00195 struct FBOGLStretchBlitData {
00196 int mX,
00197 mY,
00198 mW,
00199 mH;
00200 };
00201
00213 static void RenderOperationBlit(FBPlatformDisplayContext pDCDst, int pXDst, int pYDst, int pWDst, int pHDst, FBPlatformDisplayContext pDCSrc, int pXSrc, int pYSrc, int, int, void * pParam, const void *);
00219 static void RenderOperationStretchBlit(FBPlatformDisplayContext pDCDst, int, int, int, int, FBPlatformDisplayContext, int, int, int, int, void * pParam, const void * pReserved);
00222 static void RenderOperationNil(FBPlatformDisplayContext, int, int, int, int, FBPlatformDisplayContext, int, int, int, int, void *, const void *);
00223
00224 public:
00229 static FBPlatformPixelFormat & DefaultPixelFormat(FBPlatformPixelFormat & pPFD);
00230 };
00231
00232 #ifdef FBSDKUseNamespace
00233 }
00234 #endif
00235
00236 #endif