OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2009, Google Inc. | 2 * Copyright 2009, Google Inc. |
3 * All rights reserved. | 3 * All rights reserved. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions are | 6 * modification, are permitted provided that the following conditions are |
7 * met: | 7 * met: |
8 * | 8 * |
9 * * Redistributions of source code must retain the above copyright | 9 * * Redistributions of source code must retain the above copyright |
10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 | 91 |
92 // Implements the SetViewport function for GL. | 92 // Implements the SetViewport function for GL. |
93 virtual void SetViewport(unsigned int x, | 93 virtual void SetViewport(unsigned int x, |
94 unsigned int y, | 94 unsigned int y, |
95 unsigned int width, | 95 unsigned int width, |
96 unsigned int height, | 96 unsigned int height, |
97 float z_min, | 97 float z_min, |
98 float z_max); | 98 float z_max); |
99 | 99 |
100 // Implements the CreateVertexBuffer function for GL. | 100 // Implements the CreateVertexBuffer function for GL. |
101 virtual ParseError CreateVertexBuffer(ResourceID id, | 101 virtual ParseError CreateVertexBuffer(ResourceId id, |
102 unsigned int size, | 102 unsigned int size, |
103 unsigned int flags); | 103 unsigned int flags); |
104 | 104 |
105 // Implements the DestroyVertexBuffer function for GL. | 105 // Implements the DestroyVertexBuffer function for GL. |
106 virtual ParseError DestroyVertexBuffer(ResourceID id); | 106 virtual ParseError DestroyVertexBuffer(ResourceId id); |
107 | 107 |
108 // Implements the SetVertexBufferData function for GL. | 108 // Implements the SetVertexBufferData function for GL. |
109 virtual ParseError SetVertexBufferData(ResourceID id, | 109 virtual ParseError SetVertexBufferData(ResourceId id, |
110 unsigned int offset, | 110 unsigned int offset, |
111 unsigned int size, | 111 unsigned int size, |
112 const void *data); | 112 const void *data); |
113 | 113 |
114 // Implements the GetVertexBufferData function for GL. | 114 // Implements the GetVertexBufferData function for GL. |
115 virtual ParseError GetVertexBufferData(ResourceID id, | 115 virtual ParseError GetVertexBufferData(ResourceId id, |
116 unsigned int offset, | 116 unsigned int offset, |
117 unsigned int size, | 117 unsigned int size, |
118 void *data); | 118 void *data); |
119 | 119 |
120 // Implements the CreateIndexBuffer function for GL. | 120 // Implements the CreateIndexBuffer function for GL. |
121 virtual ParseError CreateIndexBuffer(ResourceID id, | 121 virtual ParseError CreateIndexBuffer(ResourceId id, |
122 unsigned int size, | 122 unsigned int size, |
123 unsigned int flags); | 123 unsigned int flags); |
124 | 124 |
125 // Implements the DestroyIndexBuffer function for GL. | 125 // Implements the DestroyIndexBuffer function for GL. |
126 virtual ParseError DestroyIndexBuffer(ResourceID id); | 126 virtual ParseError DestroyIndexBuffer(ResourceId id); |
127 | 127 |
128 // Implements the SetIndexBufferData function for GL. | 128 // Implements the SetIndexBufferData function for GL. |
129 virtual ParseError SetIndexBufferData(ResourceID id, | 129 virtual ParseError SetIndexBufferData(ResourceId id, |
130 unsigned int offset, | 130 unsigned int offset, |
131 unsigned int size, | 131 unsigned int size, |
132 const void *data); | 132 const void *data); |
133 | 133 |
134 // Implements the GetIndexBufferData function for GL. | 134 // Implements the GetIndexBufferData function for GL. |
135 virtual ParseError GetIndexBufferData(ResourceID id, | 135 virtual ParseError GetIndexBufferData(ResourceId id, |
136 unsigned int offset, | 136 unsigned int offset, |
137 unsigned int size, | 137 unsigned int size, |
138 void *data); | 138 void *data); |
139 | 139 |
140 // Implements the CreateVertexStruct function for GL. | 140 // Implements the CreateVertexStruct function for GL. |
141 virtual ParseError CreateVertexStruct(ResourceID id, | 141 virtual ParseError CreateVertexStruct(ResourceId id, |
142 unsigned int input_count); | 142 unsigned int input_count); |
143 | 143 |
144 // Implements the DestroyVertexStruct function for GL. | 144 // Implements the DestroyVertexStruct function for GL. |
145 virtual ParseError DestroyVertexStruct(ResourceID id); | 145 virtual ParseError DestroyVertexStruct(ResourceId id); |
146 | 146 |
147 // Implements the SetVertexInput function for GL. | 147 // Implements the SetVertexInput function for GL. |
148 virtual ParseError SetVertexInput(ResourceID vertex_struct_id, | 148 virtual ParseError SetVertexInput(ResourceId vertex_struct_id, |
149 unsigned int input_index, | 149 unsigned int input_index, |
150 ResourceID vertex_buffer_id, | 150 ResourceId vertex_buffer_id, |
151 unsigned int offset, | 151 unsigned int offset, |
152 unsigned int stride, | 152 unsigned int stride, |
153 vertex_struct::Type type, | 153 vertex_struct::Type type, |
154 vertex_struct::Semantic semantic, | 154 vertex_struct::Semantic semantic, |
155 unsigned int semantic_index); | 155 unsigned int semantic_index); |
156 | 156 |
157 // Implements the SetVertexStruct function for GL. | 157 // Implements the SetVertexStruct function for GL. |
158 virtual ParseError SetVertexStruct(ResourceID id); | 158 virtual ParseError SetVertexStruct(ResourceId id); |
159 | 159 |
160 // Implements the Draw function for GL. | 160 // Implements the Draw function for GL. |
161 virtual ParseError Draw(PrimitiveType primitive_type, | 161 virtual ParseError Draw(PrimitiveType primitive_type, |
162 unsigned int first, | 162 unsigned int first, |
163 unsigned int count); | 163 unsigned int count); |
164 | 164 |
165 // Implements the DrawIndexed function for GL. | 165 // Implements the DrawIndexed function for GL. |
166 virtual ParseError DrawIndexed(PrimitiveType primitive_type, | 166 virtual ParseError DrawIndexed(PrimitiveType primitive_type, |
167 ResourceID index_buffer_id, | 167 ResourceId index_buffer_id, |
168 unsigned int first, | 168 unsigned int first, |
169 unsigned int count, | 169 unsigned int count, |
170 unsigned int min_index, | 170 unsigned int min_index, |
171 unsigned int max_index); | 171 unsigned int max_index); |
172 | 172 |
173 // Implements the CreateEffect function for GL. | 173 // Implements the CreateEffect function for GL. |
174 virtual ParseError CreateEffect(ResourceID id, | 174 virtual ParseError CreateEffect(ResourceId id, |
175 unsigned int size, | 175 unsigned int size, |
176 const void *data); | 176 const void *data); |
177 | 177 |
178 // Implements the DestroyEffect function for GL. | 178 // Implements the DestroyEffect function for GL. |
179 virtual ParseError DestroyEffect(ResourceID id); | 179 virtual ParseError DestroyEffect(ResourceId id); |
180 | 180 |
181 // Implements the SetEffect function for GL. | 181 // Implements the SetEffect function for GL. |
182 virtual ParseError SetEffect(ResourceID id); | 182 virtual ParseError SetEffect(ResourceId id); |
183 | 183 |
184 // Implements the GetParamCount function for GL. | 184 // Implements the GetParamCount function for GL. |
185 virtual ParseError GetParamCount(ResourceID id, | 185 virtual ParseError GetParamCount(ResourceId id, |
186 unsigned int size, | 186 unsigned int size, |
187 void *data); | 187 void *data); |
188 | 188 |
189 // Implements the CreateParam function for GL. | 189 // Implements the CreateParam function for GL. |
190 virtual ParseError CreateParam(ResourceID param_id, | 190 virtual ParseError CreateParam(ResourceId param_id, |
191 ResourceID effect_id, | 191 ResourceId effect_id, |
192 unsigned int index); | 192 unsigned int index); |
193 | 193 |
194 // Implements the CreateParamByName function for GL. | 194 // Implements the CreateParamByName function for GL. |
195 virtual ParseError CreateParamByName(ResourceID param_id, | 195 virtual ParseError CreateParamByName(ResourceId param_id, |
196 ResourceID effect_id, | 196 ResourceId effect_id, |
197 unsigned int size, | 197 unsigned int size, |
198 const void *name); | 198 const void *name); |
199 | 199 |
200 // Implements the DestroyParam function for GL. | 200 // Implements the DestroyParam function for GL. |
201 virtual ParseError DestroyParam(ResourceID id); | 201 virtual ParseError DestroyParam(ResourceId id); |
202 | 202 |
203 // Implements the SetParamData function for GL. | 203 // Implements the SetParamData function for GL. |
204 virtual ParseError SetParamData(ResourceID id, | 204 virtual ParseError SetParamData(ResourceId id, |
205 unsigned int size, | 205 unsigned int size, |
206 const void *data); | 206 const void *data); |
207 | 207 |
208 // Implements the GetParamDesc function for GL. | 208 // Implements the GetParamDesc function for GL. |
209 virtual ParseError GetParamDesc(ResourceID id, | 209 virtual ParseError GetParamDesc(ResourceId id, |
210 unsigned int size, | 210 unsigned int size, |
211 void *data); | 211 void *data); |
212 | 212 |
213 // Implements the GetStreamCount function for GL. | 213 // Implements the GetStreamCount function for GL. |
214 virtual ParseError GetStreamCount(ResourceID id, | 214 virtual ParseError GetStreamCount(ResourceId id, |
215 unsigned int size, | 215 unsigned int size, |
216 void *data); | 216 void *data); |
217 | 217 |
218 // Implements the GetStreamDesc function for GL. | 218 // Implements the GetStreamDesc function for GL. |
219 virtual ParseError GetStreamDesc(ResourceID id, | 219 virtual ParseError GetStreamDesc(ResourceId id, |
220 unsigned int index, | 220 unsigned int index, |
221 unsigned int size, | 221 unsigned int size, |
222 void *data); | 222 void *data); |
223 | 223 |
224 // Implements the CreateTexture2D function for GL. | 224 // Implements the CreateTexture2D function for GL. |
225 virtual ParseError CreateTexture2D(ResourceID id, | 225 virtual ParseError CreateTexture2D(ResourceId id, |
226 unsigned int width, | 226 unsigned int width, |
227 unsigned int height, | 227 unsigned int height, |
228 unsigned int levels, | 228 unsigned int levels, |
229 texture::Format format, | 229 texture::Format format, |
230 unsigned int flags, | 230 unsigned int flags, |
231 bool enable_render_surfaces); | 231 bool enable_render_surfaces); |
232 | 232 |
233 // Implements the CreateTexture3D function for GL. | 233 // Implements the CreateTexture3D function for GL. |
234 virtual ParseError CreateTexture3D(ResourceID id, | 234 virtual ParseError CreateTexture3D(ResourceId id, |
235 unsigned int width, | 235 unsigned int width, |
236 unsigned int height, | 236 unsigned int height, |
237 unsigned int depth, | 237 unsigned int depth, |
238 unsigned int levels, | 238 unsigned int levels, |
239 texture::Format format, | 239 texture::Format format, |
240 unsigned int flags, | 240 unsigned int flags, |
241 bool enable_render_surfaces); | 241 bool enable_render_surfaces); |
242 | 242 |
243 // Implements the CreateTextureCube function for GL. | 243 // Implements the CreateTextureCube function for GL. |
244 virtual ParseError CreateTextureCube(ResourceID id, | 244 virtual ParseError CreateTextureCube(ResourceId id, |
245 unsigned int side, | 245 unsigned int side, |
246 unsigned int levels, | 246 unsigned int levels, |
247 texture::Format format, | 247 texture::Format format, |
248 unsigned int flags, | 248 unsigned int flags, |
249 bool enable_render_surfaces); | 249 bool enable_render_surfaces); |
250 | 250 |
251 // Implements the SetTextureData function for GL. | 251 // Implements the SetTextureData function for GL. |
252 virtual ParseError SetTextureData(ResourceID id, | 252 virtual ParseError SetTextureData(ResourceId id, |
253 unsigned int x, | 253 unsigned int x, |
254 unsigned int y, | 254 unsigned int y, |
255 unsigned int z, | 255 unsigned int z, |
256 unsigned int width, | 256 unsigned int width, |
257 unsigned int height, | 257 unsigned int height, |
258 unsigned int depth, | 258 unsigned int depth, |
259 unsigned int level, | 259 unsigned int level, |
260 texture::Face face, | 260 texture::Face face, |
261 unsigned int pitch, | 261 unsigned int pitch, |
262 unsigned int slice_pitch, | 262 unsigned int slice_pitch, |
263 unsigned int size, | 263 unsigned int size, |
264 const void *data); | 264 const void *data); |
265 | 265 |
266 // Implements the GetTextureData function for GL. | 266 // Implements the GetTextureData function for GL. |
267 virtual ParseError GetTextureData(ResourceID id, | 267 virtual ParseError GetTextureData(ResourceId id, |
268 unsigned int x, | 268 unsigned int x, |
269 unsigned int y, | 269 unsigned int y, |
270 unsigned int z, | 270 unsigned int z, |
271 unsigned int width, | 271 unsigned int width, |
272 unsigned int height, | 272 unsigned int height, |
273 unsigned int depth, | 273 unsigned int depth, |
274 unsigned int level, | 274 unsigned int level, |
275 texture::Face face, | 275 texture::Face face, |
276 unsigned int pitch, | 276 unsigned int pitch, |
277 unsigned int slice_pitch, | 277 unsigned int slice_pitch, |
278 unsigned int size, | 278 unsigned int size, |
279 void *data); | 279 void *data); |
280 | 280 |
281 // Implements the DestroyTexture function for GL. | 281 // Implements the DestroyTexture function for GL. |
282 virtual ParseError DestroyTexture(ResourceID id); | 282 virtual ParseError DestroyTexture(ResourceId id); |
283 | 283 |
284 // Implements the CreateSampler function for GL. | 284 // Implements the CreateSampler function for GL. |
285 virtual ParseError CreateSampler(ResourceID id); | 285 virtual ParseError CreateSampler(ResourceId id); |
286 | 286 |
287 // Implements the DestroySampler function for GL. | 287 // Implements the DestroySampler function for GL. |
288 virtual ParseError DestroySampler(ResourceID id); | 288 virtual ParseError DestroySampler(ResourceId id); |
289 | 289 |
290 // Implements the SetSamplerStates function for GL. | 290 // Implements the SetSamplerStates function for GL. |
291 virtual ParseError SetSamplerStates(ResourceID id, | 291 virtual ParseError SetSamplerStates(ResourceId id, |
292 sampler::AddressingMode addressing_u, | 292 sampler::AddressingMode addressing_u, |
293 sampler::AddressingMode addressing_v, | 293 sampler::AddressingMode addressing_v, |
294 sampler::AddressingMode addressing_w, | 294 sampler::AddressingMode addressing_w, |
295 sampler::FilteringMode mag_filter, | 295 sampler::FilteringMode mag_filter, |
296 sampler::FilteringMode min_filter, | 296 sampler::FilteringMode min_filter, |
297 sampler::FilteringMode mip_filter, | 297 sampler::FilteringMode mip_filter, |
298 unsigned int max_anisotropy); | 298 unsigned int max_anisotropy); |
299 | 299 |
300 // Implements the SetSamplerBorderColor function for GL. | 300 // Implements the SetSamplerBorderColor function for GL. |
301 virtual ParseError SetSamplerBorderColor(ResourceID id, const RGBA &color); | 301 virtual ParseError SetSamplerBorderColor(ResourceId id, const RGBA &color); |
302 | 302 |
303 // Implements the SetSamplerTexture function for GL. | 303 // Implements the SetSamplerTexture function for GL. |
304 virtual ParseError SetSamplerTexture(ResourceID id, ResourceID texture_id); | 304 virtual ParseError SetSamplerTexture(ResourceId id, ResourceId texture_id); |
305 | 305 |
306 // Implements the SetScissor function for GL. | 306 // Implements the SetScissor function for GL. |
307 virtual void SetScissor(bool enable, | 307 virtual void SetScissor(bool enable, |
308 unsigned int x, | 308 unsigned int x, |
309 unsigned int y, | 309 unsigned int y, |
310 unsigned int width, | 310 unsigned int width, |
311 unsigned int height); | 311 unsigned int height); |
312 | 312 |
313 // Implements the SetPointLineRaster function for GL. | 313 // Implements the SetPointLineRaster function for GL. |
314 virtual void SetPointLineRaster(bool line_smooth, | 314 virtual void SetPointLineRaster(bool line_smooth, |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
354 BlendFunc color_src_func, | 354 BlendFunc color_src_func, |
355 BlendFunc color_dst_func, | 355 BlendFunc color_dst_func, |
356 BlendEq alpha_eq, | 356 BlendEq alpha_eq, |
357 BlendFunc alpha_src_func, | 357 BlendFunc alpha_src_func, |
358 BlendFunc alpha_dst_func); | 358 BlendFunc alpha_dst_func); |
359 | 359 |
360 // Implements the SetBlendingColor function for GL. | 360 // Implements the SetBlendingColor function for GL. |
361 virtual void SetBlendingColor(const RGBA &color); | 361 virtual void SetBlendingColor(const RGBA &color); |
362 | 362 |
363 // Implements the CreateRenderSurface function for GL. | 363 // Implements the CreateRenderSurface function for GL. |
364 virtual ParseError CreateRenderSurface(ResourceID id, | 364 virtual ParseError CreateRenderSurface(ResourceId id, |
365 unsigned int width, | 365 unsigned int width, |
366 unsigned int height, | 366 unsigned int height, |
367 unsigned int mip_level, | 367 unsigned int mip_level, |
368 unsigned int side, | 368 unsigned int side, |
369 ResourceID texture_id); | 369 ResourceId texture_id); |
370 | 370 |
371 // Implements the DestroyRenderSurface function for GL. | 371 // Implements the DestroyRenderSurface function for GL. |
372 virtual ParseError DestroyRenderSurface(ResourceID id); | 372 virtual ParseError DestroyRenderSurface(ResourceId id); |
373 | 373 |
374 // Implements the CreateDepthSurface function for GL. | 374 // Implements the CreateDepthSurface function for GL. |
375 virtual ParseError CreateDepthSurface(ResourceID id, | 375 virtual ParseError CreateDepthSurface(ResourceId id, |
376 unsigned int width, | 376 unsigned int width, |
377 unsigned int height); | 377 unsigned int height); |
378 | 378 |
379 // Implements the DestroyDepthSurface function for GL. | 379 // Implements the DestroyDepthSurface function for GL. |
380 virtual ParseError DestroyDepthSurface(ResourceID id); | 380 virtual ParseError DestroyDepthSurface(ResourceId id); |
381 | 381 |
382 // Implements the SetRenderSurface function for GL. | 382 // Implements the SetRenderSurface function for GL. |
383 virtual ParseError SetRenderSurface(ResourceID render_surface_id, | 383 virtual ParseError SetRenderSurface(ResourceId render_surface_id, |
384 ResourceID depth_stencil_id); | 384 ResourceId depth_stencil_id); |
385 | 385 |
386 // Implements the SetBackSurfaces function for GL. | 386 // Implements the SetBackSurfaces function for GL. |
387 virtual void SetBackSurfaces(); | 387 virtual void SetBackSurfaces(); |
388 | 388 |
389 // Gets a vertex buffer by resource ID. | 389 // Gets a vertex buffer by resource ID. |
390 VertexBufferGL *GetVertexBuffer(ResourceID id) { | 390 VertexBufferGL *GetVertexBuffer(ResourceId id) { |
391 return vertex_buffers_.Get(id); | 391 return vertex_buffers_.Get(id); |
392 } | 392 } |
393 | 393 |
394 // Gets a texture by resource ID. | 394 // Gets a texture by resource ID. |
395 TextureGL *GetTexture(ResourceID id) { | 395 TextureGL *GetTexture(ResourceId id) { |
396 return textures_.Get(id); | 396 return textures_.Get(id); |
397 } | 397 } |
398 | 398 |
399 // Gets a sampler by resource ID. | 399 // Gets a sampler by resource ID. |
400 SamplerGL *GetSampler(ResourceID id) { | 400 SamplerGL *GetSampler(ResourceId id) { |
401 return samplers_.Get(id); | 401 return samplers_.Get(id); |
402 } | 402 } |
403 void set_anti_aliased(bool anti_aliased) { anti_aliased_ = anti_aliased; } | 403 void set_anti_aliased(bool anti_aliased) { anti_aliased_ = anti_aliased; } |
404 | 404 |
405 bool anti_aliased() const { return anti_aliased_; } | 405 bool anti_aliased() const { return anti_aliased_; } |
406 | 406 |
407 CGcontext cg_context() const { return cg_context_; } | 407 CGcontext cg_context() const { return cg_context_; } |
408 | 408 |
409 EffectGL *current_effect() const { return current_effect_; } | 409 EffectGL *current_effect() const { return current_effect_; } |
410 // "Dirty" the current effect. This resets the vertex and fragment program, | 410 // "Dirty" the current effect. This resets the vertex and fragment program, |
(...skipping 13 matching lines...) Expand all Loading... |
424 #elif defined(OS_WIN) | 424 #elif defined(OS_WIN) |
425 // Handle to the GL device. | 425 // Handle to the GL device. |
426 HWND hwnd_; | 426 HWND hwnd_; |
427 HDC device_context_; | 427 HDC device_context_; |
428 HGLRC gl_context_; | 428 HGLRC gl_context_; |
429 #endif | 429 #endif |
430 | 430 |
431 CGcontext cg_context_; | 431 CGcontext cg_context_; |
432 | 432 |
433 bool anti_aliased_; | 433 bool anti_aliased_; |
434 ResourceID current_vertex_struct_; | 434 ResourceId current_vertex_struct_; |
435 bool validate_streams_; | 435 bool validate_streams_; |
436 unsigned int max_vertices_; | 436 unsigned int max_vertices_; |
437 ResourceID current_effect_id_; | 437 ResourceId current_effect_id_; |
438 bool validate_effect_; | 438 bool validate_effect_; |
439 EffectGL *current_effect_; | 439 EffectGL *current_effect_; |
440 ResourceID current_surface_id_; | 440 ResourceId current_surface_id_; |
441 ResourceID current_depth_surface_id_; | 441 ResourceId current_depth_surface_id_; |
442 GLuint render_surface_framebuffer_; | 442 GLuint render_surface_framebuffer_; |
443 | 443 |
444 ResourceMap<VertexBufferGL> vertex_buffers_; | 444 ResourceMap<VertexBufferGL> vertex_buffers_; |
445 ResourceMap<IndexBufferGL> index_buffers_; | 445 ResourceMap<IndexBufferGL> index_buffers_; |
446 ResourceMap<VertexStructGL> vertex_structs_; | 446 ResourceMap<VertexStructGL> vertex_structs_; |
447 ResourceMap<EffectGL> effects_; | 447 ResourceMap<EffectGL> effects_; |
448 ResourceMap<EffectParamGL> effect_params_; | 448 ResourceMap<EffectParamGL> effect_params_; |
449 ResourceMap<TextureGL> textures_; | 449 ResourceMap<TextureGL> textures_; |
450 ResourceMap<SamplerGL> samplers_; | 450 ResourceMap<SamplerGL> samplers_; |
451 ResourceMap<RenderSurfaceGL> render_surfaces_; | 451 ResourceMap<RenderSurfaceGL> render_surfaces_; |
452 ResourceMap<RenderDepthStencilSurfaceGL> depth_surfaces_; | 452 ResourceMap<RenderDepthStencilSurfaceGL> depth_surfaces_; |
453 }; | 453 }; |
454 | 454 |
455 } // namespace command_buffer | 455 } // namespace command_buffer |
456 } // namespace o3d | 456 } // namespace o3d |
457 | 457 |
458 #endif // O3D_COMMAND_BUFFER_SERVICE_CROSS_GL_GAPI_GL_H_ | 458 #endif // O3D_COMMAND_BUFFER_SERVICE_CROSS_GL_GAPI_GL_H_ |
OLD | NEW |