fbkernel/fboglwrap.h Source File
 
 
 
fbkernel/fboglwrap.h
Go to the documentation of this file.
00001 #ifndef __FBOGLWRAP_H__
00002 #define __FBOGLWRAP_H__
00003 /**************************************************************************
00004  Copyright (c) 1994 - 2006 Autodesk, Inc. and/or its licensors.
00005  All Rights Reserved.
00006  
00007  The coded instructions, statements, computer programs, and/or related 
00008  material (collectively the "Data") in these files contain unpublished 
00009  information proprietary to Autodesk, Inc. and/or its licensors, which is 
00010  protected by Canada and United States of America federal copyright law 
00011  and by international treaties.
00012  
00013  The Data may not be disclosed or distributed to third parties, in whole 
00014  or in part, without the prior written consent of Autodesk, Inc. 
00015  ("Autodesk").
00016  
00017  THE DATA IS PROVIDED "AS IS" AND WITHOUT WARRANTY.
00018  ALL WARRANTIES ARE EXPRESSLY EXCLUDED AND DISCLAIMED. AUTODESK MAKES NO 
00019  WARRANTY OF ANY KIND WITH RESPECT TO THE DATA, EXPRESS, IMPLIED OR 
00020  ARISING BY CUSTOM OR TRADE USAGE, AND DISCLAIMS ANY IMPLIED WARRANTIES 
00021  OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR 
00022  PURPOSE OR USE. WITHOUT LIMITING THE FOREGOING, AUTODESK DOES NOT 
00023  WARRANT THAT THE OPERATION OF THE DATA WILL BE UNINTERRUPTED OR ERROR 
00024  FREE.
00025  
00026  IN NO EVENT SHALL AUTODESK, ITS AFFILIATES, PARENT COMPANIES, LICENSORS 
00027  OR SUPPLIERS ("AUTODESK GROUP") BE LIABLE FOR ANY LOSSES, DAMAGES OR 
00028  EXPENSES OF ANY KIND (INCLUDING WITHOUT LIMITATION PUNITIVE OR MULTIPLE 
00029  DAMAGES OR OTHER SPECIAL, DIRECT, INDIRECT, EXEMPLARY, INCIDENTAL, LOSS 
00030  OF PROFITS, REVENUE OR DATA, COST OF COVER OR CONSEQUENTIAL LOSSES OR 
00031  DAMAGES OF ANY KIND), HOWEVER CAUSED, AND REGARDLESS OF THE THEORY OF 
00032  LIABILITY, WHETHER DERIVED FROM CONTRACT, TORT (INCLUDING, BUT NOT 
00033  LIMITED TO, NEGLIGENCE), OR OTHERWISE, ARISING OUT OF OR RELATING TO THE 
00034  DATA OR ITS USE OR ANY OTHER PERFORMANCE, WHETHER OR NOT AUTODESK HAS 
00035  BEEN ADVISED OF THE POSSIBILITY OF SUCH LOSS OR DAMAGE.
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