Sync with trunk r63647.
[reactos.git] / dll / opengl / mesa / drivers / common / driverfuncs.c
1 /*
2 * Mesa 3-D graphics library
3 * Version: 7.1
4 *
5 * Copyright (C) 1999-2007 Brian Paul All Rights Reserved.
6 *
7 * Permission is hereby granted, free of charge, to any person obtaining a
8 * copy of this software and associated documentation files (the "Software"),
9 * to deal in the Software without restriction, including without limitation
10 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
11 * and/or sell copies of the Software, and to permit persons to whom the
12 * Software is furnished to do so, subject to the following conditions:
13 *
14 * The above copyright notice and this permission notice shall be included
15 * in all copies or substantial portions of the Software.
16 *
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
21 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23 */
24
25
26 #include "main/glheader.h"
27 #include "main/imports.h"
28 #include "main/accum.h"
29 #include "main/context.h"
30 #include "main/framebuffer.h"
31 #include "main/readpix.h"
32 #include "main/renderbuffer.h"
33 #include "main/texformat.h"
34 #include "main/texgetimage.h"
35 #include "main/teximage.h"
36 #include "main/texobj.h"
37 #include "main/texstore.h"
38 #include "main/bufferobj.h"
39
40 #include "tnl/tnl.h"
41 #include "swrast/swrast.h"
42 #include "swrast/s_renderbuffer.h"
43
44 #include "driverfuncs.h"
45 #include "meta.h"
46
47
48
49 /**
50 * Plug in default functions for all pointers in the dd_function_table
51 * structure.
52 * Device drivers should call this function and then plug in any
53 * functions which it wants to override.
54 * Some functions (pointers) MUST be implemented by all drivers (REQUIRED).
55 *
56 * \param table the dd_function_table to initialize
57 */
58 void
59 _mesa_init_driver_functions(struct dd_function_table *driver)
60 {
61 memset(driver, 0, sizeof(*driver));
62
63 driver->GetString = NULL; /* REQUIRED! */
64 driver->UpdateState = NULL; /* REQUIRED! */
65 driver->GetBufferSize = NULL; /* REQUIRED! */
66 driver->ResizeBuffers = _mesa_resize_framebuffer;
67 driver->Error = NULL;
68
69 driver->Finish = NULL;
70 driver->Flush = NULL;
71
72 /* framebuffer/image functions */
73 driver->Clear = _swrast_Clear;
74 driver->Accum = _mesa_accum;
75 driver->RasterPos = _tnl_RasterPos;
76 driver->DrawPixels = _swrast_DrawPixels;
77 driver->ReadPixels = _mesa_readpixels;
78 driver->CopyPixels = _swrast_CopyPixels;
79 driver->Bitmap = _swrast_Bitmap;
80
81 /* Texture functions */
82 driver->ChooseTextureFormat = _mesa_choose_tex_format;
83 driver->TexImage1D = _mesa_store_teximage1d;
84 driver->TexImage2D = _mesa_store_teximage2d;
85 driver->TexSubImage1D = _mesa_store_texsubimage1d;
86 driver->TexSubImage2D = _mesa_store_texsubimage2d;
87 driver->GetTexImage = _mesa_get_teximage;
88 driver->CopyTexSubImage1D = _mesa_meta_CopyTexSubImage1D;
89 driver->CopyTexSubImage2D = _mesa_meta_CopyTexSubImage2D;
90 driver->TestProxyTexImage = _mesa_test_proxy_teximage;
91 driver->BindTexture = NULL;
92 driver->NewTextureObject = _mesa_new_texture_object;
93 driver->DeleteTexture = _mesa_delete_texture_object;
94 driver->NewTextureImage = _swrast_new_texture_image;
95 driver->DeleteTextureImage = _swrast_delete_texture_image;
96 driver->AllocTextureImageBuffer = _swrast_alloc_texture_image_buffer;
97 driver->FreeTextureImageBuffer = _swrast_free_texture_image_buffer;
98 driver->MapTextureImage = _swrast_map_teximage;
99 driver->UnmapTextureImage = _swrast_unmap_teximage;
100
101 /* simple state commands */
102 driver->AlphaFunc = NULL;
103 driver->ClearColor = NULL;
104 driver->ClearDepth = NULL;
105 driver->ClearStencil = NULL;
106 driver->ClipPlane = NULL;
107 driver->ColorMask = NULL;
108 driver->ColorMaterial = NULL;
109 driver->CullFace = NULL;
110 driver->DrawBuffer = NULL;
111 driver->FrontFace = NULL;
112 driver->DepthFunc = NULL;
113 driver->DepthMask = NULL;
114 driver->DepthRange = NULL;
115 driver->Enable = NULL;
116 driver->Fogfv = NULL;
117 driver->Hint = NULL;
118 driver->Lightfv = NULL;
119 driver->LightModelfv = NULL;
120 driver->LineStipple = NULL;
121 driver->LineWidth = NULL;
122 driver->LogicOpcode = NULL;
123 driver->PointParameterfv = NULL;
124 driver->PointSize = NULL;
125 driver->PolygonMode = NULL;
126 driver->PolygonOffset = NULL;
127 driver->PolygonStipple = NULL;
128 driver->ReadBuffer = NULL;
129 driver->RenderMode = NULL;
130 driver->Scissor = NULL;
131 driver->ShadeModel = NULL;
132 driver->TexGen = NULL;
133 driver->TexEnv = NULL;
134 driver->TexParameter = NULL;
135 driver->Viewport = NULL;
136
137 /* buffer objects */
138 _mesa_init_buffer_object_functions(driver);
139
140 driver->MapRenderbuffer = _swrast_map_soft_renderbuffer;
141 driver->UnmapRenderbuffer = _swrast_unmap_soft_renderbuffer;
142
143 /* T&L stuff */
144 driver->CurrentExecPrimitive = 0;
145 driver->CurrentSavePrimitive = 0;
146 driver->NeedFlush = 0;
147 driver->SaveNeedFlush = 0;
148
149 driver->FlushVertices = NULL;
150 driver->SaveFlushVertices = NULL;
151 driver->PrepareExecBegin = NULL;
152 driver->NotifySaveBegin = NULL;
153 driver->LightingSpaceChange = NULL;
154
155 /* display list */
156 driver->NewList = NULL;
157 driver->EndList = NULL;
158 driver->BeginCallList = NULL;
159 driver->EndCallList = NULL;
160
161 /* GL_ARB_texture_storage */
162 driver->AllocTextureStorage = _swrast_AllocTextureStorage;
163 }