Allow specification of "DLLMODE=native" for native dlls.
[wine] / dlls / ddraw / mesa_private.h
index a7094de..cfa36c4 100644 (file)
@@ -68,6 +68,18 @@ typedef struct IDirect3DTextureGLImpl
     BOOLEAN initial_upload_done;
     SURFACE_STATE dirty_flag;
 
+    /* This is used to optimize dirty checking in case of mipmapping.
+       Note that a bitmap could have been used but it was not worth the pain as it will be very rare
+       to have only one mipmap level change...
+
+       The __global_dirty_flag will only be set for the main mipmap level.
+    */
+    SURFACE_STATE __global_dirty_flag;
+    SURFACE_STATE *global_dirty_flag;
+    
+    /* This is to optimize the 'per-texture' parameters. */
+    DWORD *tex_parameters;
+    
     /* Surface optimization */
     void *surface_ptr;
 
@@ -88,15 +100,26 @@ typedef enum {
     GL_TRANSFORM_VERTEXBUFFER
 } GL_TRANSFORM_STATE;
 
+typedef enum {
+    WINE_GL_BUFFER_BACK = 0,
+    WINE_GL_BUFFER_FRONT
+} WINE_GL_BUFFER_TYPE;
+
 typedef struct IDirect3DDeviceGLImpl
 {
     struct IDirect3DDeviceImpl parent;
     
     GLXContext gl_context;
 
+    /* This stores the textures which are actually bound to the GL context */
+    IDirectDrawSurfaceImpl *current_bound_texture[MAX_TEXTURES];
+
     /* The last type of vertex drawn */
     GL_TRANSFORM_STATE transform_state;
 
+    /* Maybe a hack, but it works */
+    DWORD version;
+    
     /* Used to handle fogging faster... */
     BYTE fog_table[3 * 0x10000]; /* 3 is for R, G and B
                                    0x10000 is 0xFF for the vertex color and
@@ -109,9 +132,23 @@ typedef struct IDirect3DDeviceGLImpl
     GLuint unlock_tex;
     void *surface_ptr;
     GLenum current_internal_format;
-    
-    SURFACE_STATE state, front_state;
-    IDirectDrawSurfaceImpl *lock_surf, *front_lock_surf;
+
+    /* 0 is back-buffer, 1 is front-buffer */
+    SURFACE_STATE state[2];
+    IDirectDrawSurfaceImpl *lock_surf[2];
+    RECT lock_rect[2];
+    /* This is just here to print-out a nice warning if we have two successive locks */
+    BOOLEAN lock_rect_valid[2];
+
+    /* This is used to optimize some stuff */
+    DWORD prev_clear_color;
+    DWORD prev_clear_stencil;
+    D3DVALUE prev_clear_Z;
+    BOOLEAN depth_mask, depth_test, alpha_test, stencil_test, cull_face, lighting, blending, fogging;
+    GLenum current_alpha_test_func;
+    GLclampf current_alpha_test_ref;
+    GLenum current_tex_env;
+    GLenum current_active_tex_unit;
 } IDirect3DDeviceGLImpl;
 
 /* This is for the OpenGL additions... */
@@ -123,6 +160,24 @@ typedef struct {
     LPVOID vertices;
 } IDirect3DVertexBufferGLImpl;
 
+/* This is for GL extension support.
+   
+   This can contain either only a boolean if no function pointer exists or a set
+   of function pointers.
+*/
+typedef struct {
+    /* Mirrored Repeat */
+    BOOLEAN mirrored_repeat;
+    /* Mipmap lod-bias */
+    BOOLEAN mipmap_lodbias;
+    /* Multi-texturing */
+    GLint max_texture_units;
+    void (*glActiveTexture)(GLenum texture);
+    void (*glMultiTexCoord2fv)(GLenum target, const GLfloat *v);
+    void (*glClientActiveTexture)(GLenum texture);
+} GL_EXTENSIONS_LIST; 
+extern GL_EXTENSIONS_LIST GL_extensions;
+
 /* All non-static functions 'exported' by various sub-objects */
 extern HRESULT direct3d_create(IDirectDrawImpl *This);
 extern HRESULT d3dtexture_create(IDirectDrawImpl *d3d, IDirectDrawSurfaceImpl *surf, BOOLEAN at_creation, IDirectDrawSurfaceImpl *main_surf);
@@ -131,15 +186,18 @@ extern HRESULT d3dexecutebuffer_create(IDirect3DExecuteBufferImpl **obj, IDirect
 extern HRESULT d3dmaterial_create(IDirect3DMaterialImpl **obj, IDirectDrawImpl *d3d);
 extern HRESULT d3dviewport_create(IDirect3DViewportImpl **obj, IDirectDrawImpl *d3d);
 extern HRESULT d3dvertexbuffer_create(IDirect3DVertexBufferImpl **obj, IDirectDrawImpl *d3d, LPD3DVERTEXBUFFERDESC lpD3DVertBufDesc, DWORD dwFlags);
-extern HRESULT d3ddevice_create(IDirect3DDeviceImpl **obj, IDirectDrawImpl *d3d, IDirectDrawSurfaceImpl *surface);
+extern HRESULT d3ddevice_create(IDirect3DDeviceImpl **obj, IDirectDrawImpl *d3d, IDirectDrawSurfaceImpl *surface, BOOLEAN from_surface);
 
 /* Used for Direct3D to request the device to enumerate itself */
 extern HRESULT d3ddevice_enumerate(LPD3DENUMDEVICESCALLBACK cb, LPVOID context, DWORD version) ;
 extern HRESULT d3ddevice_enumerate7(LPD3DENUMDEVICESCALLBACK7 cb, LPVOID context) ;
 extern HRESULT d3ddevice_find(IDirectDrawImpl *d3d, LPD3DFINDDEVICESEARCH lpD3DDFS, LPD3DFINDDEVICERESULT lplpD3DDevice);
 
+/* Used by the DLL init routine to set-up the GL context and stuff properly */
+extern BOOL d3ddevice_init_at_startup(void *gl_handle);
+
 /* Used to upload the texture */
-extern HRESULT gltex_upload_texture(IDirectDrawSurfaceImpl *This) ;
+extern HRESULT gltex_upload_texture(IDirectDrawSurfaceImpl *This, IDirect3DDeviceImpl *d3ddev, DWORD stage) ;
 
 /* Used to set-up our orthographic projection */
 extern void d3ddevice_set_ortho(IDirect3DDeviceImpl *This) ;
@@ -156,6 +214,9 @@ extern HRESULT upload_surface_to_tex_memory_init(IDirectDrawSurfaceImpl *surface
 extern HRESULT upload_surface_to_tex_memory(RECT *rect, DWORD xoffset, DWORD yoffset, void **temp_buffer);
 extern HRESULT upload_surface_to_tex_memory_release(void);
 
+/* Some utilities functions needed to be shared.. */
+extern GLenum convert_D3D_compare_to_GL(D3DCMPFUNC dwRenderState) ;
+
 #endif /* HAVE_OPENGL */
 
 #endif /* __GRAPHICS_WINE_MESA_PRIVATE_H */