Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygendglcontext.h
Go to the documentation of this file.
00001 /**************************************************************************** 00002 * 00003 * Mesa 3-D graphics library 00004 * Direct3D Driver Interface 00005 * 00006 * ======================================================================== 00007 * 00008 * Copyright (C) 1991-2004 SciTech Software, Inc. All rights reserved. 00009 * 00010 * Permission is hereby granted, free of charge, to any person obtaining a 00011 * copy of this software and associated documentation files (the "Software"), 00012 * to deal in the Software without restriction, including without limitation 00013 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 00014 * and/or sell copies of the Software, and to permit persons to whom the 00015 * Software is furnished to do so, subject to the following conditions: 00016 * 00017 * The above copyright notice and this permission notice shall be included 00018 * in all copies or substantial portions of the Software. 00019 * 00020 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 00021 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 00022 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 00023 * SCITECH SOFTWARE INC BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 00024 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF 00025 * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 00026 * SOFTWARE. 00027 * 00028 * ====================================================================== 00029 * 00030 * Language: ANSI C 00031 * Environment: Windows 9x (Win32) 00032 * 00033 * Description: OpenGL context handling. 00034 * 00035 ****************************************************************************/ 00036 00037 #ifndef __DGLCONTEXT_H 00038 #define __DGLCONTEXT_H 00039 00040 // Disable compiler complaints about DLL linkage 00041 #pragma warning (disable:4273) 00042 00043 // Macros to control compilation 00044 #ifndef STRICT 00045 #define STRICT 00046 #endif // STRICT 00047 #define WIN32_LEAN_AND_MEAN 00048 #include <windows.h> 00049 #include <GL\gl.h> 00050 00051 #ifdef _USE_GLD3_WGL 00052 #include "dglmacros.h" 00053 #include "dglglobals.h" 00054 #include "pixpack.h" 00055 #include "ddlog.h" 00056 #include "dglpf.h" 00057 #include "context.h" // Mesa context 00058 #else 00059 #include <ddraw.h> 00060 #include <d3d.h> 00061 00062 #include "dglmacros.h" 00063 #include "dglglobals.h" 00064 #include "pixpack.h" 00065 #include "ddlog.h" 00066 #include "dglpf.h" 00067 #include "d3dvertex.h" 00068 00069 #include "DirectGL.h" 00070 00071 #include "context.h" // Mesa context 00072 #include "vb.h" // Mesa vertex buffer 00073 #endif // _USE_GLD3_WGL 00074 00075 /*---------------------- Macros and type definitions ----------------------*/ 00076 00077 // TODO: Use a list instead of this constant! 00078 #define DGL_MAX_CONTEXTS 32 00079 00080 // Structure for describing an OpenGL context 00081 #ifdef _USE_GLD3_WGL 00082 typedef struct { 00083 BOOL bHasBeenCurrent; 00084 DGL_pixelFormat *lpPF; 00085 00086 // Pointer to private driver data (this also contains the drawable). 00087 void *glPriv; 00088 00089 // Mesa vars: 00090 GLcontext *glCtx; // The core Mesa context 00091 GLvisual *glVis; // Describes the color buffer 00092 GLframebuffer *glBuffer; // Ancillary buffers 00093 00094 GLuint ClearIndex; 00095 GLuint CurrentIndex; 00096 GLubyte ClearColor[4]; 00097 GLubyte CurrentColor[4]; 00098 00099 BOOL EmulateSingle; // Emulate single-buffering 00100 BOOL bDoubleBuffer; 00101 BOOL bDepthBuffer; 00102 00103 // Shared driver vars: 00104 BOOL bAllocated; 00105 BOOL bFullscreen; // Is this a fullscreen context? 00106 BOOL bSceneStarted; // Has a lpDev->BeginScene been issued? 00107 BOOL bCanRender; // Flag: states whether rendering is OK 00108 BOOL bFrameStarted; // Has frame update started at all? 00109 BOOL bStencil; // TRUE if this context has stencil 00110 BOOL bGDIEraseBkgnd; // GDI Erase Background command 00111 00112 // Window information 00113 HWND hWnd; // Window handle 00114 HDC hDC; // Windows' Device Context of the window 00115 DWORD dwWidth; // Window width 00116 DWORD dwHeight; // Window height 00117 DWORD dwBPP; // Window bits-per-pixel; 00118 RECT rcScreenRect; // Screen rectangle 00119 DWORD dwModeWidth; // Display mode width 00120 DWORD dwModeHeight; // Display mode height 00121 float dvClipX; 00122 float dvClipY; 00123 LONG lpfnWndProc; // window message handler function 00124 00125 } DGL_ctx; 00126 00127 #define GLD_context DGL_ctx 00128 #define GLD_GET_CONTEXT(c) (GLD_context*)(c)->DriverCtx 00129 00130 #else // _USE_GLD3_WGL 00131 00132 typedef struct { 00133 BOOL bHasBeenCurrent; 00134 DGL_pixelFormat *lpPF; 00135 // 00136 // Mesa context vars: 00137 // 00138 GLcontext *glCtx; // The core Mesa context 00139 GLvisual *glVis; // Describes the color buffer 00140 GLframebuffer *glBuffer; // Ancillary buffers 00141 00142 GLuint ClearIndex; 00143 GLuint CurrentIndex; 00144 GLubyte ClearColor[4]; 00145 GLubyte CurrentColor[4]; 00146 00147 BOOL EmulateSingle; // Emulate single-buffering 00148 BOOL bDoubleBuffer; 00149 BOOL bDepthBuffer; 00150 int iZBufferPF; // Index of Zbuffer pixel format 00151 00152 // Vertex buffer: one-to-one correlation with Mesa's vertex buffer. 00153 // This will be filled by our setup function (see d3dvsetup.c) 00154 DGL_TLvertex gWin[VB_SIZE]; // Transformed and lit vertices 00155 // DGL_Lvertex gObj[VB_SIZE]; // Lit vertices in object coordinates. 00156 00157 // Indices for DrawIndexedPrimitive. 00158 // Clipped quads are drawn seperately, so use VB_SIZE. 00159 // 6 indices are needed to make 2 triangles for each possible quad 00160 // WORD wIndices[(VB_SIZE / 4) * 6]; 00161 WORD wIndices[32768]; 00162 00163 // 00164 // Device driver vars: 00165 // 00166 BOOL bAllocated; 00167 BOOL bFullscreen; // Is this a fullscreen context? 00168 BOOL bSceneStarted; // Has a lpDev->BeginScene been issued? 00169 BOOL bCanRender; // Flag: states whether rendering is OK 00170 BOOL bFrameStarted; // Has frame update started at all? 00171 00172 // DirectX COM interfaces, postfixed with the interface number 00173 IDirectDraw *lpDD1; 00174 IDirectDraw4 *lpDD4; 00175 IDirect3D3 *lpD3D3; 00176 IDirect3DDevice3 *lpDev3; 00177 IDirect3DViewport3 *lpViewport3; 00178 IDirectDrawSurface4 *lpFront4; 00179 IDirectDrawSurface4 *lpBack4; 00180 IDirectDrawSurface4 *lpDepth4; 00181 00182 // Vertex buffers 00183 BOOL bD3DPipeline; // True if using D3D geometry pipeline 00184 IDirect3DVertexBuffer *m_vbuf; // Unprocessed vertices 00185 IDirect3DVertexBuffer *m_pvbuf; // Processed vertices ready to be rendered 00186 00187 D3DTEXTUREOP ColorOp[MAX_TEXTURE_UNITS]; // Used for re-enabling texturing 00188 D3DTEXTUREOP AlphaOp[MAX_TEXTURE_UNITS]; // Used for re-enabling texturing 00189 struct gl_texture_object *tObj[MAX_TEXTURE_UNITS]; 00190 00191 DDCAPS ddCaps; // DirectDraw caps 00192 D3DDEVICEDESC D3DDevDesc; // Direct3D Device description 00193 00194 DDPIXELFORMAT ddpfRender; // Pixel format of the render buffer 00195 DDPIXELFORMAT ddpfDepth; // Pixel format of the depth buffer 00196 00197 BOOL bStencil; // TRUE is this context has stencil 00198 00199 PX_packFunc fnPackFunc; // Pixel packing function for SW 00200 PX_unpackFunc fnUnpackFunc; // Pixel unpacking function for SW 00201 PX_packSpanFunc fnPackSpanFunc; // Pixel span packer 00202 00203 D3DVIEWPORT2 d3dViewport; // D3D Viewport object 00204 00205 D3DCULL cullmode; // Direct3D cull mode 00206 D3DCOLOR curcolor; // Current color 00207 DWORD dwColorPF; // Current color, in format of target surface 00208 D3DCOLOR d3dClearColor; // Clear color 00209 D3DCOLOR ConstantColor; // For flat shading 00210 DWORD dwClearColorPF; // Clear color, in format of target surface 00211 BOOL bGDIEraseBkgnd; // GDI Erase Background command 00212 00213 // Primitive caches 00214 // DGL_vertex LineCache[DGL_MAX_LINE_VERTS]; 00215 // DGL_vertex TriCache[DGL_MAX_TRI_VERTS]; 00216 // DWORD dwNextLineVert; 00217 // DWORD dwNextTriVert; 00218 00219 // Window information 00220 HWND hWnd; // Window handle 00221 HDC hDC; // Windows' Device Context of the window 00222 DWORD dwWidth; // Window width 00223 DWORD dwHeight; // Window height 00224 DWORD dwBPP; // Window bits-per-pixel; 00225 RECT rcScreenRect; // Screen rectangle 00226 DWORD dwModeWidth; // Display mode width 00227 DWORD dwModeHeight; // Display mode height 00228 float dvClipX; 00229 float dvClipY; 00230 LONG lpfnWndProc; // window message handler function 00231 00232 // Shared texture palette 00233 IDirectDrawPalette *lpGlobalPalette; 00234 00235 // Usage counters. 00236 // One of these counters will be incremented when we choose 00237 // between hardware and software rendering functions. 00238 // DWORD dwHWUsageCount; // Hardware usage count 00239 // DWORD dwSWUsageCount; // Software usage count 00240 00241 // Texture state flags. 00242 // BOOL m_texturing; // TRUE is texturing 00243 // BOOL m_mtex; // TRUE if multitexture 00244 // BOOL m_texHandleValid; // TRUE if tex state valid 00245 00246 // Renderstate caches to ensure no redundant state changes 00247 DWORD dwRS[256]; // Renderstates 00248 DWORD dwTSS[2][24]; // Texture-stage states 00249 LPDIRECT3DTEXTURE2 lpTex[2]; // Texture (1 per stage) 00250 00251 DWORD dwMaxTextureSize; // Max texture size: 00252 // clamped to 1024. 00253 00254 } DGL_ctx; 00255 #endif // _USE_GLD3_WGL 00256 00257 /*------------------------- Function Prototypes ---------------------------*/ 00258 00259 #ifdef __cplusplus 00260 extern "C" { 00261 #endif 00262 00263 HHOOK hKeyHook; 00264 LRESULT CALLBACK dglKeyProc(int code,WPARAM wParam,LPARAM lParam); 00265 00266 void dglInitContextState(); 00267 void dglDeleteContextState(); 00268 BOOL dglIsValidContext(HGLRC a); 00269 DGL_ctx* dglGetContextAddress(const HGLRC a); 00270 HDC dglGetCurrentDC(void); 00271 HGLRC dglGetCurrentContext(void); 00272 HGLRC dglCreateContext(HDC a, const DGL_pixelFormat *lpPF); 00273 BOOL dglMakeCurrent(HDC a, HGLRC b); 00274 BOOL dglDeleteContext(HGLRC a); 00275 BOOL dglSwapBuffers(HDC hDC); 00276 00277 #ifdef __cplusplus 00278 } 00279 #endif 00280 00281 #endif Generated on Fri May 25 2012 04:18:04 for ReactOS by
1.7.6.1
|