1 // Copyright 2016 The SwiftShader Authors. All Rights Reserved.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 // libGL.cpp: Implements the exported OpenGL functions.
15
16 #include "main.h"
17 #include "mathutil.h"
18 #include "utilities.h"
19 #include "Buffer.h"
20 #include "Context.h"
21 #include "Fence.h"
22 #include "Framebuffer.h"
23 #include "Program.h"
24 #include "Renderbuffer.h"
25 #include "Shader.h"
26 #include "Texture.h"
27 #include "Query.h"
28 #include "common/debug.h"
29 #include "Common/Version.h"
30
31 #define _GDI32_
32 #include <windows.h>
33 #include <GL/GL.h>
34 #include <GL/glext.h>
35
36 #include <limits>
37
38 using std::abs;
39
validImageSize(GLint level,GLsizei width,GLsizei height)40 static bool validImageSize(GLint level, GLsizei width, GLsizei height)
41 {
42 if(level < 0 || level >= gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS || width < 0 || height < 0)
43 {
44 return false;
45 }
46
47 return true;
48 }
49
validateSubImageParams(bool compressed,GLsizei width,GLsizei height,GLint xoffset,GLint yoffset,GLenum target,GLint level,GLenum format,gl::Texture * texture)50 static bool validateSubImageParams(bool compressed, GLsizei width, GLsizei height, GLint xoffset, GLint yoffset, GLenum target, GLint level, GLenum format, gl::Texture *texture)
51 {
52 if(!texture)
53 {
54 return error(GL_INVALID_OPERATION, false);
55 }
56
57 if(compressed != texture->isCompressed(target, level))
58 {
59 return error(GL_INVALID_OPERATION, false);
60 }
61
62 if(format != GL_NONE && format != texture->getFormat(target, level))
63 {
64 return error(GL_INVALID_OPERATION, false);
65 }
66
67 if(compressed)
68 {
69 if((width % 4 != 0 && width != texture->getWidth(target, 0)) ||
70 (height % 4 != 0 && height != texture->getHeight(target, 0)))
71 {
72 return error(GL_INVALID_OPERATION, false);
73 }
74 }
75
76 if(xoffset + width > texture->getWidth(target, level) ||
77 yoffset + height > texture->getHeight(target, level))
78 {
79 return error(GL_INVALID_VALUE, false);
80 }
81
82 return true;
83 }
84
85 // Check for combinations of format and type that are valid for ReadPixels
validReadFormatType(GLenum format,GLenum type)86 static bool validReadFormatType(GLenum format, GLenum type)
87 {
88 switch(format)
89 {
90 case GL_RGBA:
91 switch(type)
92 {
93 case GL_UNSIGNED_BYTE:
94 break;
95 default:
96 return false;
97 }
98 break;
99 case GL_BGRA_EXT:
100 switch(type)
101 {
102 case GL_UNSIGNED_BYTE:
103 case GL_UNSIGNED_SHORT_4_4_4_4_REV:
104 case GL_UNSIGNED_SHORT_1_5_5_5_REV:
105 break;
106 default:
107 return false;
108 }
109 break;
110 case gl::IMPLEMENTATION_COLOR_READ_FORMAT:
111 switch(type)
112 {
113 case gl::IMPLEMENTATION_COLOR_READ_TYPE:
114 break;
115 default:
116 return false;
117 }
118 break;
119 default:
120 return false;
121 }
122
123 return true;
124 }
125
126 extern "C"
127 {
128
glActiveTexture(GLenum texture)129 void APIENTRY glActiveTexture(GLenum texture)
130 {
131 TRACE("(GLenum texture = 0x%X)", texture);
132
133 gl::Context *context = gl::getContext();
134
135 if(context)
136 {
137 if(context->getListIndex() != 0)
138 {
139 UNIMPLEMENTED();
140 }
141
142 if(texture < GL_TEXTURE0 || texture > GL_TEXTURE0 + gl::MAX_COMBINED_TEXTURE_IMAGE_UNITS - 1)
143 {
144 return error(GL_INVALID_ENUM);
145 }
146
147 context->setActiveSampler(texture - GL_TEXTURE0);
148 }
149 }
150
glAttachShader(GLuint program,GLuint shader)151 void APIENTRY glAttachShader(GLuint program, GLuint shader)
152 {
153 TRACE("(GLuint program = %d, GLuint shader = %d)", program, shader);
154
155 gl::Context *context = gl::getContext();
156
157 if(context)
158 {
159 gl::Program *programObject = context->getProgram(program);
160 gl::Shader *shaderObject = context->getShader(shader);
161
162 if(!programObject)
163 {
164 if(context->getShader(program))
165 {
166 return error(GL_INVALID_OPERATION);
167 }
168 else
169 {
170 return error(GL_INVALID_VALUE);
171 }
172 }
173
174 if(!shaderObject)
175 {
176 if(context->getProgram(shader))
177 {
178 return error(GL_INVALID_OPERATION);
179 }
180 else
181 {
182 return error(GL_INVALID_VALUE);
183 }
184 }
185
186 if(!programObject->attachShader(shaderObject))
187 {
188 return error(GL_INVALID_OPERATION);
189 }
190 }
191 }
192
glBeginQueryEXT(GLenum target,GLuint name)193 void APIENTRY glBeginQueryEXT(GLenum target, GLuint name)
194 {
195 TRACE("(GLenum target = 0x%X, GLuint name = %d)", target, name);
196
197 switch(target)
198 {
199 case GL_ANY_SAMPLES_PASSED:
200 case GL_ANY_SAMPLES_PASSED_CONSERVATIVE:
201 break;
202 default:
203 return error(GL_INVALID_ENUM);
204 }
205
206 if(name == 0)
207 {
208 return error(GL_INVALID_OPERATION);
209 }
210
211 gl::Context *context = gl::getContext();
212
213 if(context)
214 {
215 if(context->getListIndex() != 0)
216 {
217 UNIMPLEMENTED();
218 }
219
220 context->beginQuery(target, name);
221 }
222 }
223
glBindAttribLocation(GLuint program,GLuint index,const GLchar * name)224 void APIENTRY glBindAttribLocation(GLuint program, GLuint index, const GLchar* name)
225 {
226 TRACE("(GLuint program = %d, GLuint index = %d, const GLchar* name = %s)", program, index, name);
227
228 if(index >= gl::MAX_VERTEX_ATTRIBS)
229 {
230 return error(GL_INVALID_VALUE);
231 }
232
233 gl::Context *context = gl::getContext();
234
235 if(context)
236 {
237 gl::Program *programObject = context->getProgram(program);
238
239 if(!programObject)
240 {
241 if(context->getShader(program))
242 {
243 return error(GL_INVALID_OPERATION);
244 }
245 else
246 {
247 return error(GL_INVALID_VALUE);
248 }
249 }
250
251 if(strncmp(name, "gl_", 3) == 0)
252 {
253 return error(GL_INVALID_OPERATION);
254 }
255
256 programObject->bindAttributeLocation(index, name);
257 }
258 }
259
glBindBuffer(GLenum target,GLuint buffer)260 void APIENTRY glBindBuffer(GLenum target, GLuint buffer)
261 {
262 TRACE("(GLenum target = 0x%X, GLuint buffer = %d)", target, buffer);
263
264 gl::Context *context = gl::getContext();
265
266 if(context)
267 {
268 switch(target)
269 {
270 case GL_ARRAY_BUFFER:
271 context->bindArrayBuffer(buffer);
272 return;
273 case GL_ELEMENT_ARRAY_BUFFER:
274 context->bindElementArrayBuffer(buffer);
275 return;
276 default:
277 return error(GL_INVALID_ENUM);
278 }
279 }
280 }
281
glBindFramebuffer(GLenum target,GLuint framebuffer)282 void APIENTRY glBindFramebuffer(GLenum target, GLuint framebuffer)
283 {
284 TRACE("(GLenum target = 0x%X, GLuint framebuffer = %d)", target, framebuffer);
285
286 if(target != GL_FRAMEBUFFER && target != GL_DRAW_FRAMEBUFFER_EXT && target != GL_READ_FRAMEBUFFER_EXT)
287 {
288 return error(GL_INVALID_ENUM);
289 }
290
291 gl::Context *context = gl::getContext();
292
293 if(context)
294 {
295 if(context->getListIndex() != 0)
296 {
297 UNIMPLEMENTED();
298 }
299
300 if(target == GL_READ_FRAMEBUFFER_EXT || target == GL_FRAMEBUFFER)
301 {
302 context->bindReadFramebuffer(framebuffer);
303 }
304
305 if(target == GL_DRAW_FRAMEBUFFER_EXT || target == GL_FRAMEBUFFER)
306 {
307 context->bindDrawFramebuffer(framebuffer);
308 }
309 }
310 }
311
glBindRenderbuffer(GLenum target,GLuint renderbuffer)312 void APIENTRY glBindRenderbuffer(GLenum target, GLuint renderbuffer)
313 {
314 TRACE("(GLenum target = 0x%X, GLuint renderbuffer = %d)", target, renderbuffer);
315
316 if(target != GL_RENDERBUFFER)
317 {
318 return error(GL_INVALID_ENUM);
319 }
320
321 gl::Context *context = gl::getContext();
322
323 if(context)
324 {
325 if(context->getListIndex() != 0)
326 {
327 UNIMPLEMENTED();
328 }
329
330 context->bindRenderbuffer(renderbuffer);
331 }
332 }
333
glBindTexture(GLenum target,GLuint texture)334 void APIENTRY glBindTexture(GLenum target, GLuint texture)
335 {
336 TRACE("(GLenum target = 0x%X, GLuint texture = %d)", target, texture);
337
338 gl::Context *context = gl::getContext();
339
340 if(context)
341 {
342 if(context->getListIndex() != 0)
343 {
344 UNIMPLEMENTED();
345 }
346
347 gl::Texture *textureObject = context->getTexture(texture);
348
349 if(textureObject && textureObject->getTarget() != target && texture != 0)
350 {
351 return error(GL_INVALID_OPERATION);
352 }
353
354 switch(target)
355 {
356 case GL_TEXTURE_2D:
357 context->bindTexture2D(texture);
358 return;
359 case GL_TEXTURE_CUBE_MAP:
360 context->bindTextureCubeMap(texture);
361 return;
362 default:
363 return error(GL_INVALID_ENUM);
364 }
365 }
366 }
367
glBlendColor(GLclampf red,GLclampf green,GLclampf blue,GLclampf alpha)368 void APIENTRY glBlendColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha)
369 {
370 TRACE("(GLclampf red = %f, GLclampf green = %f, GLclampf blue = %f, GLclampf alpha = %f)",
371 red, green, blue, alpha);
372
373 gl::Context* context = gl::getContext();
374
375 if(context)
376 {
377 if(context->getListIndex() != 0)
378 {
379 UNIMPLEMENTED();
380 }
381
382 context->setBlendColor(gl::clamp01(red), gl::clamp01(green), gl::clamp01(blue), gl::clamp01(alpha));
383 }
384 }
385
glBlendEquation(GLenum mode)386 void APIENTRY glBlendEquation(GLenum mode)
387 {
388 glBlendEquationSeparate(mode, mode);
389 }
390
glBlendEquationSeparate(GLenum modeRGB,GLenum modeAlpha)391 void APIENTRY glBlendEquationSeparate(GLenum modeRGB, GLenum modeAlpha)
392 {
393 TRACE("(GLenum modeRGB = 0x%X, GLenum modeAlpha = 0x%X)", modeRGB, modeAlpha);
394
395 switch(modeRGB)
396 {
397 case GL_FUNC_ADD:
398 case GL_FUNC_SUBTRACT:
399 case GL_FUNC_REVERSE_SUBTRACT:
400 case GL_MIN_EXT:
401 case GL_MAX_EXT:
402 break;
403 default:
404 return error(GL_INVALID_ENUM);
405 }
406
407 switch(modeAlpha)
408 {
409 case GL_FUNC_ADD:
410 case GL_FUNC_SUBTRACT:
411 case GL_FUNC_REVERSE_SUBTRACT:
412 case GL_MIN_EXT:
413 case GL_MAX_EXT:
414 break;
415 default:
416 return error(GL_INVALID_ENUM);
417 }
418
419 gl::Context *context = gl::getContext();
420
421 if(context)
422 {
423 if(context->getListIndex() != 0)
424 {
425 UNIMPLEMENTED();
426 }
427
428 context->setBlendEquation(modeRGB, modeAlpha);
429 }
430 }
431
glBlendFunc(GLenum sfactor,GLenum dfactor)432 void APIENTRY glBlendFunc(GLenum sfactor, GLenum dfactor)
433 {
434 glBlendFuncSeparate(sfactor, dfactor, sfactor, dfactor);
435 }
436
glBlendFuncSeparate(GLenum srcRGB,GLenum dstRGB,GLenum srcAlpha,GLenum dstAlpha)437 void APIENTRY glBlendFuncSeparate(GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha)
438 {
439 TRACE("(GLenum srcRGB = 0x%X, GLenum dstRGB = 0x%X, GLenum srcAlpha = 0x%X, GLenum dstAlpha = 0x%X)",
440 srcRGB, dstRGB, srcAlpha, dstAlpha);
441
442 switch(srcRGB)
443 {
444 case GL_ZERO:
445 case GL_ONE:
446 case GL_SRC_COLOR:
447 case GL_ONE_MINUS_SRC_COLOR:
448 case GL_DST_COLOR:
449 case GL_ONE_MINUS_DST_COLOR:
450 case GL_SRC_ALPHA:
451 case GL_ONE_MINUS_SRC_ALPHA:
452 case GL_DST_ALPHA:
453 case GL_ONE_MINUS_DST_ALPHA:
454 case GL_CONSTANT_COLOR:
455 case GL_ONE_MINUS_CONSTANT_COLOR:
456 case GL_CONSTANT_ALPHA:
457 case GL_ONE_MINUS_CONSTANT_ALPHA:
458 case GL_SRC_ALPHA_SATURATE:
459 break;
460 default:
461 return error(GL_INVALID_ENUM);
462 }
463
464 switch(dstRGB)
465 {
466 case GL_ZERO:
467 case GL_ONE:
468 case GL_SRC_COLOR:
469 case GL_ONE_MINUS_SRC_COLOR:
470 case GL_DST_COLOR:
471 case GL_ONE_MINUS_DST_COLOR:
472 case GL_SRC_ALPHA:
473 case GL_ONE_MINUS_SRC_ALPHA:
474 case GL_DST_ALPHA:
475 case GL_ONE_MINUS_DST_ALPHA:
476 case GL_CONSTANT_COLOR:
477 case GL_ONE_MINUS_CONSTANT_COLOR:
478 case GL_CONSTANT_ALPHA:
479 case GL_ONE_MINUS_CONSTANT_ALPHA:
480 break;
481 default:
482 return error(GL_INVALID_ENUM);
483 }
484
485 switch(srcAlpha)
486 {
487 case GL_ZERO:
488 case GL_ONE:
489 case GL_SRC_COLOR:
490 case GL_ONE_MINUS_SRC_COLOR:
491 case GL_DST_COLOR:
492 case GL_ONE_MINUS_DST_COLOR:
493 case GL_SRC_ALPHA:
494 case GL_ONE_MINUS_SRC_ALPHA:
495 case GL_DST_ALPHA:
496 case GL_ONE_MINUS_DST_ALPHA:
497 case GL_CONSTANT_COLOR:
498 case GL_ONE_MINUS_CONSTANT_COLOR:
499 case GL_CONSTANT_ALPHA:
500 case GL_ONE_MINUS_CONSTANT_ALPHA:
501 case GL_SRC_ALPHA_SATURATE:
502 break;
503 default:
504 return error(GL_INVALID_ENUM);
505 }
506
507 switch(dstAlpha)
508 {
509 case GL_ZERO:
510 case GL_ONE:
511 case GL_SRC_COLOR:
512 case GL_ONE_MINUS_SRC_COLOR:
513 case GL_DST_COLOR:
514 case GL_ONE_MINUS_DST_COLOR:
515 case GL_SRC_ALPHA:
516 case GL_ONE_MINUS_SRC_ALPHA:
517 case GL_DST_ALPHA:
518 case GL_ONE_MINUS_DST_ALPHA:
519 case GL_CONSTANT_COLOR:
520 case GL_ONE_MINUS_CONSTANT_COLOR:
521 case GL_CONSTANT_ALPHA:
522 case GL_ONE_MINUS_CONSTANT_ALPHA:
523 break;
524 default:
525 return error(GL_INVALID_ENUM);
526 }
527
528 gl::Context *context = gl::getContext();
529
530 if(context)
531 {
532 if(context->getListIndex() != 0)
533 {
534 UNIMPLEMENTED();
535 }
536
537 context->setBlendFactors(srcRGB, dstRGB, srcAlpha, dstAlpha);
538 }
539 }
540
glBufferData(GLenum target,GLsizeiptr size,const GLvoid * data,GLenum usage)541 void APIENTRY glBufferData(GLenum target, GLsizeiptr size, const GLvoid* data, GLenum usage)
542 {
543 TRACE("(GLenum target = 0x%X, GLsizeiptr size = %d, const GLvoid* data = %p, GLenum usage = %d)",
544 target, size, data, usage);
545
546 if(size < 0)
547 {
548 return error(GL_INVALID_VALUE);
549 }
550
551 switch(usage)
552 {
553 case GL_STREAM_DRAW:
554 case GL_STATIC_DRAW:
555 case GL_DYNAMIC_DRAW:
556 break;
557 default:
558 return error(GL_INVALID_ENUM);
559 }
560
561 gl::Context *context = gl::getContext();
562
563 if(context)
564 {
565 gl::Buffer *buffer;
566
567 switch(target)
568 {
569 case GL_ARRAY_BUFFER:
570 buffer = context->getArrayBuffer();
571 break;
572 case GL_ELEMENT_ARRAY_BUFFER:
573 buffer = context->getElementArrayBuffer();
574 break;
575 default:
576 return error(GL_INVALID_ENUM);
577 }
578
579 if(!buffer)
580 {
581 return error(GL_INVALID_OPERATION);
582 }
583
584 buffer->bufferData(data, size, usage);
585 }
586 }
587
glBufferSubData(GLenum target,GLintptr offset,GLsizeiptr size,const GLvoid * data)588 void APIENTRY glBufferSubData(GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid* data)
589 {
590 TRACE("(GLenum target = 0x%X, GLintptr offset = %d, GLsizeiptr size = %d, const GLvoid* data = %p)",
591 target, offset, size, data);
592
593 if(size < 0 || offset < 0)
594 {
595 return error(GL_INVALID_VALUE);
596 }
597
598 if(!data)
599 {
600 return;
601 }
602
603 gl::Context *context = gl::getContext();
604
605 if(context)
606 {
607 gl::Buffer *buffer;
608
609 switch(target)
610 {
611 case GL_ARRAY_BUFFER:
612 buffer = context->getArrayBuffer();
613 break;
614 case GL_ELEMENT_ARRAY_BUFFER:
615 buffer = context->getElementArrayBuffer();
616 break;
617 default:
618 return error(GL_INVALID_ENUM);
619 }
620
621 if(!buffer)
622 {
623 return error(GL_INVALID_OPERATION);
624 }
625
626 if((size_t)size + offset > buffer->size())
627 {
628 return error(GL_INVALID_VALUE);
629 }
630
631 buffer->bufferSubData(data, size, offset);
632 }
633 }
634
glCheckFramebufferStatus(GLenum target)635 GLenum APIENTRY glCheckFramebufferStatus(GLenum target)
636 {
637 TRACE("(GLenum target = 0x%X)", target);
638
639 if(target != GL_FRAMEBUFFER && target != GL_DRAW_FRAMEBUFFER_EXT && target != GL_READ_FRAMEBUFFER_EXT)
640 {
641 return error(GL_INVALID_ENUM, 0);
642 }
643
644 gl::Context *context = gl::getContext();
645
646 if(context)
647 {
648 if(context->getListIndex() != 0)
649 {
650 UNIMPLEMENTED();
651 }
652
653 gl::Framebuffer *framebuffer = nullptr;
654 if(target == GL_READ_FRAMEBUFFER_EXT)
655 {
656 framebuffer = context->getReadFramebuffer();
657 }
658 else
659 {
660 framebuffer = context->getDrawFramebuffer();
661 }
662
663 return framebuffer->completeness();
664 }
665
666 return 0;
667 }
668
glClear(GLbitfield mask)669 void APIENTRY glClear(GLbitfield mask)
670 {
671 TRACE("(GLbitfield mask = %X)", mask);
672
673 if((mask & ~(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT)) != 0)
674 {
675 return error(GL_INVALID_VALUE);
676 }
677
678 gl::Context *context = gl::getContext();
679
680 if(context)
681 {
682 if(context->getListIndex() != 0)
683 {
684 return context->listCommand(gl::newCommand(glClear, mask));
685 }
686
687 context->clear(mask);
688 }
689 }
690
glClearColor(GLclampf red,GLclampf green,GLclampf blue,GLclampf alpha)691 void APIENTRY glClearColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha)
692 {
693 TRACE("(GLclampf red = %f, GLclampf green = %f, GLclampf blue = %f, GLclampf alpha = %f)",
694 red, green, blue, alpha);
695
696 gl::Context *context = gl::getContext();
697
698 if(context)
699 {
700 if(context->getListIndex() != 0)
701 {
702 UNIMPLEMENTED();
703 }
704
705 context->setClearColor(red, green, blue, alpha);
706 }
707 }
708
glClearDepthf(GLclampf depth)709 void APIENTRY glClearDepthf(GLclampf depth)
710 {
711 TRACE("(GLclampf depth = %f)", depth);
712
713 gl::Context *context = gl::getContext();
714
715 if(context)
716 {
717 if(context->getListIndex() != 0)
718 {
719 UNIMPLEMENTED();
720 }
721
722 context->setClearDepth(depth);
723 }
724 }
725
glClearStencil(GLint s)726 void APIENTRY glClearStencil(GLint s)
727 {
728 TRACE("(GLint s = %d)", s);
729
730 gl::Context *context = gl::getContext();
731
732 if(context)
733 {
734 if(context->getListIndex() != 0)
735 {
736 UNIMPLEMENTED();
737 }
738
739 context->setClearStencil(s);
740 }
741 }
742
glColorMask(GLboolean red,GLboolean green,GLboolean blue,GLboolean alpha)743 void APIENTRY glColorMask(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha)
744 {
745 TRACE("(GLboolean red = %d, GLboolean green = %d, GLboolean blue = %d, GLboolean alpha = %d)",
746 red, green, blue, alpha);
747
748 gl::Context *context = gl::getContext();
749
750 if(context)
751 {
752 if(context->getListIndex() != 0)
753 {
754 UNIMPLEMENTED();
755 }
756
757 context->setColorMask(red == GL_TRUE, green == GL_TRUE, blue == GL_TRUE, alpha == GL_TRUE);
758 }
759 }
760
glCompileShader(GLuint shader)761 void APIENTRY glCompileShader(GLuint shader)
762 {
763 TRACE("(GLuint shader = %d)", shader);
764
765 gl::Context *context = gl::getContext();
766
767 if(context)
768 {
769 gl::Shader *shaderObject = context->getShader(shader);
770
771 if(!shaderObject)
772 {
773 if(context->getProgram(shader))
774 {
775 return error(GL_INVALID_OPERATION);
776 }
777 else
778 {
779 return error(GL_INVALID_VALUE);
780 }
781 }
782
783 shaderObject->compile();
784 }
785 }
786
glCompressedTexImage2D(GLenum target,GLint level,GLenum internalformat,GLsizei width,GLsizei height,GLint border,GLsizei imageSize,const GLvoid * data)787 void APIENTRY glCompressedTexImage2D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height,
788 GLint border, GLsizei imageSize, const GLvoid* data)
789 {
790 TRACE("(GLenum target = 0x%X, GLint level = %d, GLenum internalformat = 0x%X, GLsizei width = %d, "
791 "GLsizei height = %d, GLint border = %d, GLsizei imageSize = %d, const GLvoid* data = %p)",
792 target, level, internalformat, width, height, border, imageSize, data);
793
794 if(!validImageSize(level, width, height) || border != 0 || imageSize < 0)
795 {
796 return error(GL_INVALID_VALUE);
797 }
798
799 switch(internalformat)
800 {
801 case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
802 case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
803 case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT:
804 case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT:
805 if(!S3TC_SUPPORT)
806 {
807 return error(GL_INVALID_ENUM);
808 }
809 break;
810 case GL_DEPTH_COMPONENT:
811 case GL_DEPTH_COMPONENT16:
812 case GL_DEPTH_COMPONENT32:
813 case GL_DEPTH_STENCIL_EXT:
814 case GL_DEPTH24_STENCIL8_EXT:
815 return error(GL_INVALID_OPERATION);
816 default:
817 return error(GL_INVALID_ENUM);
818 }
819
820 if(border != 0)
821 {
822 return error(GL_INVALID_VALUE);
823 }
824
825 gl::Context *context = gl::getContext();
826
827 if(context)
828 {
829 if(context->getListIndex() != 0)
830 {
831 UNIMPLEMENTED();
832 }
833
834 if(level > gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS)
835 {
836 return error(GL_INVALID_VALUE);
837 }
838
839 switch(target)
840 {
841 case GL_TEXTURE_2D:
842 if(width > (gl::IMPLEMENTATION_MAX_TEXTURE_SIZE >> level) ||
843 height > (gl::IMPLEMENTATION_MAX_TEXTURE_SIZE >> level))
844 {
845 return error(GL_INVALID_VALUE);
846 }
847 break;
848 case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
849 case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
850 case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
851 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
852 case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
853 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
854 if(width != height)
855 {
856 return error(GL_INVALID_VALUE);
857 }
858
859 if(width > (gl::IMPLEMENTATION_MAX_CUBE_MAP_TEXTURE_SIZE >> level) ||
860 height > (gl::IMPLEMENTATION_MAX_CUBE_MAP_TEXTURE_SIZE >> level))
861 {
862 return error(GL_INVALID_VALUE);
863 }
864 break;
865 default:
866 return error(GL_INVALID_ENUM);
867 }
868
869 if(imageSize != gl::ComputeCompressedSize(width, height, internalformat))
870 {
871 return error(GL_INVALID_VALUE);
872 }
873
874 if(target == GL_TEXTURE_2D)
875 {
876 gl::Texture2D *texture = context->getTexture2D(target);
877
878 if(!texture)
879 {
880 return error(GL_INVALID_OPERATION);
881 }
882
883 texture->setCompressedImage(level, internalformat, width, height, imageSize, data);
884 }
885 else
886 {
887 gl::TextureCubeMap *texture = context->getTextureCubeMap();
888
889 if(!texture)
890 {
891 return error(GL_INVALID_OPERATION);
892 }
893
894 switch(target)
895 {
896 case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
897 case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
898 case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
899 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
900 case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
901 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
902 texture->setCompressedImage(target, level, internalformat, width, height, imageSize, data);
903 break;
904 default: UNREACHABLE(target);
905 }
906 }
907 }
908 }
909
glCompressedTexSubImage2D(GLenum target,GLint level,GLint xoffset,GLint yoffset,GLsizei width,GLsizei height,GLenum format,GLsizei imageSize,const GLvoid * data)910 void APIENTRY glCompressedTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height,
911 GLenum format, GLsizei imageSize, const GLvoid* data)
912 {
913 TRACE("(GLenum target = 0x%X, GLint level = %d, GLint xoffset = %d, GLint yoffset = %d, "
914 "GLsizei width = %d, GLsizei height = %d, GLenum format = 0x%X, "
915 "GLsizei imageSize = %d, const GLvoid* data = %p)",
916 target, level, xoffset, yoffset, width, height, format, imageSize, data);
917
918 if(!gl::IsTextureTarget(target))
919 {
920 return error(GL_INVALID_ENUM);
921 }
922
923 if(xoffset < 0 || yoffset < 0 || !validImageSize(level, width, height) || imageSize < 0)
924 {
925 return error(GL_INVALID_VALUE);
926 }
927
928 switch(format)
929 {
930 case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
931 case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
932 case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT:
933 case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT:
934 if(!S3TC_SUPPORT)
935 {
936 return error(GL_INVALID_ENUM);
937 }
938 break;
939 default:
940 return error(GL_INVALID_ENUM);
941 }
942
943 if(width == 0 || height == 0 || !data)
944 {
945 return;
946 }
947
948 gl::Context *context = gl::getContext();
949
950 if(context)
951 {
952 if(context->getListIndex() != 0)
953 {
954 UNIMPLEMENTED();
955 }
956
957 if(level > gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS)
958 {
959 return error(GL_INVALID_VALUE);
960 }
961
962 if(imageSize != gl::ComputeCompressedSize(width, height, format))
963 {
964 return error(GL_INVALID_VALUE);
965 }
966
967 if(xoffset % 4 != 0 || yoffset % 4 != 0)
968 {
969 // We wait to check the offsets until this point, because the multiple-of-four restriction does not exist unless DXT1 textures are supported
970 return error(GL_INVALID_OPERATION);
971 }
972
973 if(target == GL_TEXTURE_2D)
974 {
975 gl::Texture2D *texture = context->getTexture2D(target);
976
977 if(validateSubImageParams(true, width, height, xoffset, yoffset, target, level, format, texture))
978 {
979 texture->subImageCompressed(level, xoffset, yoffset, width, height, format, imageSize, data);
980 }
981 }
982 else if(gl::IsCubemapTextureTarget(target))
983 {
984 gl::TextureCubeMap *texture = context->getTextureCubeMap();
985
986 if(validateSubImageParams(true, width, height, xoffset, yoffset, target, level, format, texture))
987 {
988 texture->subImageCompressed(target, level, xoffset, yoffset, width, height, format, imageSize, data);
989 }
990 }
991 else UNREACHABLE(target);
992 }
993 }
994
glCopyTexImage2D(GLenum target,GLint level,GLenum internalformat,GLint x,GLint y,GLsizei width,GLsizei height,GLint border)995 void APIENTRY glCopyTexImage2D(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border)
996 {
997 TRACE("(GLenum target = 0x%X, GLint level = %d, GLenum internalformat = 0x%X, "
998 "GLint x = %d, GLint y = %d, GLsizei width = %d, GLsizei height = %d, GLint border = %d)",
999 target, level, internalformat, x, y, width, height, border);
1000
1001 if(!validImageSize(level, width, height))
1002 {
1003 return error(GL_INVALID_VALUE);
1004 }
1005
1006 if(border != 0)
1007 {
1008 return error(GL_INVALID_VALUE);
1009 }
1010
1011 gl::Context *context = gl::getContext();
1012
1013 if(context)
1014 {
1015 if(context->getListIndex() != 0)
1016 {
1017 UNIMPLEMENTED();
1018 }
1019
1020 switch(target)
1021 {
1022 case GL_TEXTURE_2D:
1023 if(width > (gl::IMPLEMENTATION_MAX_TEXTURE_SIZE >> level) ||
1024 height > (gl::IMPLEMENTATION_MAX_TEXTURE_SIZE >> level))
1025 {
1026 return error(GL_INVALID_VALUE);
1027 }
1028 break;
1029 case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
1030 case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
1031 case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
1032 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
1033 case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
1034 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
1035 if(width != height)
1036 {
1037 return error(GL_INVALID_VALUE);
1038 }
1039
1040 if(width > (gl::IMPLEMENTATION_MAX_CUBE_MAP_TEXTURE_SIZE >> level) ||
1041 height > (gl::IMPLEMENTATION_MAX_CUBE_MAP_TEXTURE_SIZE >> level))
1042 {
1043 return error(GL_INVALID_VALUE);
1044 }
1045 break;
1046 default:
1047 return error(GL_INVALID_ENUM);
1048 }
1049
1050 gl::Framebuffer *framebuffer = context->getReadFramebuffer();
1051
1052 if(framebuffer->completeness() != GL_FRAMEBUFFER_COMPLETE)
1053 {
1054 return error(GL_INVALID_FRAMEBUFFER_OPERATION);
1055 }
1056
1057 if(context->getReadFramebufferName() != 0 && framebuffer->getColorbuffer()->getSamples() > 1)
1058 {
1059 return error(GL_INVALID_OPERATION);
1060 }
1061
1062 gl::Renderbuffer *source = framebuffer->getColorbuffer();
1063 GLenum colorbufferFormat = source->getFormat();
1064
1065 switch(internalformat)
1066 {
1067 case GL_ALPHA:
1068 if(colorbufferFormat != GL_ALPHA &&
1069 colorbufferFormat != GL_RGBA &&
1070 colorbufferFormat != GL_RGBA4 &&
1071 colorbufferFormat != GL_RGB5_A1 &&
1072 colorbufferFormat != GL_RGBA8_EXT)
1073 {
1074 return error(GL_INVALID_OPERATION);
1075 }
1076 break;
1077 case GL_LUMINANCE:
1078 case GL_RGB:
1079 if(colorbufferFormat != GL_RGB &&
1080 colorbufferFormat != GL_RGB565 &&
1081 colorbufferFormat != GL_RGB8_EXT &&
1082 colorbufferFormat != GL_RGBA &&
1083 colorbufferFormat != GL_RGBA4 &&
1084 colorbufferFormat != GL_RGB5_A1 &&
1085 colorbufferFormat != GL_RGBA8_EXT)
1086 {
1087 return error(GL_INVALID_OPERATION);
1088 }
1089 break;
1090 case GL_LUMINANCE_ALPHA:
1091 case GL_RGBA:
1092 if(colorbufferFormat != GL_RGBA &&
1093 colorbufferFormat != GL_RGBA4 &&
1094 colorbufferFormat != GL_RGB5_A1 &&
1095 colorbufferFormat != GL_RGBA8_EXT)
1096 {
1097 return error(GL_INVALID_OPERATION);
1098 }
1099 break;
1100 case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
1101 case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
1102 case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT:
1103 case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT:
1104 if(S3TC_SUPPORT)
1105 {
1106 return error(GL_INVALID_OPERATION);
1107 }
1108 else
1109 {
1110 return error(GL_INVALID_ENUM);
1111 }
1112 default:
1113 return error(GL_INVALID_ENUM);
1114 }
1115
1116 if(target == GL_TEXTURE_2D)
1117 {
1118 gl::Texture2D *texture = context->getTexture2D(target);
1119
1120 if(!texture)
1121 {
1122 return error(GL_INVALID_OPERATION);
1123 }
1124
1125 texture->copyImage(level, internalformat, x, y, width, height, framebuffer);
1126 }
1127 else if(gl::IsCubemapTextureTarget(target))
1128 {
1129 gl::TextureCubeMap *texture = context->getTextureCubeMap();
1130
1131 if(!texture)
1132 {
1133 return error(GL_INVALID_OPERATION);
1134 }
1135
1136 texture->copyImage(target, level, internalformat, x, y, width, height, framebuffer);
1137 }
1138 else UNREACHABLE(target);
1139 }
1140 }
1141
glCopyTexSubImage2D(GLenum target,GLint level,GLint xoffset,GLint yoffset,GLint x,GLint y,GLsizei width,GLsizei height)1142 void APIENTRY glCopyTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height)
1143 {
1144 TRACE("(GLenum target = 0x%X, GLint level = %d, GLint xoffset = %d, GLint yoffset = %d, "
1145 "GLint x = %d, GLint y = %d, GLsizei width = %d, GLsizei height = %d)",
1146 target, level, xoffset, yoffset, x, y, width, height);
1147
1148 if(!gl::IsTextureTarget(target))
1149 {
1150 return error(GL_INVALID_ENUM);
1151 }
1152
1153 if(level < 0 || xoffset < 0 || yoffset < 0 || width < 0 || height < 0)
1154 {
1155 return error(GL_INVALID_VALUE);
1156 }
1157
1158 if(std::numeric_limits<GLsizei>::max() - xoffset < width || std::numeric_limits<GLsizei>::max() - yoffset < height)
1159 {
1160 return error(GL_INVALID_VALUE);
1161 }
1162
1163 if(width == 0 || height == 0)
1164 {
1165 return;
1166 }
1167
1168 gl::Context *context = gl::getContext();
1169
1170 if(context)
1171 {
1172 if(context->getListIndex() != 0)
1173 {
1174 UNIMPLEMENTED();
1175 }
1176
1177 if(level > gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS)
1178 {
1179 return error(GL_INVALID_VALUE);
1180 }
1181
1182 gl::Framebuffer *framebuffer = context->getReadFramebuffer();
1183
1184 if(framebuffer->completeness() != GL_FRAMEBUFFER_COMPLETE)
1185 {
1186 return error(GL_INVALID_FRAMEBUFFER_OPERATION);
1187 }
1188
1189 if(context->getReadFramebufferName() != 0 && framebuffer->getColorbuffer()->getSamples() > 1)
1190 {
1191 return error(GL_INVALID_OPERATION);
1192 }
1193
1194 gl::Texture *texture = nullptr;
1195
1196 if(target == GL_TEXTURE_2D)
1197 {
1198 texture = context->getTexture2D(target);
1199 }
1200 else if(gl::IsCubemapTextureTarget(target))
1201 {
1202 texture = context->getTextureCubeMap();
1203 }
1204 else UNREACHABLE(target);
1205
1206 if(!validateSubImageParams(false, width, height, xoffset, yoffset, target, level, GL_NONE, texture))
1207 {
1208 return;
1209 }
1210
1211 texture->copySubImage(target, level, xoffset, yoffset, x, y, width, height, framebuffer);
1212 }
1213 }
1214
glCreateProgram(void)1215 GLuint APIENTRY glCreateProgram(void)
1216 {
1217 TRACE("()");
1218
1219 gl::Context *context = gl::getContext();
1220
1221 if(context)
1222 {
1223 return context->createProgram();
1224 }
1225
1226 return 0;
1227 }
1228
glCreateShader(GLenum type)1229 GLuint APIENTRY glCreateShader(GLenum type)
1230 {
1231 TRACE("(GLenum type = 0x%X)", type);
1232
1233 gl::Context *context = gl::getContext();
1234
1235 if(context)
1236 {
1237 switch(type)
1238 {
1239 case GL_FRAGMENT_SHADER:
1240 case GL_VERTEX_SHADER:
1241 return context->createShader(type);
1242 default:
1243 return error(GL_INVALID_ENUM, 0);
1244 }
1245 }
1246
1247 return 0;
1248 }
1249
glCullFace(GLenum mode)1250 void APIENTRY glCullFace(GLenum mode)
1251 {
1252 TRACE("(GLenum mode = 0x%X)", mode);
1253
1254 switch(mode)
1255 {
1256 case GL_FRONT:
1257 case GL_BACK:
1258 case GL_FRONT_AND_BACK:
1259 {
1260 gl::Context *context = gl::getContext();
1261
1262 if(context)
1263 {
1264 context->setCullMode(mode);
1265 }
1266 }
1267 break;
1268 default:
1269 return error(GL_INVALID_ENUM);
1270 }
1271 }
1272
glDeleteBuffers(GLsizei n,const GLuint * buffers)1273 void APIENTRY glDeleteBuffers(GLsizei n, const GLuint* buffers)
1274 {
1275 TRACE("(GLsizei n = %d, const GLuint* buffers = %p)", n, buffers);
1276
1277 if(n < 0)
1278 {
1279 return error(GL_INVALID_VALUE);
1280 }
1281
1282 gl::Context *context = gl::getContext();
1283
1284 if(context)
1285 {
1286 for(int i = 0; i < n; i++)
1287 {
1288 context->deleteBuffer(buffers[i]);
1289 }
1290 }
1291 }
1292
glDeleteFencesNV(GLsizei n,const GLuint * fences)1293 void APIENTRY glDeleteFencesNV(GLsizei n, const GLuint* fences)
1294 {
1295 TRACE("(GLsizei n = %d, const GLuint* fences = %p)", n, fences);
1296
1297 if(n < 0)
1298 {
1299 return error(GL_INVALID_VALUE);
1300 }
1301
1302 gl::Context *context = gl::getContext();
1303
1304 if(context)
1305 {
1306 if(context->getListIndex() != 0)
1307 {
1308 UNIMPLEMENTED();
1309 }
1310
1311 for(int i = 0; i < n; i++)
1312 {
1313 context->deleteFence(fences[i]);
1314 }
1315 }
1316 }
1317
glDeleteFramebuffers(GLsizei n,const GLuint * framebuffers)1318 void APIENTRY glDeleteFramebuffers(GLsizei n, const GLuint* framebuffers)
1319 {
1320 TRACE("(GLsizei n = %d, const GLuint* framebuffers = %p)", n, framebuffers);
1321
1322 if(n < 0)
1323 {
1324 return error(GL_INVALID_VALUE);
1325 }
1326
1327 gl::Context *context = gl::getContext();
1328
1329 if(context)
1330 {
1331 if(context->getListIndex() != 0)
1332 {
1333 UNIMPLEMENTED();
1334 }
1335
1336 for(int i = 0; i < n; i++)
1337 {
1338 if(framebuffers[i] != 0)
1339 {
1340 context->deleteFramebuffer(framebuffers[i]);
1341 }
1342 }
1343 }
1344 }
1345
glDeleteProgram(GLuint program)1346 void APIENTRY glDeleteProgram(GLuint program)
1347 {
1348 TRACE("(GLuint program = %d)", program);
1349
1350 if(program == 0)
1351 {
1352 return;
1353 }
1354
1355 gl::Context *context = gl::getContext();
1356
1357 if(context)
1358 {
1359 if(!context->getProgram(program))
1360 {
1361 if(context->getShader(program))
1362 {
1363 return error(GL_INVALID_OPERATION);
1364 }
1365 else
1366 {
1367 return error(GL_INVALID_VALUE);
1368 }
1369 }
1370
1371 context->deleteProgram(program);
1372 }
1373 }
1374
glDeleteQueriesEXT(GLsizei n,const GLuint * ids)1375 void APIENTRY glDeleteQueriesEXT(GLsizei n, const GLuint *ids)
1376 {
1377 TRACE("(GLsizei n = %d, const GLuint *ids = %p)", n, ids);
1378
1379 if(n < 0)
1380 {
1381 return error(GL_INVALID_VALUE);
1382 }
1383
1384 gl::Context *context = gl::getContext();
1385
1386 if(context)
1387 {
1388 for(int i = 0; i < n; i++)
1389 {
1390 context->deleteQuery(ids[i]);
1391 }
1392 }
1393 }
1394
glDeleteRenderbuffers(GLsizei n,const GLuint * renderbuffers)1395 void APIENTRY glDeleteRenderbuffers(GLsizei n, const GLuint* renderbuffers)
1396 {
1397 TRACE("(GLsizei n = %d, const GLuint* renderbuffers = %p)", n, renderbuffers);
1398
1399 if(n < 0)
1400 {
1401 return error(GL_INVALID_VALUE);
1402 }
1403
1404 gl::Context *context = gl::getContext();
1405
1406 if(context)
1407 {
1408 if(context->getListIndex() != 0)
1409 {
1410 UNIMPLEMENTED();
1411 }
1412
1413 for(int i = 0; i < n; i++)
1414 {
1415 context->deleteRenderbuffer(renderbuffers[i]);
1416 }
1417 }
1418 }
1419
glDeleteShader(GLuint shader)1420 void APIENTRY glDeleteShader(GLuint shader)
1421 {
1422 TRACE("(GLuint shader = %d)", shader);
1423
1424 if(shader == 0)
1425 {
1426 return;
1427 }
1428
1429 gl::Context *context = gl::getContext();
1430
1431 if(context)
1432 {
1433 if(!context->getShader(shader))
1434 {
1435 if(context->getProgram(shader))
1436 {
1437 return error(GL_INVALID_OPERATION);
1438 }
1439 else
1440 {
1441 return error(GL_INVALID_VALUE);
1442 }
1443 }
1444
1445 context->deleteShader(shader);
1446 }
1447 }
1448
glDeleteTextures(GLsizei n,const GLuint * textures)1449 void APIENTRY glDeleteTextures(GLsizei n, const GLuint* textures)
1450 {
1451 TRACE("(GLsizei n = %d, const GLuint* textures = %p)", n, textures);
1452
1453 if(n < 0)
1454 {
1455 return error(GL_INVALID_VALUE);
1456 }
1457
1458 gl::Context *context = gl::getContext();
1459
1460 if(context)
1461 {
1462 for(int i = 0; i < n; i++)
1463 {
1464 if(textures[i] != 0)
1465 {
1466 context->deleteTexture(textures[i]);
1467 }
1468 }
1469 }
1470 }
1471
glDepthFunc(GLenum func)1472 void APIENTRY glDepthFunc(GLenum func)
1473 {
1474 TRACE("(GLenum func = 0x%X)", func);
1475
1476 switch(func)
1477 {
1478 case GL_NEVER:
1479 case GL_ALWAYS:
1480 case GL_LESS:
1481 case GL_LEQUAL:
1482 case GL_EQUAL:
1483 case GL_GREATER:
1484 case GL_GEQUAL:
1485 case GL_NOTEQUAL:
1486 break;
1487 default:
1488 return error(GL_INVALID_ENUM);
1489 }
1490
1491 gl::Context *context = gl::getContext();
1492
1493 if(context)
1494 {
1495 if(context->getListIndex() != 0)
1496 {
1497 UNIMPLEMENTED();
1498 }
1499
1500 context->setDepthFunc(func);
1501 }
1502 }
1503
glDepthMask(GLboolean flag)1504 void APIENTRY glDepthMask(GLboolean flag)
1505 {
1506 TRACE("(GLboolean flag = %d)", flag);
1507
1508 gl::Context *context = gl::getContext();
1509
1510 if(context)
1511 {
1512 if(context->getListIndex() != 0)
1513 {
1514 UNIMPLEMENTED();
1515 }
1516
1517 context->setDepthMask(flag != GL_FALSE);
1518 }
1519 }
1520
glDepthRangef(GLclampf zNear,GLclampf zFar)1521 void APIENTRY glDepthRangef(GLclampf zNear, GLclampf zFar)
1522 {
1523 TRACE("(GLclampf zNear = %f, GLclampf zFar = %f)", zNear, zFar);
1524
1525 gl::Context *context = gl::getContext();
1526
1527 if(context)
1528 {
1529 if(context->getListIndex() != 0)
1530 {
1531 UNIMPLEMENTED();
1532 }
1533
1534 context->setDepthRange(zNear, zFar);
1535 }
1536 }
1537
glDetachShader(GLuint program,GLuint shader)1538 void APIENTRY glDetachShader(GLuint program, GLuint shader)
1539 {
1540 TRACE("(GLuint program = %d, GLuint shader = %d)", program, shader);
1541
1542 gl::Context *context = gl::getContext();
1543
1544 if(context)
1545 {
1546 gl::Program *programObject = context->getProgram(program);
1547 gl::Shader *shaderObject = context->getShader(shader);
1548
1549 if(!programObject)
1550 {
1551 gl::Shader *shaderByProgramHandle;
1552 shaderByProgramHandle = context->getShader(program);
1553 if(!shaderByProgramHandle)
1554 {
1555 return error(GL_INVALID_VALUE);
1556 }
1557 else
1558 {
1559 return error(GL_INVALID_OPERATION);
1560 }
1561 }
1562
1563 if(!shaderObject)
1564 {
1565 gl::Program *programByShaderHandle = context->getProgram(shader);
1566 if(!programByShaderHandle)
1567 {
1568 return error(GL_INVALID_VALUE);
1569 }
1570 else
1571 {
1572 return error(GL_INVALID_OPERATION);
1573 }
1574 }
1575
1576 if(!programObject->detachShader(shaderObject))
1577 {
1578 return error(GL_INVALID_OPERATION);
1579 }
1580 }
1581 }
1582
glDisable(GLenum cap)1583 void APIENTRY glDisable(GLenum cap)
1584 {
1585 TRACE("(GLenum cap = 0x%X)", cap);
1586
1587 gl::Context *context = gl::getContext();
1588
1589 if(context)
1590 {
1591 if(context->getListIndex() != 0)
1592 {
1593 UNIMPLEMENTED();
1594 }
1595
1596 switch(cap)
1597 {
1598 case GL_CULL_FACE: context->setCullFaceEnabled(false); break;
1599 case GL_POLYGON_OFFSET_FILL: context->setPolygonOffsetFillEnabled(false); break;
1600 case GL_SAMPLE_ALPHA_TO_COVERAGE: context->setSampleAlphaToCoverageEnabled(false); break;
1601 case GL_SAMPLE_COVERAGE: context->setSampleCoverageEnabled(false); break;
1602 case GL_SCISSOR_TEST: context->setScissorTestEnabled(false); break;
1603 case GL_STENCIL_TEST: context->setStencilTestEnabled(false); break;
1604 case GL_DEPTH_TEST: context->setDepthTestEnabled(false); break;
1605 case GL_BLEND: context->setBlendEnabled(false); break;
1606 case GL_DITHER: context->setDitherEnabled(false); break;
1607 case GL_LIGHTING: context->setLightingEnabled(false); break;
1608 case GL_FOG: context->setFogEnabled(false); break;
1609 case GL_ALPHA_TEST: context->setAlphaTestEnabled(false); break;
1610 case GL_TEXTURE_2D: context->setTexture2DEnabled(false); break;
1611 case GL_LIGHT0: context->setLightEnabled(0, false); break;
1612 case GL_LIGHT1: context->setLightEnabled(1, false); break;
1613 case GL_LIGHT2: context->setLightEnabled(2, false); break;
1614 case GL_LIGHT3: context->setLightEnabled(3, false); break;
1615 case GL_LIGHT4: context->setLightEnabled(4, false); break;
1616 case GL_LIGHT5: context->setLightEnabled(5, false); break;
1617 case GL_LIGHT6: context->setLightEnabled(6, false); break;
1618 case GL_LIGHT7: context->setLightEnabled(7, false); break;
1619 case GL_COLOR_MATERIAL: context->setColorMaterialEnabled(false); break;
1620 case GL_RESCALE_NORMAL: context->setNormalizeNormalsEnabled(false); break;
1621 case GL_COLOR_LOGIC_OP: context->setColorLogicOpEnabled(false); break;
1622 case GL_INDEX_LOGIC_OP: UNIMPLEMENTED();
1623 default:
1624 return error(GL_INVALID_ENUM);
1625 }
1626 }
1627 }
1628
glDisableVertexAttribArray(GLuint index)1629 void APIENTRY glDisableVertexAttribArray(GLuint index)
1630 {
1631 TRACE("(GLuint index = %d)", index);
1632
1633 if(index >= gl::MAX_VERTEX_ATTRIBS)
1634 {
1635 return error(GL_INVALID_VALUE);
1636 }
1637
1638 gl::Context *context = gl::getContext();
1639
1640 if(context)
1641 {
1642 context->setVertexAttribArrayEnabled(index, false);
1643 }
1644 }
1645
glCaptureAttribs()1646 void APIENTRY glCaptureAttribs()
1647 {
1648 TRACE("()");
1649
1650 gl::Context *context = gl::getContext();
1651
1652 if(context)
1653 {
1654 context->captureAttribs();
1655 }
1656 }
1657
glRestoreAttribs()1658 void APIENTRY glRestoreAttribs()
1659 {
1660 TRACE("()");
1661
1662 gl::Context *context = gl::getContext();
1663
1664 if(context)
1665 {
1666 context->restoreAttribs();
1667 }
1668 }
1669
glDrawArrays(GLenum mode,GLint first,GLsizei count)1670 void APIENTRY glDrawArrays(GLenum mode, GLint first, GLsizei count)
1671 {
1672 TRACE("(GLenum mode = 0x%X, GLint first = %d, GLsizei count = %d)", mode, first, count);
1673
1674 if(count < 0 || first < 0)
1675 {
1676 return error(GL_INVALID_VALUE);
1677 }
1678
1679 gl::Context *context = gl::getContext();
1680
1681 if(context)
1682 {
1683 if(context->getListIndex() != 0)
1684 {
1685 ASSERT(context->getListMode() != GL_COMPILE_AND_EXECUTE); // UNIMPLEMENTED!
1686
1687 context->listCommand(gl::newCommand(glCaptureAttribs));
1688 context->captureDrawArrays(mode, first, count);
1689 context->listCommand(gl::newCommand(glDrawArrays, mode, first, count));
1690 context->listCommand(gl::newCommand(glRestoreAttribs));
1691
1692 return;
1693 }
1694
1695 context->drawArrays(mode, first, count);
1696 }
1697 }
1698
glDrawElements(GLenum mode,GLsizei count,GLenum type,const GLvoid * indices)1699 void APIENTRY glDrawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid* indices)
1700 {
1701 TRACE("(GLenum mode = 0x%X, GLsizei count = %d, GLenum type = 0x%X, const GLvoid* indices = %p)",
1702 mode, count, type, indices);
1703
1704 if(count < 0)
1705 {
1706 return error(GL_INVALID_VALUE);
1707 }
1708
1709 gl::Context *context = gl::getContext();
1710
1711 if(context)
1712 {
1713 if(context->getListIndex() != 0)
1714 {
1715 UNIMPLEMENTED();
1716 }
1717
1718 switch(type)
1719 {
1720 case GL_UNSIGNED_BYTE:
1721 case GL_UNSIGNED_SHORT:
1722 case GL_UNSIGNED_INT:
1723 break;
1724 default:
1725 return error(GL_INVALID_ENUM);
1726 }
1727
1728 context->drawElements(mode, count, type, indices);
1729 }
1730 }
1731
glEnable(GLenum cap)1732 void APIENTRY glEnable(GLenum cap)
1733 {
1734 TRACE("(GLenum cap = 0x%X)", cap);
1735
1736 gl::Context *context = gl::getContext();
1737
1738 if(context)
1739 {
1740 if(context->getListIndex() != 0)
1741 {
1742 UNIMPLEMENTED();
1743 }
1744
1745 switch(cap)
1746 {
1747 case GL_CULL_FACE: context->setCullFaceEnabled(true); break;
1748 case GL_POLYGON_OFFSET_FILL: context->setPolygonOffsetFillEnabled(true); break;
1749 case GL_SAMPLE_ALPHA_TO_COVERAGE: context->setSampleAlphaToCoverageEnabled(true); break;
1750 case GL_SAMPLE_COVERAGE: context->setSampleCoverageEnabled(true); break;
1751 case GL_SCISSOR_TEST: context->setScissorTestEnabled(true); break;
1752 case GL_STENCIL_TEST: context->setStencilTestEnabled(true); break;
1753 case GL_DEPTH_TEST: context->setDepthTestEnabled(true); break;
1754 case GL_BLEND: context->setBlendEnabled(true); break;
1755 case GL_DITHER: context->setDitherEnabled(true); break;
1756 case GL_TEXTURE_2D: context->setTexture2DEnabled(true); break;
1757 case GL_ALPHA_TEST: context->setAlphaTestEnabled(true); break;
1758 case GL_COLOR_MATERIAL: context->setColorMaterialEnabled(true); break;
1759 case GL_FOG: context->setFogEnabled(true); break;
1760 case GL_LIGHTING: context->setLightingEnabled(true); break;
1761 case GL_LIGHT0: context->setLightEnabled(0, true); break;
1762 case GL_LIGHT1: context->setLightEnabled(1, true); break;
1763 case GL_LIGHT2: context->setLightEnabled(2, true); break;
1764 case GL_LIGHT3: context->setLightEnabled(3, true); break;
1765 case GL_LIGHT4: context->setLightEnabled(4, true); break;
1766 case GL_LIGHT5: context->setLightEnabled(5, true); break;
1767 case GL_LIGHT6: context->setLightEnabled(6, true); break;
1768 case GL_LIGHT7: context->setLightEnabled(7, true); break;
1769 case GL_RESCALE_NORMAL: context->setNormalizeNormalsEnabled(true); break;
1770 case GL_COLOR_LOGIC_OP: context->setColorLogicOpEnabled(true); break;
1771 case GL_INDEX_LOGIC_OP: UNIMPLEMENTED();
1772 default:
1773 return error(GL_INVALID_ENUM);
1774 }
1775 }
1776 }
1777
glEnableVertexAttribArray(GLuint index)1778 void APIENTRY glEnableVertexAttribArray(GLuint index)
1779 {
1780 TRACE("(GLuint index = %d)", index);
1781
1782 if(index >= gl::MAX_VERTEX_ATTRIBS)
1783 {
1784 return error(GL_INVALID_VALUE);
1785 }
1786
1787 gl::Context *context = gl::getContext();
1788
1789 if(context)
1790 {
1791 context->setVertexAttribArrayEnabled(index, true);
1792 }
1793 }
1794
glEndQueryEXT(GLenum target)1795 void APIENTRY glEndQueryEXT(GLenum target)
1796 {
1797 TRACE("GLenum target = 0x%X)", target);
1798
1799 switch(target)
1800 {
1801 case GL_ANY_SAMPLES_PASSED:
1802 case GL_ANY_SAMPLES_PASSED_CONSERVATIVE:
1803 break;
1804 default:
1805 return error(GL_INVALID_ENUM);
1806 }
1807
1808 gl::Context *context = gl::getContext();
1809
1810 if(context)
1811 {
1812 if(context->getListIndex() != 0)
1813 {
1814 UNIMPLEMENTED();
1815 }
1816
1817 context->endQuery(target);
1818 }
1819 }
1820
glFinishFenceNV(GLuint fence)1821 void APIENTRY glFinishFenceNV(GLuint fence)
1822 {
1823 TRACE("(GLuint fence = %d)", fence);
1824
1825 gl::Context *context = gl::getContext();
1826
1827 if(context)
1828 {
1829 if(context->getListIndex() != 0)
1830 {
1831 UNIMPLEMENTED();
1832 }
1833
1834 gl::Fence* fenceObject = context->getFence(fence);
1835
1836 if(!fenceObject)
1837 {
1838 return error(GL_INVALID_OPERATION);
1839 }
1840
1841 fenceObject->finishFence();
1842 }
1843 }
1844
glFinish(void)1845 void APIENTRY glFinish(void)
1846 {
1847 TRACE("()");
1848
1849 gl::Context *context = gl::getContext();
1850
1851 if(context)
1852 {
1853 context->finish();
1854 }
1855 }
1856
glFlush(void)1857 void APIENTRY glFlush(void)
1858 {
1859 TRACE("()");
1860
1861 gl::Context *context = gl::getContext();
1862
1863 if(context)
1864 {
1865 context->flush();
1866 }
1867 }
1868
glFramebufferRenderbuffer(GLenum target,GLenum attachment,GLenum renderbuffertarget,GLuint renderbuffer)1869 void APIENTRY glFramebufferRenderbuffer(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer)
1870 {
1871 TRACE("(GLenum target = 0x%X, GLenum attachment = 0x%X, GLenum renderbuffertarget = 0x%X, "
1872 "GLuint renderbuffer = %d)", target, attachment, renderbuffertarget, renderbuffer);
1873
1874 if((target != GL_FRAMEBUFFER && target != GL_DRAW_FRAMEBUFFER_EXT && target != GL_READ_FRAMEBUFFER_EXT) ||
1875 (renderbuffertarget != GL_RENDERBUFFER && renderbuffer != 0))
1876 {
1877 return error(GL_INVALID_ENUM);
1878 }
1879
1880 gl::Context *context = gl::getContext();
1881
1882 if(context)
1883 {
1884 if(context->getListIndex() != 0)
1885 {
1886 UNIMPLEMENTED();
1887 }
1888
1889 gl::Framebuffer *framebuffer = nullptr;
1890 GLuint framebufferName = 0;
1891 if(target == GL_READ_FRAMEBUFFER_EXT)
1892 {
1893 framebuffer = context->getReadFramebuffer();
1894 framebufferName = context->getReadFramebufferName();
1895 }
1896 else
1897 {
1898 framebuffer = context->getDrawFramebuffer();
1899 framebufferName = context->getDrawFramebufferName();
1900 }
1901
1902 if(!framebuffer || (framebufferName == 0 && renderbuffer != 0))
1903 {
1904 return error(GL_INVALID_OPERATION);
1905 }
1906
1907 switch(attachment)
1908 {
1909 case GL_COLOR_ATTACHMENT0:
1910 framebuffer->setColorbuffer(GL_RENDERBUFFER, renderbuffer);
1911 break;
1912 case GL_DEPTH_ATTACHMENT:
1913 framebuffer->setDepthbuffer(GL_RENDERBUFFER, renderbuffer);
1914 break;
1915 case GL_STENCIL_ATTACHMENT:
1916 framebuffer->setStencilbuffer(GL_RENDERBUFFER, renderbuffer);
1917 break;
1918 default:
1919 return error(GL_INVALID_ENUM);
1920 }
1921 }
1922 }
1923
glFramebufferTexture1D(GLenum target,GLenum attachment,GLenum textarget,GLuint texture,GLint level)1924 void APIENTRY glFramebufferTexture1D(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level)
1925 {
1926 UNIMPLEMENTED();
1927 }
1928
glFramebufferTexture2D(GLenum target,GLenum attachment,GLenum textarget,GLuint texture,GLint level)1929 void APIENTRY glFramebufferTexture2D(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level)
1930 {
1931 TRACE("(GLenum target = 0x%X, GLenum attachment = 0x%X, GLenum textarget = 0x%X, "
1932 "GLuint texture = %d, GLint level = %d)", target, attachment, textarget, texture, level);
1933
1934 if(target != GL_FRAMEBUFFER && target != GL_DRAW_FRAMEBUFFER_EXT && target != GL_READ_FRAMEBUFFER_EXT)
1935 {
1936 return error(GL_INVALID_ENUM);
1937 }
1938
1939 switch(attachment)
1940 {
1941 case GL_COLOR_ATTACHMENT0:
1942 case GL_DEPTH_ATTACHMENT:
1943 case GL_STENCIL_ATTACHMENT:
1944 break;
1945 default:
1946 return error(GL_INVALID_ENUM);
1947 }
1948
1949 gl::Context *context = gl::getContext();
1950
1951 if(context)
1952 {
1953 if(context->getListIndex() != 0)
1954 {
1955 UNIMPLEMENTED();
1956 }
1957
1958 if(texture == 0)
1959 {
1960 textarget = GL_NONE;
1961 }
1962 else
1963 {
1964 gl::Texture *tex = context->getTexture(texture);
1965
1966 if(!tex)
1967 {
1968 return error(GL_INVALID_OPERATION);
1969 }
1970
1971 if(tex->isCompressed(textarget, level))
1972 {
1973 return error(GL_INVALID_OPERATION);
1974 }
1975
1976 switch(textarget)
1977 {
1978 case GL_TEXTURE_2D:
1979 if(tex->getTarget() != GL_TEXTURE_2D)
1980 {
1981 return error(GL_INVALID_OPERATION);
1982 }
1983 break;
1984 case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
1985 case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
1986 case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
1987 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
1988 case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
1989 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
1990 if(tex->getTarget() != GL_TEXTURE_CUBE_MAP)
1991 {
1992 return error(GL_INVALID_OPERATION);
1993 }
1994 break;
1995 default:
1996 return error(GL_INVALID_ENUM);
1997 }
1998
1999 if(level != 0)
2000 {
2001 return error(GL_INVALID_VALUE);
2002 }
2003 }
2004
2005 gl::Framebuffer *framebuffer = nullptr;
2006 GLuint framebufferName = 0;
2007 if(target == GL_READ_FRAMEBUFFER_EXT)
2008 {
2009 framebuffer = context->getReadFramebuffer();
2010 framebufferName = context->getReadFramebufferName();
2011 }
2012 else
2013 {
2014 framebuffer = context->getDrawFramebuffer();
2015 framebufferName = context->getDrawFramebufferName();
2016 }
2017
2018 if(framebufferName == 0 || !framebuffer)
2019 {
2020 return error(GL_INVALID_OPERATION);
2021 }
2022
2023 switch(attachment)
2024 {
2025 case GL_COLOR_ATTACHMENT0: framebuffer->setColorbuffer(textarget, texture); break;
2026 case GL_DEPTH_ATTACHMENT: framebuffer->setDepthbuffer(textarget, texture); break;
2027 case GL_STENCIL_ATTACHMENT: framebuffer->setStencilbuffer(textarget, texture); break;
2028 }
2029 }
2030 }
2031
glFramebufferTexture3D(GLenum target,GLenum attachment,GLenum textarget,GLuint texture,GLint level,GLint zoffset)2032 void APIENTRY glFramebufferTexture3D(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset)
2033 {
2034 UNIMPLEMENTED();
2035 }
2036
glFrontFace(GLenum mode)2037 void APIENTRY glFrontFace(GLenum mode)
2038 {
2039 TRACE("(GLenum mode = 0x%X)", mode);
2040
2041 switch(mode)
2042 {
2043 case GL_CW:
2044 case GL_CCW:
2045 {
2046 gl::Context *context = gl::getContext();
2047
2048 if(context)
2049 {
2050 context->setFrontFace(mode);
2051 }
2052 }
2053 break;
2054 default:
2055 return error(GL_INVALID_ENUM);
2056 }
2057 }
2058
glGenBuffers(GLsizei n,GLuint * buffers)2059 void APIENTRY glGenBuffers(GLsizei n, GLuint* buffers)
2060 {
2061 TRACE("(GLsizei n = %d, GLuint* buffers = %p)", n, buffers);
2062
2063 if(n < 0)
2064 {
2065 return error(GL_INVALID_VALUE);
2066 }
2067
2068 gl::Context *context = gl::getContext();
2069
2070 if(context)
2071 {
2072 for(int i = 0; i < n; i++)
2073 {
2074 buffers[i] = context->createBuffer();
2075 }
2076 }
2077 }
2078
glGenerateMipmap(GLenum target)2079 void APIENTRY glGenerateMipmap(GLenum target)
2080 {
2081 TRACE("(GLenum target = 0x%X)", target);
2082
2083 gl::Context *context = gl::getContext();
2084
2085 if(context)
2086 {
2087 if(context->getListIndex() != 0)
2088 {
2089 UNIMPLEMENTED();
2090 }
2091
2092 gl::Texture *texture;
2093
2094 switch(target)
2095 {
2096 case GL_TEXTURE_2D:
2097 texture = context->getTexture2D(target);
2098 break;
2099 case GL_TEXTURE_CUBE_MAP:
2100 texture = context->getTextureCubeMap();
2101 break;
2102 default:
2103 return error(GL_INVALID_ENUM);
2104 }
2105
2106 if(texture->isCompressed(target, 0) || texture->isDepth(target, 0))
2107 {
2108 return error(GL_INVALID_OPERATION);
2109 }
2110
2111 texture->generateMipmaps();
2112 }
2113 }
2114
glGenFencesNV(GLsizei n,GLuint * fences)2115 void APIENTRY glGenFencesNV(GLsizei n, GLuint* fences)
2116 {
2117 TRACE("(GLsizei n = %d, GLuint* fences = %p)", n, fences);
2118
2119 if(n < 0)
2120 {
2121 return error(GL_INVALID_VALUE);
2122 }
2123
2124 gl::Context *context = gl::getContext();
2125
2126 if(context)
2127 {
2128 if(context->getListIndex() != 0)
2129 {
2130 UNIMPLEMENTED();
2131 }
2132
2133 for(int i = 0; i < n; i++)
2134 {
2135 fences[i] = context->createFence();
2136 }
2137 }
2138 }
2139
glGenFramebuffers(GLsizei n,GLuint * framebuffers)2140 void APIENTRY glGenFramebuffers(GLsizei n, GLuint* framebuffers)
2141 {
2142 TRACE("(GLsizei n = %d, GLuint* framebuffers = %p)", n, framebuffers);
2143
2144 if(n < 0)
2145 {
2146 return error(GL_INVALID_VALUE);
2147 }
2148
2149 gl::Context *context = gl::getContext();
2150
2151 if(context)
2152 {
2153 if(context->getListIndex() != 0)
2154 {
2155 UNIMPLEMENTED();
2156 }
2157
2158 for(int i = 0; i < n; i++)
2159 {
2160 framebuffers[i] = context->createFramebuffer();
2161 }
2162 }
2163 }
2164
glGenQueriesEXT(GLsizei n,GLuint * ids)2165 void APIENTRY glGenQueriesEXT(GLsizei n, GLuint* ids)
2166 {
2167 TRACE("(GLsizei n = %d, GLuint* ids = %p)", n, ids);
2168
2169 if(n < 0)
2170 {
2171 return error(GL_INVALID_VALUE);
2172 }
2173
2174 gl::Context *context = gl::getContext();
2175
2176 if(context)
2177 {
2178 for(int i = 0; i < n; i++)
2179 {
2180 ids[i] = context->createQuery();
2181 }
2182 }
2183 }
2184
glGenRenderbuffers(GLsizei n,GLuint * renderbuffers)2185 void APIENTRY glGenRenderbuffers(GLsizei n, GLuint* renderbuffers)
2186 {
2187 TRACE("(GLsizei n = %d, GLuint* renderbuffers = %p)", n, renderbuffers);
2188
2189 if(n < 0)
2190 {
2191 return error(GL_INVALID_VALUE);
2192 }
2193
2194 gl::Context *context = gl::getContext();
2195
2196 if(context)
2197 {
2198 if(context->getListIndex() != 0)
2199 {
2200 UNIMPLEMENTED();
2201 }
2202
2203 for(int i = 0; i < n; i++)
2204 {
2205 renderbuffers[i] = context->createRenderbuffer();
2206 }
2207 }
2208 }
2209
glGenTextures(GLsizei n,GLuint * textures)2210 void APIENTRY glGenTextures(GLsizei n, GLuint* textures)
2211 {
2212 TRACE("(GLsizei n = %d, GLuint* textures = %p)", n, textures);
2213
2214 if(n < 0)
2215 {
2216 return error(GL_INVALID_VALUE);
2217 }
2218
2219 gl::Context *context = gl::getContext();
2220
2221 if(context)
2222 {
2223 for(int i = 0; i < n; i++)
2224 {
2225 textures[i] = context->createTexture();
2226 }
2227 }
2228 }
2229
glGetActiveAttrib(GLuint program,GLuint index,GLsizei bufsize,GLsizei * length,GLint * size,GLenum * type,GLchar * name)2230 void APIENTRY glGetActiveAttrib(GLuint program, GLuint index, GLsizei bufsize, GLsizei *length, GLint *size, GLenum *type, GLchar *name)
2231 {
2232 TRACE("(GLuint program = %d, GLuint index = %d, GLsizei bufsize = %d, GLsizei *length = %p, "
2233 "GLint *size = %p, GLenum *type = %p, GLchar *name = %p)",
2234 program, index, bufsize, length, size, type, name);
2235
2236 if(bufsize < 0)
2237 {
2238 return error(GL_INVALID_VALUE);
2239 }
2240
2241 gl::Context *context = gl::getContext();
2242
2243 if(context)
2244 {
2245 gl::Program *programObject = context->getProgram(program);
2246
2247 if(!programObject)
2248 {
2249 if(context->getShader(program))
2250 {
2251 return error(GL_INVALID_OPERATION);
2252 }
2253 else
2254 {
2255 return error(GL_INVALID_VALUE);
2256 }
2257 }
2258
2259 if(index >= programObject->getActiveAttributeCount())
2260 {
2261 return error(GL_INVALID_VALUE);
2262 }
2263
2264 programObject->getActiveAttribute(index, bufsize, length, size, type, name);
2265 }
2266 }
2267
glGetActiveUniform(GLuint program,GLuint index,GLsizei bufsize,GLsizei * length,GLint * size,GLenum * type,GLchar * name)2268 void APIENTRY glGetActiveUniform(GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, GLchar* name)
2269 {
2270 TRACE("(GLuint program = %d, GLuint index = %d, GLsizei bufsize = %d, "
2271 "GLsizei* length = %p, GLint* size = %p, GLenum* type = %p, GLchar* name = %s)",
2272 program, index, bufsize, length, size, type, name);
2273
2274 if(bufsize < 0)
2275 {
2276 return error(GL_INVALID_VALUE);
2277 }
2278
2279 gl::Context *context = gl::getContext();
2280
2281 if(context)
2282 {
2283 gl::Program *programObject = context->getProgram(program);
2284
2285 if(!programObject)
2286 {
2287 if(context->getShader(program))
2288 {
2289 return error(GL_INVALID_OPERATION);
2290 }
2291 else
2292 {
2293 return error(GL_INVALID_VALUE);
2294 }
2295 }
2296
2297 if(index >= programObject->getActiveUniformCount())
2298 {
2299 return error(GL_INVALID_VALUE);
2300 }
2301
2302 programObject->getActiveUniform(index, bufsize, length, size, type, name);
2303 }
2304 }
2305
glGetAttachedShaders(GLuint program,GLsizei maxcount,GLsizei * count,GLuint * shaders)2306 void APIENTRY glGetAttachedShaders(GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders)
2307 {
2308 TRACE("(GLuint program = %d, GLsizei maxcount = %d, GLsizei* count = %p, GLuint* shaders = %p)",
2309 program, maxcount, count, shaders);
2310
2311 if(maxcount < 0)
2312 {
2313 return error(GL_INVALID_VALUE);
2314 }
2315
2316 gl::Context *context = gl::getContext();
2317
2318 if(context)
2319 {
2320 gl::Program *programObject = context->getProgram(program);
2321
2322 if(!programObject)
2323 {
2324 if(context->getShader(program))
2325 {
2326 return error(GL_INVALID_OPERATION);
2327 }
2328 else
2329 {
2330 return error(GL_INVALID_VALUE);
2331 }
2332 }
2333
2334 return programObject->getAttachedShaders(maxcount, count, shaders);
2335 }
2336 }
2337
glGetAttribLocation(GLuint program,const GLchar * name)2338 int APIENTRY glGetAttribLocation(GLuint program, const GLchar* name)
2339 {
2340 TRACE("(GLuint program = %d, const GLchar* name = %s)", program, name);
2341
2342 gl::Context *context = gl::getContext();
2343
2344 if(context)
2345 {
2346 gl::Program *programObject = context->getProgram(program);
2347
2348 if(!programObject)
2349 {
2350 if(context->getShader(program))
2351 {
2352 return error(GL_INVALID_OPERATION, -1);
2353 }
2354 else
2355 {
2356 return error(GL_INVALID_VALUE, -1);
2357 }
2358 }
2359
2360 if(!programObject->isLinked())
2361 {
2362 return error(GL_INVALID_OPERATION, -1);
2363 }
2364
2365 return programObject->getAttributeLocation(name);
2366 }
2367
2368 return -1;
2369 }
2370
glGetBooleanv(GLenum pname,GLboolean * params)2371 void APIENTRY glGetBooleanv(GLenum pname, GLboolean* params)
2372 {
2373 TRACE("(GLenum pname = 0x%X, GLboolean* params = %p)", pname, params);
2374
2375 gl::Context *context = gl::getContext();
2376
2377 if(context)
2378 {
2379 if(!(context->getBooleanv(pname, params)))
2380 {
2381 GLenum nativeType;
2382 unsigned int numParams = 0;
2383 if(!context->getQueryParameterInfo(pname, &nativeType, &numParams))
2384 return error(GL_INVALID_ENUM);
2385
2386 if(numParams == 0)
2387 return; // it is known that the pname is valid, but there are no parameters to return
2388
2389 if(nativeType == GL_FLOAT)
2390 {
2391 GLfloat *floatParams = nullptr;
2392 floatParams = new GLfloat[numParams];
2393
2394 context->getFloatv(pname, floatParams);
2395
2396 for(unsigned int i = 0; i < numParams; ++i)
2397 {
2398 if(floatParams[i] == 0.0f)
2399 params[i] = GL_FALSE;
2400 else
2401 params[i] = GL_TRUE;
2402 }
2403
2404 delete [] floatParams;
2405 }
2406 else if(nativeType == GL_INT)
2407 {
2408 GLint *intParams = nullptr;
2409 intParams = new GLint[numParams];
2410
2411 context->getIntegerv(pname, intParams);
2412
2413 for(unsigned int i = 0; i < numParams; ++i)
2414 {
2415 if(intParams[i] == 0)
2416 params[i] = GL_FALSE;
2417 else
2418 params[i] = GL_TRUE;
2419 }
2420
2421 delete [] intParams;
2422 }
2423 }
2424 }
2425 }
2426
glGetBufferParameteriv(GLenum target,GLenum pname,GLint * params)2427 void APIENTRY glGetBufferParameteriv(GLenum target, GLenum pname, GLint* params)
2428 {
2429 TRACE("(GLenum target = 0x%X, GLenum pname = 0x%X, GLint* params = %p)", target, pname, params);
2430
2431 gl::Context *context = gl::getContext();
2432
2433 if(context)
2434 {
2435 gl::Buffer *buffer;
2436
2437 switch(target)
2438 {
2439 case GL_ARRAY_BUFFER:
2440 buffer = context->getArrayBuffer();
2441 break;
2442 case GL_ELEMENT_ARRAY_BUFFER:
2443 buffer = context->getElementArrayBuffer();
2444 break;
2445 default:
2446 return error(GL_INVALID_ENUM);
2447 }
2448
2449 if(!buffer)
2450 {
2451 // A null buffer means that "0" is bound to the requested buffer target
2452 return error(GL_INVALID_OPERATION);
2453 }
2454
2455 switch(pname)
2456 {
2457 case GL_BUFFER_USAGE:
2458 *params = buffer->usage();
2459 break;
2460 case GL_BUFFER_SIZE:
2461 *params = buffer->size();
2462 break;
2463 default:
2464 return error(GL_INVALID_ENUM);
2465 }
2466 }
2467 }
2468
glGetError(void)2469 GLenum APIENTRY glGetError(void)
2470 {
2471 TRACE("()");
2472
2473 gl::Context *context = gl::getContext();
2474
2475 if(context)
2476 {
2477 return context->getError();
2478 }
2479
2480 return GL_NO_ERROR;
2481 }
2482
glGetFenceivNV(GLuint fence,GLenum pname,GLint * params)2483 void APIENTRY glGetFenceivNV(GLuint fence, GLenum pname, GLint *params)
2484 {
2485 TRACE("(GLuint fence = %d, GLenum pname = 0x%X, GLint *params = %p)", fence, pname, params);
2486
2487 gl::Context *context = gl::getContext();
2488
2489 if(context)
2490 {
2491 gl::Fence *fenceObject = context->getFence(fence);
2492
2493 if(!fenceObject)
2494 {
2495 return error(GL_INVALID_OPERATION);
2496 }
2497
2498 fenceObject->getFenceiv(pname, params);
2499 }
2500 }
2501
glGetFloatv(GLenum pname,GLfloat * params)2502 void APIENTRY glGetFloatv(GLenum pname, GLfloat* params)
2503 {
2504 TRACE("(GLenum pname = 0x%X, GLfloat* params = %p)", pname, params);
2505
2506 gl::Context *context = gl::getContext();
2507
2508 if(context)
2509 {
2510 if(!(context->getFloatv(pname, params)))
2511 {
2512 GLenum nativeType;
2513 unsigned int numParams = 0;
2514 if(!context->getQueryParameterInfo(pname, &nativeType, &numParams))
2515 return error(GL_INVALID_ENUM);
2516
2517 if(numParams == 0)
2518 return; // it is known that the pname is valid, but that there are no parameters to return.
2519
2520 if(nativeType == GL_BOOL)
2521 {
2522 GLboolean *boolParams = nullptr;
2523 boolParams = new GLboolean[numParams];
2524
2525 context->getBooleanv(pname, boolParams);
2526
2527 for(unsigned int i = 0; i < numParams; ++i)
2528 {
2529 if(boolParams[i] == GL_FALSE)
2530 params[i] = 0.0f;
2531 else
2532 params[i] = 1.0f;
2533 }
2534
2535 delete [] boolParams;
2536 }
2537 else if(nativeType == GL_INT)
2538 {
2539 GLint *intParams = nullptr;
2540 intParams = new GLint[numParams];
2541
2542 context->getIntegerv(pname, intParams);
2543
2544 for(unsigned int i = 0; i < numParams; ++i)
2545 {
2546 params[i] = (GLfloat)intParams[i];
2547 }
2548
2549 delete [] intParams;
2550 }
2551 }
2552 }
2553 }
2554
glGetFramebufferAttachmentParameteriv(GLenum target,GLenum attachment,GLenum pname,GLint * params)2555 void APIENTRY glGetFramebufferAttachmentParameteriv(GLenum target, GLenum attachment, GLenum pname, GLint* params)
2556 {
2557 TRACE("(GLenum target = 0x%X, GLenum attachment = 0x%X, GLenum pname = 0x%X, GLint* params = %p)",
2558 target, attachment, pname, params);
2559
2560 gl::Context *context = gl::getContext();
2561
2562 if(context)
2563 {
2564 if(target != GL_FRAMEBUFFER && target != GL_DRAW_FRAMEBUFFER_EXT && target != GL_READ_FRAMEBUFFER_EXT)
2565 {
2566 return error(GL_INVALID_ENUM);
2567 }
2568
2569 gl::Framebuffer *framebuffer = nullptr;
2570 if(target == GL_READ_FRAMEBUFFER_EXT)
2571 {
2572 if(context->getReadFramebufferName() == 0)
2573 {
2574 return error(GL_INVALID_OPERATION);
2575 }
2576
2577 framebuffer = context->getReadFramebuffer();
2578 }
2579 else
2580 {
2581 if(context->getDrawFramebufferName() == 0)
2582 {
2583 return error(GL_INVALID_OPERATION);
2584 }
2585
2586 framebuffer = context->getDrawFramebuffer();
2587 }
2588
2589 GLenum attachmentType;
2590 GLuint attachmentHandle;
2591 switch(attachment)
2592 {
2593 case GL_COLOR_ATTACHMENT0:
2594 attachmentType = framebuffer->getColorbufferType();
2595 attachmentHandle = framebuffer->getColorbufferName();
2596 break;
2597 case GL_DEPTH_ATTACHMENT:
2598 attachmentType = framebuffer->getDepthbufferType();
2599 attachmentHandle = framebuffer->getDepthbufferName();
2600 break;
2601 case GL_STENCIL_ATTACHMENT:
2602 attachmentType = framebuffer->getStencilbufferType();
2603 attachmentHandle = framebuffer->getStencilbufferName();
2604 break;
2605 default:
2606 return error(GL_INVALID_ENUM);
2607 }
2608
2609 GLenum attachmentObjectType; // Type category
2610 if(attachmentType == GL_NONE || attachmentType == GL_RENDERBUFFER)
2611 {
2612 attachmentObjectType = attachmentType;
2613 }
2614 else if(gl::IsTextureTarget(attachmentType))
2615 {
2616 attachmentObjectType = GL_TEXTURE;
2617 }
2618 else UNREACHABLE(attachmentType);
2619
2620 switch(pname)
2621 {
2622 case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE:
2623 *params = attachmentObjectType;
2624 break;
2625 case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME:
2626 if(attachmentObjectType == GL_RENDERBUFFER || attachmentObjectType == GL_TEXTURE)
2627 {
2628 *params = attachmentHandle;
2629 }
2630 else
2631 {
2632 return error(GL_INVALID_ENUM);
2633 }
2634 break;
2635 case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL:
2636 if(attachmentObjectType == GL_TEXTURE)
2637 {
2638 *params = 0; // FramebufferTexture2D will not allow level to be set to anything else in GL ES 2.0
2639 }
2640 else
2641 {
2642 return error(GL_INVALID_ENUM);
2643 }
2644 break;
2645 case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE:
2646 if(attachmentObjectType == GL_TEXTURE)
2647 {
2648 if(gl::IsCubemapTextureTarget(attachmentType))
2649 {
2650 *params = attachmentType;
2651 }
2652 else
2653 {
2654 *params = 0;
2655 }
2656 }
2657 else
2658 {
2659 return error(GL_INVALID_ENUM);
2660 }
2661 break;
2662 default:
2663 return error(GL_INVALID_ENUM);
2664 }
2665 }
2666 }
2667
glGetGraphicsResetStatusEXT(void)2668 GLenum APIENTRY glGetGraphicsResetStatusEXT(void)
2669 {
2670 TRACE("()");
2671
2672 return GL_NO_ERROR;
2673 }
2674
glGetIntegerv(GLenum pname,GLint * params)2675 void APIENTRY glGetIntegerv(GLenum pname, GLint* params)
2676 {
2677 TRACE("(GLenum pname = 0x%X, GLint* params = %p)", pname, params);
2678
2679 gl::Context *context = gl::getContext();
2680
2681 if(context)
2682 {
2683 if(!(context->getIntegerv(pname, params)))
2684 {
2685 GLenum nativeType;
2686 unsigned int numParams = 0;
2687 if(!context->getQueryParameterInfo(pname, &nativeType, &numParams))
2688 return error(GL_INVALID_ENUM);
2689
2690 if(numParams == 0)
2691 return; // it is known that pname is valid, but there are no parameters to return
2692
2693 if(nativeType == GL_BOOL)
2694 {
2695 GLboolean *boolParams = nullptr;
2696 boolParams = new GLboolean[numParams];
2697
2698 context->getBooleanv(pname, boolParams);
2699
2700 for(unsigned int i = 0; i < numParams; ++i)
2701 {
2702 if(boolParams[i] == GL_FALSE)
2703 params[i] = 0;
2704 else
2705 params[i] = 1;
2706 }
2707
2708 delete [] boolParams;
2709 }
2710 else if(nativeType == GL_FLOAT)
2711 {
2712 GLfloat *floatParams = nullptr;
2713 floatParams = new GLfloat[numParams];
2714
2715 context->getFloatv(pname, floatParams);
2716
2717 for(unsigned int i = 0; i < numParams; ++i)
2718 {
2719 if(pname == GL_DEPTH_RANGE || pname == GL_COLOR_CLEAR_VALUE || pname == GL_DEPTH_CLEAR_VALUE || pname == GL_BLEND_COLOR)
2720 {
2721 params[i] = (GLint)(((GLfloat)(0xFFFFFFFF) * floatParams[i] - 1.0f) / 2.0f);
2722 }
2723 else
2724 {
2725 params[i] = (GLint)(floatParams[i] > 0.0f ? floor(floatParams[i] + 0.5) : ceil(floatParams[i] - 0.5));
2726 }
2727 }
2728
2729 delete [] floatParams;
2730 }
2731 }
2732 }
2733 }
2734
glGetProgramiv(GLuint program,GLenum pname,GLint * params)2735 void APIENTRY glGetProgramiv(GLuint program, GLenum pname, GLint* params)
2736 {
2737 TRACE("(GLuint program = %d, GLenum pname = 0x%X, GLint* params = %p)", program, pname, params);
2738
2739 gl::Context *context = gl::getContext();
2740
2741 if(context)
2742 {
2743 gl::Program *programObject = context->getProgram(program);
2744
2745 if(!programObject)
2746 {
2747 return error(GL_INVALID_VALUE);
2748 }
2749
2750 switch(pname)
2751 {
2752 case GL_DELETE_STATUS:
2753 *params = programObject->isFlaggedForDeletion();
2754 return;
2755 case GL_LINK_STATUS:
2756 *params = programObject->isLinked();
2757 return;
2758 case GL_VALIDATE_STATUS:
2759 *params = programObject->isValidated();
2760 return;
2761 case GL_INFO_LOG_LENGTH:
2762 *params = programObject->getInfoLogLength();
2763 return;
2764 case GL_ATTACHED_SHADERS:
2765 *params = programObject->getAttachedShadersCount();
2766 return;
2767 case GL_ACTIVE_ATTRIBUTES:
2768 *params = programObject->getActiveAttributeCount();
2769 return;
2770 case GL_ACTIVE_ATTRIBUTE_MAX_LENGTH:
2771 *params = programObject->getActiveAttributeMaxLength();
2772 return;
2773 case GL_ACTIVE_UNIFORMS:
2774 *params = programObject->getActiveUniformCount();
2775 return;
2776 case GL_ACTIVE_UNIFORM_MAX_LENGTH:
2777 *params = programObject->getActiveUniformMaxLength();
2778 return;
2779 default:
2780 return error(GL_INVALID_ENUM);
2781 }
2782 }
2783 }
2784
glGetProgramInfoLog(GLuint program,GLsizei bufsize,GLsizei * length,GLchar * infolog)2785 void APIENTRY glGetProgramInfoLog(GLuint program, GLsizei bufsize, GLsizei* length, GLchar* infolog)
2786 {
2787 TRACE("(GLuint program = %d, GLsizei bufsize = %d, GLsizei* length = %p, GLchar* infolog = %p)",
2788 program, bufsize, length, infolog);
2789
2790 if(bufsize < 0)
2791 {
2792 return error(GL_INVALID_VALUE);
2793 }
2794
2795 gl::Context *context = gl::getContext();
2796
2797 if(context)
2798 {
2799 gl::Program *programObject = context->getProgram(program);
2800
2801 if(!programObject)
2802 {
2803 return error(GL_INVALID_VALUE);
2804 }
2805
2806 programObject->getInfoLog(bufsize, length, infolog);
2807 }
2808 }
2809
glGetQueryivEXT(GLenum target,GLenum pname,GLint * params)2810 void APIENTRY glGetQueryivEXT(GLenum target, GLenum pname, GLint *params)
2811 {
2812 TRACE("GLenum target = 0x%X, GLenum pname = 0x%X, GLint *params = %p)", target, pname, params);
2813
2814 switch(pname)
2815 {
2816 case GL_CURRENT_QUERY:
2817 break;
2818 default:
2819 return error(GL_INVALID_ENUM);
2820 }
2821
2822 gl::Context *context = gl::getContext();
2823
2824 if(context)
2825 {
2826 params[0] = context->getActiveQuery(target);
2827 }
2828 }
2829
glGetQueryObjectuivEXT(GLuint name,GLenum pname,GLuint * params)2830 void APIENTRY glGetQueryObjectuivEXT(GLuint name, GLenum pname, GLuint *params)
2831 {
2832 TRACE("(GLuint name = %d, GLenum pname = 0x%X, GLuint *params = %p)", name, pname, params);
2833
2834 switch(pname)
2835 {
2836 case GL_QUERY_RESULT:
2837 case GL_QUERY_RESULT_AVAILABLE:
2838 break;
2839 default:
2840 return error(GL_INVALID_ENUM);
2841 }
2842
2843 gl::Context *context = gl::getContext();
2844
2845 if(context)
2846 {
2847 gl::Query *queryObject = context->getQuery(name, false, GL_NONE);
2848
2849 if(!queryObject)
2850 {
2851 return error(GL_INVALID_OPERATION);
2852 }
2853
2854 if(context->getActiveQuery(queryObject->getType()) == name)
2855 {
2856 return error(GL_INVALID_OPERATION);
2857 }
2858
2859 switch(pname)
2860 {
2861 case GL_QUERY_RESULT:
2862 params[0] = queryObject->getResult();
2863 break;
2864 case GL_QUERY_RESULT_AVAILABLE:
2865 params[0] = queryObject->isResultAvailable();
2866 break;
2867 default:
2868 ASSERT(false);
2869 }
2870 }
2871 }
2872
glGetRenderbufferParameteriv(GLenum target,GLenum pname,GLint * params)2873 void APIENTRY glGetRenderbufferParameteriv(GLenum target, GLenum pname, GLint* params)
2874 {
2875 TRACE("(GLenum target = 0x%X, GLenum pname = 0x%X, GLint* params = %p)", target, pname, params);
2876
2877 gl::Context *context = gl::getContext();
2878
2879 if(context)
2880 {
2881 if(target != GL_RENDERBUFFER)
2882 {
2883 return error(GL_INVALID_ENUM);
2884 }
2885
2886 if(context->getRenderbufferName() == 0)
2887 {
2888 return error(GL_INVALID_OPERATION);
2889 }
2890
2891 gl::Renderbuffer *renderbuffer = context->getRenderbuffer(context->getRenderbufferName());
2892
2893 switch(pname)
2894 {
2895 case GL_RENDERBUFFER_WIDTH: *params = renderbuffer->getWidth(); break;
2896 case GL_RENDERBUFFER_HEIGHT: *params = renderbuffer->getHeight(); break;
2897 case GL_RENDERBUFFER_INTERNAL_FORMAT: *params = renderbuffer->getFormat(); break;
2898 case GL_RENDERBUFFER_RED_SIZE: *params = renderbuffer->getRedSize(); break;
2899 case GL_RENDERBUFFER_GREEN_SIZE: *params = renderbuffer->getGreenSize(); break;
2900 case GL_RENDERBUFFER_BLUE_SIZE: *params = renderbuffer->getBlueSize(); break;
2901 case GL_RENDERBUFFER_ALPHA_SIZE: *params = renderbuffer->getAlphaSize(); break;
2902 case GL_RENDERBUFFER_DEPTH_SIZE: *params = renderbuffer->getDepthSize(); break;
2903 case GL_RENDERBUFFER_STENCIL_SIZE: *params = renderbuffer->getStencilSize(); break;
2904 case GL_RENDERBUFFER_SAMPLES_EXT: *params = renderbuffer->getSamples(); break;
2905 default:
2906 return error(GL_INVALID_ENUM);
2907 }
2908 }
2909 }
2910
glGetShaderiv(GLuint shader,GLenum pname,GLint * params)2911 void APIENTRY glGetShaderiv(GLuint shader, GLenum pname, GLint* params)
2912 {
2913 TRACE("(GLuint shader = %d, GLenum pname = %d, GLint* params = %p)", shader, pname, params);
2914
2915 gl::Context *context = gl::getContext();
2916
2917 if(context)
2918 {
2919 gl::Shader *shaderObject = context->getShader(shader);
2920
2921 if(!shaderObject)
2922 {
2923 return error(GL_INVALID_VALUE);
2924 }
2925
2926 switch(pname)
2927 {
2928 case GL_SHADER_TYPE:
2929 *params = shaderObject->getType();
2930 return;
2931 case GL_DELETE_STATUS:
2932 *params = shaderObject->isFlaggedForDeletion();
2933 return;
2934 case GL_COMPILE_STATUS:
2935 *params = shaderObject->isCompiled() ? GL_TRUE : GL_FALSE;
2936 return;
2937 case GL_INFO_LOG_LENGTH:
2938 *params = shaderObject->getInfoLogLength();
2939 return;
2940 case GL_SHADER_SOURCE_LENGTH:
2941 *params = shaderObject->getSourceLength();
2942 return;
2943 default:
2944 return error(GL_INVALID_ENUM);
2945 }
2946 }
2947 }
2948
glGetShaderInfoLog(GLuint shader,GLsizei bufsize,GLsizei * length,GLchar * infolog)2949 void APIENTRY glGetShaderInfoLog(GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* infolog)
2950 {
2951 TRACE("(GLuint shader = %d, GLsizei bufsize = %d, GLsizei* length = %p, GLchar* infolog = %p)",
2952 shader, bufsize, length, infolog);
2953
2954 if(bufsize < 0)
2955 {
2956 return error(GL_INVALID_VALUE);
2957 }
2958
2959 gl::Context *context = gl::getContext();
2960
2961 if(context)
2962 {
2963 gl::Shader *shaderObject = context->getShader(shader);
2964
2965 if(!shaderObject)
2966 {
2967 return error(GL_INVALID_VALUE);
2968 }
2969
2970 shaderObject->getInfoLog(bufsize, length, infolog);
2971 }
2972 }
2973
glGetShaderPrecisionFormat(GLenum shadertype,GLenum precisiontype,GLint * range,GLint * precision)2974 void APIENTRY glGetShaderPrecisionFormat(GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision)
2975 {
2976 TRACE("(GLenum shadertype = 0x%X, GLenum precisiontype = 0x%X, GLint* range = %p, GLint* precision = %p)",
2977 shadertype, precisiontype, range, precision);
2978
2979 switch(shadertype)
2980 {
2981 case GL_VERTEX_SHADER:
2982 case GL_FRAGMENT_SHADER:
2983 break;
2984 default:
2985 return error(GL_INVALID_ENUM);
2986 }
2987
2988 switch(precisiontype)
2989 {
2990 case GL_LOW_FLOAT:
2991 case GL_MEDIUM_FLOAT:
2992 case GL_HIGH_FLOAT:
2993 // IEEE 754 single-precision
2994 range[0] = 127;
2995 range[1] = 127;
2996 *precision = 23;
2997 break;
2998 case GL_LOW_INT:
2999 case GL_MEDIUM_INT:
3000 case GL_HIGH_INT:
3001 // Full integer precision is supported
3002 range[0] = 31;
3003 range[1] = 30;
3004 *precision = 0;
3005 break;
3006 default:
3007 return error(GL_INVALID_ENUM);
3008 }
3009 }
3010
glGetShaderSource(GLuint shader,GLsizei bufsize,GLsizei * length,GLchar * source)3011 void APIENTRY glGetShaderSource(GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* source)
3012 {
3013 TRACE("(GLuint shader = %d, GLsizei bufsize = %d, GLsizei* length = %p, GLchar* source = %p)",
3014 shader, bufsize, length, source);
3015
3016 if(bufsize < 0)
3017 {
3018 return error(GL_INVALID_VALUE);
3019 }
3020
3021 gl::Context *context = gl::getContext();
3022
3023 if(context)
3024 {
3025 gl::Shader *shaderObject = context->getShader(shader);
3026
3027 if(!shaderObject)
3028 {
3029 return error(GL_INVALID_OPERATION);
3030 }
3031
3032 shaderObject->getSource(bufsize, length, source);
3033 }
3034 }
3035
glGetString(GLenum name)3036 const GLubyte* APIENTRY glGetString(GLenum name)
3037 {
3038 TRACE("(GLenum name = 0x%X)", name);
3039
3040 switch(name)
3041 {
3042 case GL_VENDOR:
3043 return (GLubyte*)"Google Inc.";
3044 case GL_RENDERER:
3045 return (GLubyte*)"SwiftShader";
3046 case GL_VERSION:
3047 return (GLubyte*)"2.1 SwiftShader "VERSION_STRING;
3048 case GL_SHADING_LANGUAGE_VERSION:
3049 return (GLubyte*)"3.30 SwiftShader "VERSION_STRING;
3050 case GL_EXTENSIONS:
3051 // Keep list sorted in following order:
3052 // OES extensions
3053 // EXT extensions
3054 // Vendor extensions
3055 return (GLubyte*)
3056 "GL_ARB_framebuffer_object "
3057 "GL_EXT_blend_minmax "
3058 "GL_EXT_depth_texture "
3059 "GL_EXT_depth_texture_cube_map "
3060 "GL_EXT_element_index_uint "
3061 "GL_EXT_packed_depth_stencil "
3062 "GL_EXT_rgb8_rgba8 "
3063 "GL_EXT_standard_derivatives "
3064 "GL_EXT_texture_float "
3065 "GL_EXT_texture_float_linear "
3066 "GL_EXT_texture_half_float "
3067 "GL_EXT_texture_half_float_linear "
3068 "GL_EXT_texture_npot "
3069 "GL_EXT_occlusion_query_boolean "
3070 "GL_EXT_read_format_bgra "
3071 #if (S3TC_SUPPORT)
3072 "GL_EXT_texture_compression_dxt1 "
3073 #endif
3074 "GL_EXT_blend_func_separate "
3075 "GL_EXT_secondary_color "
3076 "GL_EXT_texture_filter_anisotropic "
3077 "GL_EXT_texture_format_BGRA8888 "
3078 "GL_EXT_framebuffer_blit "
3079 "GL_EXT_framebuffer_multisample "
3080 #if (S3TC_SUPPORT)
3081 "GL_EXT_texture_compression_dxt3 "
3082 "GL_EXT_texture_compression_dxt5 "
3083 #endif
3084 "GL_NV_fence";
3085 default:
3086 return error(GL_INVALID_ENUM, (GLubyte*)nullptr);
3087 }
3088
3089 return nullptr;
3090 }
3091
glGetTexParameterfv(GLenum target,GLenum pname,GLfloat * params)3092 void APIENTRY glGetTexParameterfv(GLenum target, GLenum pname, GLfloat* params)
3093 {
3094 TRACE("(GLenum target = 0x%X, GLenum pname = 0x%X, GLfloat* params = %p)", target, pname, params);
3095
3096 gl::Context *context = gl::getContext();
3097
3098 if(context)
3099 {
3100 gl::Texture *texture;
3101
3102 switch(target)
3103 {
3104 case GL_TEXTURE_2D:
3105 texture = context->getTexture2D(target);
3106 break;
3107 case GL_TEXTURE_CUBE_MAP:
3108 texture = context->getTextureCubeMap();
3109 break;
3110 default:
3111 return error(GL_INVALID_ENUM);
3112 }
3113
3114 switch(pname)
3115 {
3116 case GL_TEXTURE_MAG_FILTER:
3117 *params = (GLfloat)texture->getMagFilter();
3118 break;
3119 case GL_TEXTURE_MIN_FILTER:
3120 *params = (GLfloat)texture->getMinFilter();
3121 break;
3122 case GL_TEXTURE_WRAP_S:
3123 *params = (GLfloat)texture->getWrapS();
3124 break;
3125 case GL_TEXTURE_WRAP_T:
3126 *params = (GLfloat)texture->getWrapT();
3127 break;
3128 case GL_TEXTURE_MAX_ANISOTROPY_EXT:
3129 *params = texture->getMaxAnisotropy();
3130 break;
3131 default:
3132 return error(GL_INVALID_ENUM);
3133 }
3134 }
3135 }
3136
glGetTexParameteriv(GLenum target,GLenum pname,GLint * params)3137 void APIENTRY glGetTexParameteriv(GLenum target, GLenum pname, GLint* params)
3138 {
3139 TRACE("(GLenum target = 0x%X, GLenum pname = 0x%X, GLint* params = %p)", target, pname, params);
3140
3141 gl::Context *context = gl::getContext();
3142
3143 if(context)
3144 {
3145 gl::Texture *texture;
3146
3147 switch(target)
3148 {
3149 case GL_TEXTURE_2D:
3150 texture = context->getTexture2D(target);
3151 break;
3152 case GL_TEXTURE_CUBE_MAP:
3153 texture = context->getTextureCubeMap();
3154 break;
3155 default:
3156 return error(GL_INVALID_ENUM);
3157 }
3158
3159 switch(pname)
3160 {
3161 case GL_TEXTURE_MAG_FILTER:
3162 *params = texture->getMagFilter();
3163 break;
3164 case GL_TEXTURE_MIN_FILTER:
3165 *params = texture->getMinFilter();
3166 break;
3167 case GL_TEXTURE_WRAP_S:
3168 *params = texture->getWrapS();
3169 break;
3170 case GL_TEXTURE_WRAP_T:
3171 *params = texture->getWrapT();
3172 break;
3173 case GL_TEXTURE_MAX_ANISOTROPY_EXT:
3174 *params = (GLint)texture->getMaxAnisotropy();
3175 break;
3176 default:
3177 return error(GL_INVALID_ENUM);
3178 }
3179 }
3180 }
3181
glGetnUniformfvEXT(GLuint program,GLint location,GLsizei bufSize,GLfloat * params)3182 void APIENTRY glGetnUniformfvEXT(GLuint program, GLint location, GLsizei bufSize, GLfloat* params)
3183 {
3184 TRACE("(GLuint program = %d, GLint location = %d, GLsizei bufSize = %d, GLfloat* params = %p)",
3185 program, location, bufSize, params);
3186
3187 if(bufSize < 0)
3188 {
3189 return error(GL_INVALID_VALUE);
3190 }
3191
3192 gl::Context *context = gl::getContext();
3193
3194 if(context)
3195 {
3196 if(program == 0)
3197 {
3198 return error(GL_INVALID_VALUE);
3199 }
3200
3201 gl::Program *programObject = context->getProgram(program);
3202
3203 if(!programObject || !programObject->isLinked())
3204 {
3205 return error(GL_INVALID_OPERATION);
3206 }
3207
3208 if(!programObject->getUniformfv(location, &bufSize, params))
3209 {
3210 return error(GL_INVALID_OPERATION);
3211 }
3212 }
3213 }
3214
glGetUniformfv(GLuint program,GLint location,GLfloat * params)3215 void APIENTRY glGetUniformfv(GLuint program, GLint location, GLfloat* params)
3216 {
3217 TRACE("(GLuint program = %d, GLint location = %d, GLfloat* params = %p)", program, location, params);
3218
3219 gl::Context *context = gl::getContext();
3220
3221 if(context)
3222 {
3223 if(program == 0)
3224 {
3225 return error(GL_INVALID_VALUE);
3226 }
3227
3228 gl::Program *programObject = context->getProgram(program);
3229
3230 if(!programObject || !programObject->isLinked())
3231 {
3232 return error(GL_INVALID_OPERATION);
3233 }
3234
3235 if(!programObject->getUniformfv(location, nullptr, params))
3236 {
3237 return error(GL_INVALID_OPERATION);
3238 }
3239 }
3240 }
3241
glGetnUniformivEXT(GLuint program,GLint location,GLsizei bufSize,GLint * params)3242 void APIENTRY glGetnUniformivEXT(GLuint program, GLint location, GLsizei bufSize, GLint* params)
3243 {
3244 TRACE("(GLuint program = %d, GLint location = %d, GLsizei bufSize = %d, GLint* params = %p)",
3245 program, location, bufSize, params);
3246
3247 if(bufSize < 0)
3248 {
3249 return error(GL_INVALID_VALUE);
3250 }
3251
3252 gl::Context *context = gl::getContext();
3253
3254 if(context)
3255 {
3256 if(program == 0)
3257 {
3258 return error(GL_INVALID_VALUE);
3259 }
3260
3261 gl::Program *programObject = context->getProgram(program);
3262
3263 if(!programObject || !programObject->isLinked())
3264 {
3265 return error(GL_INVALID_OPERATION);
3266 }
3267
3268 if(!programObject)
3269 {
3270 return error(GL_INVALID_OPERATION);
3271 }
3272
3273 if(!programObject->getUniformiv(location, &bufSize, params))
3274 {
3275 return error(GL_INVALID_OPERATION);
3276 }
3277 }
3278 }
3279
glGetUniformiv(GLuint program,GLint location,GLint * params)3280 void APIENTRY glGetUniformiv(GLuint program, GLint location, GLint* params)
3281 {
3282 TRACE("(GLuint program = %d, GLint location = %d, GLint* params = %p)", program, location, params);
3283
3284 gl::Context *context = gl::getContext();
3285
3286 if(context)
3287 {
3288 if(program == 0)
3289 {
3290 return error(GL_INVALID_VALUE);
3291 }
3292
3293 gl::Program *programObject = context->getProgram(program);
3294
3295 if(!programObject || !programObject->isLinked())
3296 {
3297 return error(GL_INVALID_OPERATION);
3298 }
3299
3300 if(!programObject)
3301 {
3302 return error(GL_INVALID_OPERATION);
3303 }
3304
3305 if(!programObject->getUniformiv(location, nullptr, params))
3306 {
3307 return error(GL_INVALID_OPERATION);
3308 }
3309 }
3310 }
3311
glGetUniformLocation(GLuint program,const GLchar * name)3312 int APIENTRY glGetUniformLocation(GLuint program, const GLchar* name)
3313 {
3314 TRACE("(GLuint program = %d, const GLchar* name = %s)", program, name);
3315
3316 gl::Context *context = gl::getContext();
3317
3318 if(strstr(name, "gl_") == name)
3319 {
3320 return -1;
3321 }
3322
3323 if(context)
3324 {
3325 gl::Program *programObject = context->getProgram(program);
3326
3327 if(!programObject)
3328 {
3329 if(context->getShader(program))
3330 {
3331 return error(GL_INVALID_OPERATION, -1);
3332 }
3333 else
3334 {
3335 return error(GL_INVALID_VALUE, -1);
3336 }
3337 }
3338
3339 if(!programObject->isLinked())
3340 {
3341 return error(GL_INVALID_OPERATION, -1);
3342 }
3343
3344 return programObject->getUniformLocation(name);
3345 }
3346
3347 return -1;
3348 }
3349
glGetVertexAttribfv(GLuint index,GLenum pname,GLfloat * params)3350 void APIENTRY glGetVertexAttribfv(GLuint index, GLenum pname, GLfloat* params)
3351 {
3352 TRACE("(GLuint index = %d, GLenum pname = 0x%X, GLfloat* params = %p)", index, pname, params);
3353
3354 gl::Context *context = gl::getContext();
3355
3356 if(context)
3357 {
3358 if(index >= gl::MAX_VERTEX_ATTRIBS)
3359 {
3360 return error(GL_INVALID_VALUE);
3361 }
3362
3363 const gl::VertexAttribute &attribState = context->getVertexAttribState(index);
3364
3365 switch(pname)
3366 {
3367 case GL_VERTEX_ATTRIB_ARRAY_ENABLED:
3368 *params = (GLfloat)(attribState.mArrayEnabled ? GL_TRUE : GL_FALSE);
3369 break;
3370 case GL_VERTEX_ATTRIB_ARRAY_SIZE:
3371 *params = (GLfloat)attribState.mSize;
3372 break;
3373 case GL_VERTEX_ATTRIB_ARRAY_STRIDE:
3374 *params = (GLfloat)attribState.mStride;
3375 break;
3376 case GL_VERTEX_ATTRIB_ARRAY_TYPE:
3377 *params = (GLfloat)attribState.mType;
3378 break;
3379 case GL_VERTEX_ATTRIB_ARRAY_NORMALIZED:
3380 *params = (GLfloat)(attribState.mNormalized ? GL_TRUE : GL_FALSE);
3381 break;
3382 case GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING:
3383 *params = (GLfloat)attribState.mBoundBuffer.name();
3384 break;
3385 case GL_CURRENT_VERTEX_ATTRIB:
3386 for(int i = 0; i < 4; ++i)
3387 {
3388 params[i] = attribState.mCurrentValue[i];
3389 }
3390 break;
3391 default: return error(GL_INVALID_ENUM);
3392 }
3393 }
3394 }
3395
glGetVertexAttribiv(GLuint index,GLenum pname,GLint * params)3396 void APIENTRY glGetVertexAttribiv(GLuint index, GLenum pname, GLint* params)
3397 {
3398 TRACE("(GLuint index = %d, GLenum pname = 0x%X, GLint* params = %p)", index, pname, params);
3399
3400 gl::Context *context = gl::getContext();
3401
3402 if(context)
3403 {
3404 if(index >= gl::MAX_VERTEX_ATTRIBS)
3405 {
3406 return error(GL_INVALID_VALUE);
3407 }
3408
3409 const gl::VertexAttribute &attribState = context->getVertexAttribState(index);
3410
3411 switch(pname)
3412 {
3413 case GL_VERTEX_ATTRIB_ARRAY_ENABLED:
3414 *params = (attribState.mArrayEnabled ? GL_TRUE : GL_FALSE);
3415 break;
3416 case GL_VERTEX_ATTRIB_ARRAY_SIZE:
3417 *params = attribState.mSize;
3418 break;
3419 case GL_VERTEX_ATTRIB_ARRAY_STRIDE:
3420 *params = attribState.mStride;
3421 break;
3422 case GL_VERTEX_ATTRIB_ARRAY_TYPE:
3423 *params = attribState.mType;
3424 break;
3425 case GL_VERTEX_ATTRIB_ARRAY_NORMALIZED:
3426 *params = (attribState.mNormalized ? GL_TRUE : GL_FALSE);
3427 break;
3428 case GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING:
3429 *params = attribState.mBoundBuffer.name();
3430 break;
3431 case GL_CURRENT_VERTEX_ATTRIB:
3432 for(int i = 0; i < 4; ++i)
3433 {
3434 float currentValue = attribState.mCurrentValue[i];
3435 params[i] = (GLint)(currentValue > 0.0f ? floor(currentValue + 0.5f) : ceil(currentValue - 0.5f));
3436 }
3437 break;
3438 default: return error(GL_INVALID_ENUM);
3439 }
3440 }
3441 }
3442
glGetVertexAttribPointerv(GLuint index,GLenum pname,GLvoid ** pointer)3443 void APIENTRY glGetVertexAttribPointerv(GLuint index, GLenum pname, GLvoid** pointer)
3444 {
3445 TRACE("(GLuint index = %d, GLenum pname = 0x%X, GLvoid** pointer = %p)", index, pname, pointer);
3446
3447 gl::Context *context = gl::getContext();
3448
3449 if(context)
3450 {
3451 if(index >= gl::MAX_VERTEX_ATTRIBS)
3452 {
3453 return error(GL_INVALID_VALUE);
3454 }
3455
3456 if(pname != GL_VERTEX_ATTRIB_ARRAY_POINTER)
3457 {
3458 return error(GL_INVALID_ENUM);
3459 }
3460
3461 *pointer = const_cast<GLvoid*>(context->getVertexAttribPointer(index));
3462 }
3463 }
3464
glHint(GLenum target,GLenum mode)3465 void APIENTRY glHint(GLenum target, GLenum mode)
3466 {
3467 TRACE("(GLenum target = 0x%X, GLenum mode = 0x%X)", target, mode);
3468
3469 switch(mode)
3470 {
3471 case GL_FASTEST:
3472 case GL_NICEST:
3473 case GL_DONT_CARE:
3474 break;
3475 default:
3476 return error(GL_INVALID_ENUM);
3477 }
3478
3479 gl::Context *context = gl::getContext();
3480 switch(target)
3481 {
3482 case GL_GENERATE_MIPMAP_HINT:
3483 if(context) context->setGenerateMipmapHint(mode);
3484 break;
3485 case GL_FRAGMENT_SHADER_DERIVATIVE_HINT:
3486 if(context) context->setFragmentShaderDerivativeHint(mode);
3487 break;
3488 default:
3489 return error(GL_INVALID_ENUM);
3490 }
3491 }
3492
glIsBuffer(GLuint buffer)3493 GLboolean APIENTRY glIsBuffer(GLuint buffer)
3494 {
3495 TRACE("(GLuint buffer = %d)", buffer);
3496
3497 gl::Context *context = gl::getContext();
3498
3499 if(context && buffer)
3500 {
3501 gl::Buffer *bufferObject = context->getBuffer(buffer);
3502
3503 if(bufferObject)
3504 {
3505 return GL_TRUE;
3506 }
3507 }
3508
3509 return GL_FALSE;
3510 }
3511
glIsEnabled(GLenum cap)3512 GLboolean APIENTRY glIsEnabled(GLenum cap)
3513 {
3514 TRACE("(GLenum cap = 0x%X)", cap);
3515
3516 gl::Context *context = gl::getContext();
3517
3518 if(context)
3519 {
3520 switch(cap)
3521 {
3522 case GL_CULL_FACE: return context->isCullFaceEnabled();
3523 case GL_POLYGON_OFFSET_FILL: return context->isPolygonOffsetFillEnabled();
3524 case GL_SAMPLE_ALPHA_TO_COVERAGE: return context->isSampleAlphaToCoverageEnabled();
3525 case GL_SAMPLE_COVERAGE: return context->isSampleCoverageEnabled();
3526 case GL_SCISSOR_TEST: return context->isScissorTestEnabled();
3527 case GL_STENCIL_TEST: return context->isStencilTestEnabled();
3528 case GL_DEPTH_TEST: return context->isDepthTestEnabled();
3529 case GL_BLEND: return context->isBlendEnabled();
3530 case GL_DITHER: return context->isDitherEnabled();
3531 case GL_COLOR_LOGIC_OP: return context->isColorLogicOpEnabled();
3532 case GL_INDEX_LOGIC_OP: UNIMPLEMENTED();
3533 default:
3534 return error(GL_INVALID_ENUM, false);
3535 }
3536 }
3537
3538 return false;
3539 }
3540
glIsFenceNV(GLuint fence)3541 GLboolean APIENTRY glIsFenceNV(GLuint fence)
3542 {
3543 TRACE("(GLuint fence = %d)", fence);
3544
3545 gl::Context *context = gl::getContext();
3546
3547 if(context)
3548 {
3549 gl::Fence *fenceObject = context->getFence(fence);
3550
3551 if(!fenceObject)
3552 {
3553 return GL_FALSE;
3554 }
3555
3556 return fenceObject->isFence();
3557 }
3558
3559 return GL_FALSE;
3560 }
3561
glIsFramebuffer(GLuint framebuffer)3562 GLboolean APIENTRY glIsFramebuffer(GLuint framebuffer)
3563 {
3564 TRACE("(GLuint framebuffer = %d)", framebuffer);
3565
3566 gl::Context *context = gl::getContext();
3567
3568 if(context && framebuffer)
3569 {
3570 gl::Framebuffer *framebufferObject = context->getFramebuffer(framebuffer);
3571
3572 if(framebufferObject)
3573 {
3574 return GL_TRUE;
3575 }
3576 }
3577
3578 return GL_FALSE;
3579 }
3580
glIsProgram(GLuint program)3581 GLboolean APIENTRY glIsProgram(GLuint program)
3582 {
3583 TRACE("(GLuint program = %d)", program);
3584
3585 gl::Context *context = gl::getContext();
3586
3587 if(context && program)
3588 {
3589 gl::Program *programObject = context->getProgram(program);
3590
3591 if(programObject)
3592 {
3593 return GL_TRUE;
3594 }
3595 }
3596
3597 return GL_FALSE;
3598 }
3599
glIsQueryEXT(GLuint name)3600 GLboolean APIENTRY glIsQueryEXT(GLuint name)
3601 {
3602 TRACE("(GLuint name = %d)", name);
3603
3604 if(name == 0)
3605 {
3606 return GL_FALSE;
3607 }
3608
3609 gl::Context *context = gl::getContext();
3610
3611 if(context)
3612 {
3613 gl::Query *queryObject = context->getQuery(name, false, GL_NONE);
3614
3615 if(queryObject)
3616 {
3617 return GL_TRUE;
3618 }
3619 }
3620
3621 return GL_FALSE;
3622 }
3623
glIsRenderbuffer(GLuint renderbuffer)3624 GLboolean APIENTRY glIsRenderbuffer(GLuint renderbuffer)
3625 {
3626 TRACE("(GLuint renderbuffer = %d)", renderbuffer);
3627
3628 gl::Context *context = gl::getContext();
3629
3630 if(context && renderbuffer)
3631 {
3632 gl::Renderbuffer *renderbufferObject = context->getRenderbuffer(renderbuffer);
3633
3634 if(renderbufferObject)
3635 {
3636 return GL_TRUE;
3637 }
3638 }
3639
3640 return GL_FALSE;
3641 }
3642
glIsShader(GLuint shader)3643 GLboolean APIENTRY glIsShader(GLuint shader)
3644 {
3645 TRACE("(GLuint shader = %d)", shader);
3646
3647 gl::Context *context = gl::getContext();
3648
3649 if(context && shader)
3650 {
3651 gl::Shader *shaderObject = context->getShader(shader);
3652
3653 if(shaderObject)
3654 {
3655 return GL_TRUE;
3656 }
3657 }
3658
3659 return GL_FALSE;
3660 }
3661
glIsTexture(GLuint texture)3662 GLboolean APIENTRY glIsTexture(GLuint texture)
3663 {
3664 TRACE("(GLuint texture = %d)", texture);
3665
3666 gl::Context *context = gl::getContext();
3667
3668 if(context && texture)
3669 {
3670 gl::Texture *textureObject = context->getTexture(texture);
3671
3672 if(textureObject)
3673 {
3674 return GL_TRUE;
3675 }
3676 }
3677
3678 return GL_FALSE;
3679 }
3680
glLineWidth(GLfloat width)3681 void APIENTRY glLineWidth(GLfloat width)
3682 {
3683 TRACE("(GLfloat width = %f)", width);
3684
3685 if(width <= 0.0f)
3686 {
3687 return error(GL_INVALID_VALUE);
3688 }
3689
3690 gl::Context *context = gl::getContext();
3691
3692 if(context)
3693 {
3694 if(context->getListIndex() != 0)
3695 {
3696 UNIMPLEMENTED();
3697 }
3698
3699 context->setLineWidth(width);
3700 }
3701 }
3702
glLinkProgram(GLuint program)3703 void APIENTRY glLinkProgram(GLuint program)
3704 {
3705 TRACE("(GLuint program = %d)", program);
3706
3707 gl::Context *context = gl::getContext();
3708
3709 if(context)
3710 {
3711 gl::Program *programObject = context->getProgram(program);
3712
3713 if(!programObject)
3714 {
3715 if(context->getShader(program))
3716 {
3717 return error(GL_INVALID_OPERATION);
3718 }
3719 else
3720 {
3721 return error(GL_INVALID_VALUE);
3722 }
3723 }
3724
3725 programObject->link();
3726 }
3727 }
3728
glPixelStorei(GLenum pname,GLint param)3729 void APIENTRY glPixelStorei(GLenum pname, GLint param)
3730 {
3731 TRACE("(GLenum pname = 0x%X, GLint param = %d)", pname, param);
3732
3733 gl::Context *context = gl::getContext();
3734
3735 if(context)
3736 {
3737 switch(pname)
3738 {
3739 case GL_UNPACK_ALIGNMENT:
3740 if(param != 1 && param != 2 && param != 4 && param != 8)
3741 {
3742 return error(GL_INVALID_VALUE);
3743 }
3744 context->setUnpackAlignment(param);
3745 break;
3746 case GL_PACK_ALIGNMENT:
3747 if(param != 1 && param != 2 && param != 4 && param != 8)
3748 {
3749 return error(GL_INVALID_VALUE);
3750 }
3751 context->setPackAlignment(param);
3752 break;
3753 default:
3754 return error(GL_INVALID_ENUM);
3755 }
3756 }
3757 }
3758
glPolygonOffset(GLfloat factor,GLfloat units)3759 void APIENTRY glPolygonOffset(GLfloat factor, GLfloat units)
3760 {
3761 TRACE("(GLfloat factor = %f, GLfloat units = %f)", factor, units);
3762
3763 gl::Context *context = gl::getContext();
3764
3765 if(context)
3766 {
3767 if(context->getListIndex() != 0)
3768 {
3769 UNIMPLEMENTED();
3770 }
3771
3772 context->setPolygonOffsetParams(factor, units);
3773 }
3774 }
3775
glReadnPixelsEXT(GLint x,GLint y,GLsizei width,GLsizei height,GLenum format,GLenum type,GLsizei bufSize,GLvoid * data)3776 void APIENTRY glReadnPixelsEXT(GLint x, GLint y, GLsizei width, GLsizei height,
3777 GLenum format, GLenum type, GLsizei bufSize, GLvoid *data)
3778 {
3779 TRACE("(GLint x = %d, GLint y = %d, GLsizei width = %d, GLsizei height = %d, "
3780 "GLenum format = 0x%X, GLenum type = 0x%X, GLsizei bufSize = 0x%d, GLvoid *data = %p)",
3781 x, y, width, height, format, type, bufSize, data);
3782
3783 if(width < 0 || height < 0 || bufSize < 0)
3784 {
3785 return error(GL_INVALID_VALUE);
3786 }
3787
3788 if(!validReadFormatType(format, type))
3789 {
3790 return error(GL_INVALID_OPERATION);
3791 }
3792
3793 gl::Context *context = gl::getContext();
3794
3795 if(context)
3796 {
3797 if(context->getListIndex() != 0)
3798 {
3799 UNIMPLEMENTED();
3800 }
3801
3802 context->readPixels(x, y, width, height, format, type, &bufSize, data);
3803 }
3804 }
3805
glReadPixels(GLint x,GLint y,GLsizei width,GLsizei height,GLenum format,GLenum type,GLvoid * pixels)3806 void APIENTRY glReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid* pixels)
3807 {
3808 TRACE("(GLint x = %d, GLint y = %d, GLsizei width = %d, GLsizei height = %d, "
3809 "GLenum format = 0x%X, GLenum type = 0x%X, GLvoid* pixels = %p)",
3810 x, y, width, height, format, type, pixels);
3811
3812 if(width < 0 || height < 0)
3813 {
3814 return error(GL_INVALID_VALUE);
3815 }
3816
3817 if(!validReadFormatType(format, type))
3818 {
3819 return error(GL_INVALID_OPERATION);
3820 }
3821
3822 gl::Context *context = gl::getContext();
3823
3824 if(context)
3825 {
3826 context->readPixels(x, y, width, height, format, type, nullptr, pixels);
3827 }
3828 }
3829
glReleaseShaderCompiler(void)3830 void APIENTRY glReleaseShaderCompiler(void)
3831 {
3832 TRACE("()");
3833
3834 gl::Shader::releaseCompiler();
3835 }
3836
glRenderbufferStorageMultisampleANGLE(GLenum target,GLsizei samples,GLenum internalformat,GLsizei width,GLsizei height)3837 void APIENTRY glRenderbufferStorageMultisampleANGLE(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height)
3838 {
3839 TRACE("(GLenum target = 0x%X, GLsizei samples = %d, GLenum internalformat = 0x%X, GLsizei width = %d, GLsizei height = %d)",
3840 target, samples, internalformat, width, height);
3841
3842 switch(target)
3843 {
3844 case GL_RENDERBUFFER:
3845 break;
3846 default:
3847 return error(GL_INVALID_ENUM);
3848 }
3849
3850 if(!gl::IsColorRenderable(internalformat) && !gl::IsDepthRenderable(internalformat) && !gl::IsStencilRenderable(internalformat))
3851 {
3852 return error(GL_INVALID_ENUM);
3853 }
3854
3855 if(width < 0 || height < 0 || samples < 0)
3856 {
3857 return error(GL_INVALID_VALUE);
3858 }
3859
3860 gl::Context *context = gl::getContext();
3861
3862 if(context)
3863 {
3864 if(context->getListIndex() != 0)
3865 {
3866 UNIMPLEMENTED();
3867 }
3868
3869 if(width > gl::IMPLEMENTATION_MAX_RENDERBUFFER_SIZE ||
3870 height > gl::IMPLEMENTATION_MAX_RENDERBUFFER_SIZE ||
3871 samples > gl::IMPLEMENTATION_MAX_SAMPLES)
3872 {
3873 return error(GL_INVALID_VALUE);
3874 }
3875
3876 GLuint handle = context->getRenderbufferName();
3877 if(handle == 0)
3878 {
3879 return error(GL_INVALID_OPERATION);
3880 }
3881
3882 switch(internalformat)
3883 {
3884 case GL_DEPTH_COMPONENT16:
3885 case GL_DEPTH_COMPONENT24:
3886 context->setRenderbufferStorage(new gl::Depthbuffer(width, height, samples));
3887 break;
3888 case GL_RGBA4:
3889 case GL_RGB5_A1:
3890 case GL_RGB565:
3891 case GL_RGB8_EXT:
3892 case GL_RGBA8_EXT:
3893 context->setRenderbufferStorage(new gl::Colorbuffer(width, height, internalformat, samples));
3894 break;
3895 case GL_STENCIL_INDEX8:
3896 context->setRenderbufferStorage(new gl::Stencilbuffer(width, height, samples));
3897 break;
3898 case GL_DEPTH24_STENCIL8_EXT:
3899 context->setRenderbufferStorage(new gl::DepthStencilbuffer(width, height, samples));
3900 break;
3901 default:
3902 return error(GL_INVALID_ENUM);
3903 }
3904 }
3905 }
3906
glRenderbufferStorage(GLenum target,GLenum internalformat,GLsizei width,GLsizei height)3907 void APIENTRY glRenderbufferStorage(GLenum target, GLenum internalformat, GLsizei width, GLsizei height)
3908 {
3909 glRenderbufferStorageMultisampleANGLE(target, 0, internalformat, width, height);
3910 }
3911
glSampleCoverage(GLclampf value,GLboolean invert)3912 void APIENTRY glSampleCoverage(GLclampf value, GLboolean invert)
3913 {
3914 TRACE("(GLclampf value = %f, GLboolean invert = %d)", value, invert);
3915
3916 gl::Context* context = gl::getContext();
3917
3918 if(context)
3919 {
3920 if(context->getListIndex() != 0)
3921 {
3922 UNIMPLEMENTED();
3923 }
3924
3925 context->setSampleCoverageParams(gl::clamp01(value), invert == GL_TRUE);
3926 }
3927 }
3928
glSetFenceNV(GLuint fence,GLenum condition)3929 void APIENTRY glSetFenceNV(GLuint fence, GLenum condition)
3930 {
3931 TRACE("(GLuint fence = %d, GLenum condition = 0x%X)", fence, condition);
3932
3933 if(condition != GL_ALL_COMPLETED_NV)
3934 {
3935 return error(GL_INVALID_ENUM);
3936 }
3937
3938 gl::Context *context = gl::getContext();
3939
3940 if(context)
3941 {
3942 if(context->getListIndex() != 0)
3943 {
3944 UNIMPLEMENTED();
3945 }
3946
3947 gl::Fence *fenceObject = context->getFence(fence);
3948
3949 if(!fenceObject)
3950 {
3951 return error(GL_INVALID_OPERATION);
3952 }
3953
3954 fenceObject->setFence(condition);
3955 }
3956 }
3957
glScissor(GLint x,GLint y,GLsizei width,GLsizei height)3958 void APIENTRY glScissor(GLint x, GLint y, GLsizei width, GLsizei height)
3959 {
3960 TRACE("(GLint x = %d, GLint y = %d, GLsizei width = %d, GLsizei height = %d)", x, y, width, height);
3961
3962 if(width < 0 || height < 0)
3963 {
3964 return error(GL_INVALID_VALUE);
3965 }
3966
3967 gl::Context* context = gl::getContext();
3968
3969 if(context)
3970 {
3971 if(context->getListIndex() != 0)
3972 {
3973 UNIMPLEMENTED();
3974 }
3975
3976 context->setScissorParams(x, y, width, height);
3977 }
3978 }
3979
glShaderBinary(GLsizei n,const GLuint * shaders,GLenum binaryformat,const GLvoid * binary,GLsizei length)3980 void APIENTRY glShaderBinary(GLsizei n, const GLuint* shaders, GLenum binaryformat, const GLvoid* binary, GLsizei length)
3981 {
3982 TRACE("(GLsizei n = %d, const GLuint* shaders = %p, GLenum binaryformat = 0x%X, "
3983 "const GLvoid* binary = %p, GLsizei length = %d)",
3984 n, shaders, binaryformat, binary, length);
3985
3986 // No binary shader formats are supported.
3987 return error(GL_INVALID_ENUM);
3988 }
3989
glShaderSource(GLuint shader,GLsizei count,const GLchar * const * string,const GLint * length)3990 void APIENTRY glShaderSource(GLuint shader, GLsizei count, const GLchar *const *string, const GLint *length)
3991 {
3992 TRACE("(GLuint shader = %d, GLsizei count = %d, const GLchar** string = %p, const GLint* length = %p)",
3993 shader, count, string, length);
3994
3995 if(count < 0)
3996 {
3997 return error(GL_INVALID_VALUE);
3998 }
3999
4000 gl::Context *context = gl::getContext();
4001
4002 if(context)
4003 {
4004 if(context->getListIndex() != 0)
4005 {
4006 UNIMPLEMENTED();
4007 }
4008
4009 gl::Shader *shaderObject = context->getShader(shader);
4010
4011 if(!shaderObject)
4012 {
4013 if(context->getProgram(shader))
4014 {
4015 return error(GL_INVALID_OPERATION);
4016 }
4017 else
4018 {
4019 return error(GL_INVALID_VALUE);
4020 }
4021 }
4022
4023 shaderObject->setSource(count, string, length);
4024 }
4025 }
4026
glStencilFunc(GLenum func,GLint ref,GLuint mask)4027 void APIENTRY glStencilFunc(GLenum func, GLint ref, GLuint mask)
4028 {
4029 glStencilFuncSeparate(GL_FRONT_AND_BACK, func, ref, mask);
4030 }
4031
glStencilFuncSeparate(GLenum face,GLenum func,GLint ref,GLuint mask)4032 void APIENTRY glStencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint mask)
4033 {
4034 TRACE("(GLenum face = 0x%X, GLenum func = 0x%X, GLint ref = %d, GLuint mask = %d)", face, func, ref, mask);
4035
4036 switch(face)
4037 {
4038 case GL_FRONT:
4039 case GL_BACK:
4040 case GL_FRONT_AND_BACK:
4041 break;
4042 default:
4043 return error(GL_INVALID_ENUM);
4044 }
4045
4046 switch(func)
4047 {
4048 case GL_NEVER:
4049 case GL_ALWAYS:
4050 case GL_LESS:
4051 case GL_LEQUAL:
4052 case GL_EQUAL:
4053 case GL_GEQUAL:
4054 case GL_GREATER:
4055 case GL_NOTEQUAL:
4056 break;
4057 default:
4058 return error(GL_INVALID_ENUM);
4059 }
4060
4061 gl::Context *context = gl::getContext();
4062
4063 if(context)
4064 {
4065 if(context->getListIndex() != 0)
4066 {
4067 UNIMPLEMENTED();
4068 }
4069
4070 if(face == GL_FRONT || face == GL_FRONT_AND_BACK)
4071 {
4072 context->setStencilParams(func, ref, mask);
4073 }
4074
4075 if(face == GL_BACK || face == GL_FRONT_AND_BACK)
4076 {
4077 context->setStencilBackParams(func, ref, mask);
4078 }
4079 }
4080 }
4081
glStencilMask(GLuint mask)4082 void APIENTRY glStencilMask(GLuint mask)
4083 {
4084 glStencilMaskSeparate(GL_FRONT_AND_BACK, mask);
4085 }
4086
glStencilMaskSeparate(GLenum face,GLuint mask)4087 void APIENTRY glStencilMaskSeparate(GLenum face, GLuint mask)
4088 {
4089 TRACE("(GLenum face = 0x%X, GLuint mask = %d)", face, mask);
4090
4091 switch(face)
4092 {
4093 case GL_FRONT:
4094 case GL_BACK:
4095 case GL_FRONT_AND_BACK:
4096 break;
4097 default:
4098 return error(GL_INVALID_ENUM);
4099 }
4100
4101 gl::Context *context = gl::getContext();
4102
4103 if(context)
4104 {
4105 if(context->getListIndex() != 0)
4106 {
4107 UNIMPLEMENTED();
4108 }
4109
4110 if(face == GL_FRONT || face == GL_FRONT_AND_BACK)
4111 {
4112 context->setStencilWritemask(mask);
4113 }
4114
4115 if(face == GL_BACK || face == GL_FRONT_AND_BACK)
4116 {
4117 context->setStencilBackWritemask(mask);
4118 }
4119 }
4120 }
4121
glStencilOp(GLenum fail,GLenum zfail,GLenum zpass)4122 void APIENTRY glStencilOp(GLenum fail, GLenum zfail, GLenum zpass)
4123 {
4124 glStencilOpSeparate(GL_FRONT_AND_BACK, fail, zfail, zpass);
4125 }
4126
glStencilOpSeparate(GLenum face,GLenum fail,GLenum zfail,GLenum zpass)4127 void APIENTRY glStencilOpSeparate(GLenum face, GLenum fail, GLenum zfail, GLenum zpass)
4128 {
4129 TRACE("(GLenum face = 0x%X, GLenum fail = 0x%X, GLenum zfail = 0x%X, GLenum zpas = 0x%Xs)",
4130 face, fail, zfail, zpass);
4131
4132 switch(face)
4133 {
4134 case GL_FRONT:
4135 case GL_BACK:
4136 case GL_FRONT_AND_BACK:
4137 break;
4138 default:
4139 return error(GL_INVALID_ENUM);
4140 }
4141
4142 switch(fail)
4143 {
4144 case GL_ZERO:
4145 case GL_KEEP:
4146 case GL_REPLACE:
4147 case GL_INCR:
4148 case GL_DECR:
4149 case GL_INVERT:
4150 case GL_INCR_WRAP:
4151 case GL_DECR_WRAP:
4152 break;
4153 default:
4154 return error(GL_INVALID_ENUM);
4155 }
4156
4157 switch(zfail)
4158 {
4159 case GL_ZERO:
4160 case GL_KEEP:
4161 case GL_REPLACE:
4162 case GL_INCR:
4163 case GL_DECR:
4164 case GL_INVERT:
4165 case GL_INCR_WRAP:
4166 case GL_DECR_WRAP:
4167 break;
4168 default:
4169 return error(GL_INVALID_ENUM);
4170 }
4171
4172 switch(zpass)
4173 {
4174 case GL_ZERO:
4175 case GL_KEEP:
4176 case GL_REPLACE:
4177 case GL_INCR:
4178 case GL_DECR:
4179 case GL_INVERT:
4180 case GL_INCR_WRAP:
4181 case GL_DECR_WRAP:
4182 break;
4183 default:
4184 return error(GL_INVALID_ENUM);
4185 }
4186
4187 gl::Context *context = gl::getContext();
4188
4189 if(context)
4190 {
4191 if(context->getListIndex() != 0)
4192 {
4193 UNIMPLEMENTED();
4194 }
4195
4196 if(face == GL_FRONT || face == GL_FRONT_AND_BACK)
4197 {
4198 context->setStencilOperations(fail, zfail, zpass);
4199 }
4200
4201 if(face == GL_BACK || face == GL_FRONT_AND_BACK)
4202 {
4203 context->setStencilBackOperations(fail, zfail, zpass);
4204 }
4205 }
4206 }
4207
glTestFenceNV(GLuint fence)4208 GLboolean APIENTRY glTestFenceNV(GLuint fence)
4209 {
4210 TRACE("(GLuint fence = %d)", fence);
4211
4212 gl::Context *context = gl::getContext();
4213
4214 if(context)
4215 {
4216 if(context->getListIndex() != 0)
4217 {
4218 UNIMPLEMENTED();
4219 }
4220
4221 gl::Fence *fenceObject = context->getFence(fence);
4222
4223 if(!fenceObject)
4224 {
4225 return error(GL_INVALID_OPERATION, GL_TRUE);
4226 }
4227
4228 return fenceObject->testFence();
4229 }
4230
4231 return GL_TRUE;
4232 }
4233
glTexImage2D(GLenum target,GLint level,GLint internalformat,GLsizei width,GLsizei height,GLint border,GLenum format,GLenum type,const GLvoid * pixels)4234 void APIENTRY glTexImage2D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height,
4235 GLint border, GLenum format, GLenum type, const GLvoid* pixels)
4236 {
4237 TRACE("(GLenum target = 0x%X, GLint level = %d, GLint internalformat = %d, GLsizei width = %d, GLsizei height = %d, "
4238 "GLint border = %d, GLenum format = 0x%X, GLenum type = 0x%X, const GLvoid* pixels = %p)",
4239 target, level, internalformat, width, height, border, format, type, pixels);
4240
4241 if(!validImageSize(level, width, height))
4242 {
4243 return error(GL_INVALID_VALUE);
4244 }
4245
4246 if(internalformat != (GLint)format)
4247 {
4248 //TRACE("UNIMPLEMENTED!!");
4249 //return error(GL_INVALID_OPERATION);
4250 }
4251
4252 switch(format)
4253 {
4254 case GL_ALPHA:
4255 case GL_LUMINANCE:
4256 case GL_LUMINANCE_ALPHA:
4257 switch(type)
4258 {
4259 case GL_UNSIGNED_BYTE:
4260 case GL_FLOAT:
4261 case GL_HALF_FLOAT:
4262 break;
4263 default:
4264 return error(GL_INVALID_ENUM);
4265 }
4266 break;
4267 case GL_RGB:
4268 switch(type)
4269 {
4270 case GL_UNSIGNED_BYTE:
4271 case GL_UNSIGNED_SHORT_5_6_5:
4272 case GL_FLOAT:
4273 case GL_HALF_FLOAT:
4274 break;
4275 default:
4276 return error(GL_INVALID_ENUM);
4277 }
4278 break;
4279 case GL_RGBA:
4280 switch(type)
4281 {
4282 case GL_UNSIGNED_BYTE:
4283 case GL_UNSIGNED_SHORT_4_4_4_4:
4284 case GL_UNSIGNED_SHORT_5_5_5_1:
4285 case GL_FLOAT:
4286 case GL_HALF_FLOAT:
4287 break;
4288 default:
4289 return error(GL_INVALID_ENUM);
4290 }
4291 break;
4292 case GL_BGRA_EXT:
4293 switch(type)
4294 {
4295 case GL_UNSIGNED_BYTE:
4296 case GL_UNSIGNED_SHORT_5_6_5:
4297 case GL_UNSIGNED_INT_8_8_8_8_REV:
4298 break;
4299 default:
4300 return error(GL_INVALID_ENUM);
4301 }
4302 break;
4303 case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: // error cases for compressed textures are handled below
4304 case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
4305 case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT:
4306 case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT:
4307 break;
4308 case GL_DEPTH_COMPONENT:
4309 switch(type)
4310 {
4311 case GL_UNSIGNED_SHORT:
4312 case GL_UNSIGNED_INT:
4313 break;
4314 default:
4315 return error(GL_INVALID_ENUM);
4316 }
4317 break;
4318 case GL_DEPTH_STENCIL_EXT:
4319 switch(type)
4320 {
4321 case GL_UNSIGNED_INT_24_8_EXT:
4322 break;
4323 default:
4324 return error(GL_INVALID_ENUM);
4325 }
4326 break;
4327 default:
4328 return error(GL_INVALID_VALUE);
4329 }
4330
4331 if(border != 0)
4332 {
4333 return error(GL_INVALID_VALUE);
4334 }
4335
4336 switch(target)
4337 {
4338 case GL_TEXTURE_2D:
4339 if(width > (gl::IMPLEMENTATION_MAX_TEXTURE_SIZE >> level) ||
4340 height > (gl::IMPLEMENTATION_MAX_TEXTURE_SIZE >> level))
4341 {
4342 return error(GL_INVALID_VALUE);
4343 }
4344 break;
4345 case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
4346 case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
4347 case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
4348 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
4349 case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
4350 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
4351 if(width != height)
4352 {
4353 return error(GL_INVALID_VALUE);
4354 }
4355
4356 if(width > (gl::IMPLEMENTATION_MAX_CUBE_MAP_TEXTURE_SIZE >> level) ||
4357 height > (gl::IMPLEMENTATION_MAX_CUBE_MAP_TEXTURE_SIZE >> level))
4358 {
4359 return error(GL_INVALID_VALUE);
4360 }
4361 break;
4362 case GL_PROXY_TEXTURE_2D:
4363 pixels = 0;
4364
4365 if(width > (gl::IMPLEMENTATION_MAX_TEXTURE_SIZE >> level) ||
4366 height > (gl::IMPLEMENTATION_MAX_TEXTURE_SIZE >> level))
4367 {
4368 //UNIMPLEMENTED();
4369 width = 0;
4370 height = 0;
4371 internalformat = GL_NONE;
4372 format = GL_NONE;
4373 type = GL_NONE;
4374
4375 //return;// error(GL_INVALID_VALUE);
4376 }
4377 break;
4378 default:
4379 return error(GL_INVALID_ENUM);
4380 }
4381
4382 if(format == GL_COMPRESSED_RGB_S3TC_DXT1_EXT ||
4383 format == GL_COMPRESSED_RGBA_S3TC_DXT1_EXT ||
4384 format == GL_COMPRESSED_RGBA_S3TC_DXT3_EXT ||
4385 format == GL_COMPRESSED_RGBA_S3TC_DXT5_EXT)
4386 {
4387 if(S3TC_SUPPORT)
4388 {
4389 return error(GL_INVALID_OPERATION);
4390 }
4391 else
4392 {
4393 return error(GL_INVALID_ENUM);
4394 }
4395 }
4396
4397 gl::Context *context = gl::getContext();
4398
4399 if(context)
4400 {
4401 if(context->getListIndex() != 0)
4402 {
4403 UNIMPLEMENTED();
4404 }
4405
4406 if(target == GL_TEXTURE_2D || target == GL_PROXY_TEXTURE_2D)
4407 {
4408 gl::Texture2D *texture = context->getTexture2D(target);
4409
4410 if(!texture)
4411 {
4412 return error(GL_INVALID_OPERATION);
4413 }
4414
4415 texture->setImage(level, width, height, format, type, context->getUnpackAlignment(), pixels);
4416 }
4417 else
4418 {
4419 gl::TextureCubeMap *texture = context->getTextureCubeMap();
4420
4421 if(!texture)
4422 {
4423 return error(GL_INVALID_OPERATION);
4424 }
4425
4426 texture->setImage(target, level, width, height, format, type, context->getUnpackAlignment(), pixels);
4427 }
4428 }
4429 }
4430
glTexParameterf(GLenum target,GLenum pname,GLfloat param)4431 void APIENTRY glTexParameterf(GLenum target, GLenum pname, GLfloat param)
4432 {
4433 TRACE("(GLenum target = 0x%X, GLenum pname = 0x%X, GLfloat param = %f)", target, pname, param);
4434
4435 gl::Context *context = gl::getContext();
4436
4437 if(context)
4438 {
4439 if(context->getListIndex() != 0)
4440 {
4441 UNIMPLEMENTED();
4442 }
4443
4444 gl::Texture *texture;
4445
4446 switch(target)
4447 {
4448 case GL_TEXTURE_2D:
4449 texture = context->getTexture2D(target);
4450 break;
4451 case GL_TEXTURE_CUBE_MAP:
4452 texture = context->getTextureCubeMap();
4453 break;
4454 default:
4455 return error(GL_INVALID_ENUM);
4456 }
4457
4458 switch(pname)
4459 {
4460 case GL_TEXTURE_WRAP_S:
4461 if(!texture->setWrapS((GLenum)param))
4462 {
4463 return error(GL_INVALID_ENUM);
4464 }
4465 break;
4466 case GL_TEXTURE_WRAP_T:
4467 if(!texture->setWrapT((GLenum)param))
4468 {
4469 return error(GL_INVALID_ENUM);
4470 }
4471 break;
4472 case GL_TEXTURE_MIN_FILTER:
4473 if(!texture->setMinFilter((GLenum)param))
4474 {
4475 return error(GL_INVALID_ENUM);
4476 }
4477 break;
4478 case GL_TEXTURE_MAG_FILTER:
4479 if(!texture->setMagFilter((GLenum)param))
4480 {
4481 return error(GL_INVALID_ENUM);
4482 }
4483 break;
4484 case GL_TEXTURE_MAX_ANISOTROPY_EXT:
4485 if(!texture->setMaxAnisotropy(param))
4486 {
4487 return error(GL_INVALID_VALUE);
4488 }
4489 break;
4490 case GL_TEXTURE_MIN_LOD:
4491 //TRACE("() UNIMPLEMENTED!!"); // FIXME
4492 //UNIMPLEMENTED();
4493 break;
4494 case GL_TEXTURE_MAX_LOD:
4495 //TRACE("() UNIMPLEMENTED!!"); // FIXME
4496 //UNIMPLEMENTED();
4497 break;
4498 case GL_TEXTURE_LOD_BIAS:
4499 if(param != 0.0f)
4500 {
4501 UNIMPLEMENTED();
4502 }
4503 break;
4504 default:
4505 return error(GL_INVALID_ENUM);
4506 }
4507 }
4508 }
4509
glTexParameterfv(GLenum target,GLenum pname,const GLfloat * params)4510 void APIENTRY glTexParameterfv(GLenum target, GLenum pname, const GLfloat* params)
4511 {
4512 glTexParameterf(target, pname, *params);
4513 }
4514
glTexParameteri(GLenum target,GLenum pname,GLint param)4515 void APIENTRY glTexParameteri(GLenum target, GLenum pname, GLint param)
4516 {
4517 TRACE("(GLenum target = 0x%X, GLenum pname = 0x%X, GLint param = %d)", target, pname, param);
4518
4519 gl::Context *context = gl::getContext();
4520
4521 if(context)
4522 {
4523 if(context->getListIndex() != 0)
4524 {
4525 UNIMPLEMENTED();
4526 }
4527
4528 gl::Texture *texture;
4529
4530 switch(target)
4531 {
4532 case GL_TEXTURE_2D:
4533 texture = context->getTexture2D(target);
4534 break;
4535 case GL_TEXTURE_CUBE_MAP:
4536 texture = context->getTextureCubeMap();
4537 break;
4538 default:
4539 return error(GL_INVALID_ENUM);
4540 }
4541
4542 switch(pname)
4543 {
4544 case GL_TEXTURE_WRAP_S:
4545 if(!texture->setWrapS((GLenum)param))
4546 {
4547 return error(GL_INVALID_ENUM);
4548 }
4549 break;
4550 case GL_TEXTURE_WRAP_T:
4551 if(!texture->setWrapT((GLenum)param))
4552 {
4553 return error(GL_INVALID_ENUM);
4554 }
4555 break;
4556 case GL_TEXTURE_MIN_FILTER:
4557 if(!texture->setMinFilter((GLenum)param))
4558 {
4559 return error(GL_INVALID_ENUM);
4560 }
4561 break;
4562 case GL_TEXTURE_MAG_FILTER:
4563 if(!texture->setMagFilter((GLenum)param))
4564 {
4565 return error(GL_INVALID_ENUM);
4566 }
4567 break;
4568 case GL_TEXTURE_MAX_ANISOTROPY_EXT:
4569 if(!texture->setMaxAnisotropy((GLfloat)param))
4570 {
4571 return error(GL_INVALID_VALUE);
4572 }
4573 break;
4574 case GL_TEXTURE_MAX_LEVEL:
4575 if(!texture->setMaxLevel(param))
4576 {
4577 return error(GL_INVALID_ENUM);
4578 }
4579 break;
4580 default:
4581 return error(GL_INVALID_ENUM);
4582 }
4583 }
4584 }
4585
glTexParameteriv(GLenum target,GLenum pname,const GLint * params)4586 void APIENTRY glTexParameteriv(GLenum target, GLenum pname, const GLint* params)
4587 {
4588 glTexParameteri(target, pname, *params);
4589 }
4590
glTexSubImage2D(GLenum target,GLint level,GLint xoffset,GLint yoffset,GLsizei width,GLsizei height,GLenum format,GLenum type,const GLvoid * pixels)4591 void APIENTRY glTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height,
4592 GLenum format, GLenum type, const GLvoid* pixels)
4593 {
4594 TRACE("(GLenum target = 0x%X, GLint level = %d, GLint xoffset = %d, GLint yoffset = %d, "
4595 "GLsizei width = %d, GLsizei height = %d, GLenum format = 0x%X, GLenum type = 0x%X, "
4596 "const GLvoid* pixels = %p)",
4597 target, level, xoffset, yoffset, width, height, format, type, pixels);
4598
4599 if(!gl::IsTextureTarget(target))
4600 {
4601 return error(GL_INVALID_ENUM);
4602 }
4603
4604 if(level < 0 || xoffset < 0 || yoffset < 0 || width < 0 || height < 0)
4605 {
4606 return error(GL_INVALID_VALUE);
4607 }
4608
4609 if(std::numeric_limits<GLsizei>::max() - xoffset < width || std::numeric_limits<GLsizei>::max() - yoffset < height)
4610 {
4611 return error(GL_INVALID_VALUE);
4612 }
4613
4614 if(!gl::CheckTextureFormatType(format, type))
4615 {
4616 return error(GL_INVALID_ENUM);
4617 }
4618
4619 if(width == 0 || height == 0 || !pixels)
4620 {
4621 return;
4622 }
4623
4624 gl::Context *context = gl::getContext();
4625
4626 if(context)
4627 {
4628 if(context->getListIndex() != 0)
4629 {
4630 UNIMPLEMENTED();
4631 }
4632
4633 if(level > gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS)
4634 {
4635 return error(GL_INVALID_VALUE);
4636 }
4637
4638 if(target == GL_TEXTURE_2D)
4639 {
4640 gl::Texture2D *texture = context->getTexture2D(target);
4641
4642 if(validateSubImageParams(false, width, height, xoffset, yoffset, target, level, format, texture))
4643 {
4644 texture->subImage(level, xoffset, yoffset, width, height, format, type, context->getUnpackAlignment(), pixels);
4645 }
4646 }
4647 else if(gl::IsCubemapTextureTarget(target))
4648 {
4649 gl::TextureCubeMap *texture = context->getTextureCubeMap();
4650
4651 if(validateSubImageParams(false, width, height, xoffset, yoffset, target, level, format, texture))
4652 {
4653 texture->subImage(target, level, xoffset, yoffset, width, height, format, type, context->getUnpackAlignment(), pixels);
4654 }
4655 }
4656 else UNREACHABLE(target);
4657 }
4658 }
4659
glUniform1f(GLint location,GLfloat x)4660 void APIENTRY glUniform1f(GLint location, GLfloat x)
4661 {
4662 glUniform1fv(location, 1, &x);
4663 }
4664
glUniform1fv(GLint location,GLsizei count,const GLfloat * v)4665 void APIENTRY glUniform1fv(GLint location, GLsizei count, const GLfloat* v)
4666 {
4667 TRACE("(GLint location = %d, GLsizei count = %d, const GLfloat* v = %p)", location, count, v);
4668
4669 if(count < 0)
4670 {
4671 return error(GL_INVALID_VALUE);
4672 }
4673
4674 if(location == -1)
4675 {
4676 return;
4677 }
4678
4679 gl::Context *context = gl::getContext();
4680
4681 if(context)
4682 {
4683 if(context->getListIndex() != 0)
4684 {
4685 UNIMPLEMENTED();
4686 }
4687
4688 gl::Program *program = context->getCurrentProgram();
4689
4690 if(!program)
4691 {
4692 return error(GL_INVALID_OPERATION);
4693 }
4694
4695 if(!program->setUniform1fv(location, count, v))
4696 {
4697 return error(GL_INVALID_OPERATION);
4698 }
4699 }
4700 }
4701
glUniform1i(GLint location,GLint x)4702 void APIENTRY glUniform1i(GLint location, GLint x)
4703 {
4704 glUniform1iv(location, 1, &x);
4705 }
4706
glUniform1iv(GLint location,GLsizei count,const GLint * v)4707 void APIENTRY glUniform1iv(GLint location, GLsizei count, const GLint* v)
4708 {
4709 TRACE("(GLint location = %d, GLsizei count = %d, const GLint* v = %p)", location, count, v);
4710
4711 if(count < 0)
4712 {
4713 return error(GL_INVALID_VALUE);
4714 }
4715
4716 if(location == -1)
4717 {
4718 return;
4719 }
4720
4721 gl::Context *context = gl::getContext();
4722
4723 if(context)
4724 {
4725 if(context->getListIndex() != 0)
4726 {
4727 UNIMPLEMENTED();
4728 }
4729
4730 gl::Program *program = context->getCurrentProgram();
4731
4732 if(!program)
4733 {
4734 return error(GL_INVALID_OPERATION);
4735 }
4736
4737 if(!program->setUniform1iv(location, count, v))
4738 {
4739 return error(GL_INVALID_OPERATION);
4740 }
4741 }
4742 }
4743
glUniform2f(GLint location,GLfloat x,GLfloat y)4744 void APIENTRY glUniform2f(GLint location, GLfloat x, GLfloat y)
4745 {
4746 GLfloat xy[2] = {x, y};
4747
4748 glUniform2fv(location, 1, (GLfloat*)&xy);
4749 }
4750
glUniform2fv(GLint location,GLsizei count,const GLfloat * v)4751 void APIENTRY glUniform2fv(GLint location, GLsizei count, const GLfloat* v)
4752 {
4753 TRACE("(GLint location = %d, GLsizei count = %d, const GLfloat* v = %p)", location, count, v);
4754
4755 if(count < 0)
4756 {
4757 return error(GL_INVALID_VALUE);
4758 }
4759
4760 if(location == -1)
4761 {
4762 return;
4763 }
4764
4765 gl::Context *context = gl::getContext();
4766
4767 if(context)
4768 {
4769 if(context->getListIndex() != 0)
4770 {
4771 UNIMPLEMENTED();
4772 }
4773
4774 gl::Program *program = context->getCurrentProgram();
4775
4776 if(!program)
4777 {
4778 return error(GL_INVALID_OPERATION);
4779 }
4780
4781 if(!program->setUniform2fv(location, count, v))
4782 {
4783 return error(GL_INVALID_OPERATION);
4784 }
4785 }
4786 }
4787
glUniform2i(GLint location,GLint x,GLint y)4788 void APIENTRY glUniform2i(GLint location, GLint x, GLint y)
4789 {
4790 GLint xy[4] = {x, y};
4791
4792 glUniform2iv(location, 1, (GLint*)&xy);
4793 }
4794
glUniform2iv(GLint location,GLsizei count,const GLint * v)4795 void APIENTRY glUniform2iv(GLint location, GLsizei count, const GLint* v)
4796 {
4797 TRACE("(GLint location = %d, GLsizei count = %d, const GLint* v = %p)", location, count, v);
4798
4799 if(count < 0)
4800 {
4801 return error(GL_INVALID_VALUE);
4802 }
4803
4804 if(location == -1)
4805 {
4806 return;
4807 }
4808
4809 gl::Context *context = gl::getContext();
4810
4811 if(context)
4812 {
4813 if(context->getListIndex() != 0)
4814 {
4815 UNIMPLEMENTED();
4816 }
4817
4818 gl::Program *program = context->getCurrentProgram();
4819
4820 if(!program)
4821 {
4822 return error(GL_INVALID_OPERATION);
4823 }
4824
4825 if(!program->setUniform2iv(location, count, v))
4826 {
4827 return error(GL_INVALID_OPERATION);
4828 }
4829 }
4830 }
4831
glUniform3f(GLint location,GLfloat x,GLfloat y,GLfloat z)4832 void APIENTRY glUniform3f(GLint location, GLfloat x, GLfloat y, GLfloat z)
4833 {
4834 GLfloat xyz[3] = {x, y, z};
4835
4836 glUniform3fv(location, 1, (GLfloat*)&xyz);
4837 }
4838
glUniform3fv(GLint location,GLsizei count,const GLfloat * v)4839 void APIENTRY glUniform3fv(GLint location, GLsizei count, const GLfloat* v)
4840 {
4841 TRACE("(GLint location = %d, GLsizei count = %d, const GLfloat* v = %p)", location, count, v);
4842
4843 if(count < 0)
4844 {
4845 return error(GL_INVALID_VALUE);
4846 }
4847
4848 if(location == -1)
4849 {
4850 return;
4851 }
4852
4853 gl::Context *context = gl::getContext();
4854
4855 if(context)
4856 {
4857 if(context->getListIndex() != 0)
4858 {
4859 UNIMPLEMENTED();
4860 }
4861
4862 gl::Program *program = context->getCurrentProgram();
4863
4864 if(!program)
4865 {
4866 return error(GL_INVALID_OPERATION);
4867 }
4868
4869 if(!program->setUniform3fv(location, count, v))
4870 {
4871 return error(GL_INVALID_OPERATION);
4872 }
4873 }
4874 }
4875
glUniform3i(GLint location,GLint x,GLint y,GLint z)4876 void APIENTRY glUniform3i(GLint location, GLint x, GLint y, GLint z)
4877 {
4878 GLint xyz[3] = {x, y, z};
4879
4880 glUniform3iv(location, 1, (GLint*)&xyz);
4881 }
4882
glUniform3iv(GLint location,GLsizei count,const GLint * v)4883 void APIENTRY glUniform3iv(GLint location, GLsizei count, const GLint* v)
4884 {
4885 TRACE("(GLint location = %d, GLsizei count = %d, const GLint* v = %p)", location, count, v);
4886
4887 if(count < 0)
4888 {
4889 return error(GL_INVALID_VALUE);
4890 }
4891
4892 if(location == -1)
4893 {
4894 return;
4895 }
4896
4897 gl::Context *context = gl::getContext();
4898
4899 if(context)
4900 {
4901 if(context->getListIndex() != 0)
4902 {
4903 UNIMPLEMENTED();
4904 }
4905
4906 gl::Program *program = context->getCurrentProgram();
4907
4908 if(!program)
4909 {
4910 return error(GL_INVALID_OPERATION);
4911 }
4912
4913 if(!program->setUniform3iv(location, count, v))
4914 {
4915 return error(GL_INVALID_OPERATION);
4916 }
4917 }
4918 }
4919
glUniform4f(GLint location,GLfloat x,GLfloat y,GLfloat z,GLfloat w)4920 void APIENTRY glUniform4f(GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
4921 {
4922 GLfloat xyzw[4] = {x, y, z, w};
4923
4924 glUniform4fv(location, 1, (GLfloat*)&xyzw);
4925 }
4926
glUniform4fv(GLint location,GLsizei count,const GLfloat * v)4927 void APIENTRY glUniform4fv(GLint location, GLsizei count, const GLfloat* v)
4928 {
4929 TRACE("(GLint location = %d, GLsizei count = %d, const GLfloat* v = %p)", location, count, v);
4930
4931 if(count < 0)
4932 {
4933 return error(GL_INVALID_VALUE);
4934 }
4935
4936 if(location == -1)
4937 {
4938 return;
4939 }
4940
4941 gl::Context *context = gl::getContext();
4942
4943 if(context)
4944 {
4945 if(context->getListIndex() != 0)
4946 {
4947 UNIMPLEMENTED();
4948 }
4949
4950 gl::Program *program = context->getCurrentProgram();
4951
4952 if(!program)
4953 {
4954 return error(GL_INVALID_OPERATION);
4955 }
4956
4957 if(!program->setUniform4fv(location, count, v))
4958 {
4959 return error(GL_INVALID_OPERATION);
4960 }
4961 }
4962 }
4963
glUniform4i(GLint location,GLint x,GLint y,GLint z,GLint w)4964 void APIENTRY glUniform4i(GLint location, GLint x, GLint y, GLint z, GLint w)
4965 {
4966 GLint xyzw[4] = {x, y, z, w};
4967
4968 glUniform4iv(location, 1, (GLint*)&xyzw);
4969 }
4970
glUniform4iv(GLint location,GLsizei count,const GLint * v)4971 void APIENTRY glUniform4iv(GLint location, GLsizei count, const GLint* v)
4972 {
4973 TRACE("(GLint location = %d, GLsizei count = %d, const GLint* v = %p)", location, count, v);
4974
4975 if(count < 0)
4976 {
4977 return error(GL_INVALID_VALUE);
4978 }
4979
4980 if(location == -1)
4981 {
4982 return;
4983 }
4984
4985 gl::Context *context = gl::getContext();
4986
4987 if(context)
4988 {
4989 if(context->getListIndex() != 0)
4990 {
4991 UNIMPLEMENTED();
4992 }
4993
4994 gl::Program *program = context->getCurrentProgram();
4995
4996 if(!program)
4997 {
4998 return error(GL_INVALID_OPERATION);
4999 }
5000
5001 if(!program->setUniform4iv(location, count, v))
5002 {
5003 return error(GL_INVALID_OPERATION);
5004 }
5005 }
5006 }
5007
glUniformMatrix2fv(GLint location,GLsizei count,GLboolean transpose,const GLfloat * value)5008 void APIENTRY glUniformMatrix2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
5009 {
5010 TRACE("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %d, const GLfloat* value = %p)",
5011 location, count, transpose, value);
5012
5013 if(count < 0 || transpose != GL_FALSE)
5014 {
5015 return error(GL_INVALID_VALUE);
5016 }
5017
5018 if(location == -1)
5019 {
5020 return;
5021 }
5022
5023 gl::Context *context = gl::getContext();
5024
5025 if(context)
5026 {
5027 if(context->getListIndex() != 0)
5028 {
5029 UNIMPLEMENTED();
5030 }
5031
5032 gl::Program *program = context->getCurrentProgram();
5033
5034 if(!program)
5035 {
5036 return error(GL_INVALID_OPERATION);
5037 }
5038
5039 if(!program->setUniformMatrix2fv(location, count, value))
5040 {
5041 return error(GL_INVALID_OPERATION);
5042 }
5043 }
5044 }
5045
glUniformMatrix3fv(GLint location,GLsizei count,GLboolean transpose,const GLfloat * value)5046 void APIENTRY glUniformMatrix3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
5047 {
5048 TRACE("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %d, const GLfloat* value = %p)",
5049 location, count, transpose, value);
5050
5051 if(count < 0 || transpose != GL_FALSE)
5052 {
5053 return error(GL_INVALID_VALUE);
5054 }
5055
5056 if(location == -1)
5057 {
5058 return;
5059 }
5060
5061 gl::Context *context = gl::getContext();
5062
5063 if(context)
5064 {
5065 if(context->getListIndex() != 0)
5066 {
5067 UNIMPLEMENTED();
5068 }
5069
5070 gl::Program *program = context->getCurrentProgram();
5071
5072 if(!program)
5073 {
5074 return error(GL_INVALID_OPERATION);
5075 }
5076
5077 if(!program->setUniformMatrix3fv(location, count, value))
5078 {
5079 return error(GL_INVALID_OPERATION);
5080 }
5081 }
5082 }
5083
glUniformMatrix4fv(GLint location,GLsizei count,GLboolean transpose,const GLfloat * value)5084 void APIENTRY glUniformMatrix4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
5085 {
5086 TRACE("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %d, const GLfloat* value = %p)",
5087 location, count, transpose, value);
5088
5089 if(count < 0 || transpose != GL_FALSE)
5090 {
5091 return error(GL_INVALID_VALUE);
5092 }
5093
5094 if(location == -1)
5095 {
5096 return;
5097 }
5098
5099 gl::Context *context = gl::getContext();
5100
5101 if(context)
5102 {
5103 if(context->getListIndex() != 0)
5104 {
5105 UNIMPLEMENTED();
5106 }
5107
5108 gl::Program *program = context->getCurrentProgram();
5109
5110 if(!program)
5111 {
5112 return error(GL_INVALID_OPERATION);
5113 }
5114
5115 if(!program->setUniformMatrix4fv(location, count, value))
5116 {
5117 return error(GL_INVALID_OPERATION);
5118 }
5119 }
5120 }
5121
glUseProgram(GLuint program)5122 void APIENTRY glUseProgram(GLuint program)
5123 {
5124 TRACE("(GLuint program = %d)", program);
5125
5126 gl::Context *context = gl::getContext();
5127
5128 if(context)
5129 {
5130 if(context->getListIndex() != 0)
5131 {
5132 UNIMPLEMENTED();
5133 }
5134
5135 gl::Program *programObject = context->getProgram(program);
5136
5137 if(!programObject && program != 0)
5138 {
5139 if(context->getShader(program))
5140 {
5141 return error(GL_INVALID_OPERATION);
5142 }
5143 else
5144 {
5145 return error(GL_INVALID_VALUE);
5146 }
5147 }
5148
5149 if(program != 0 && !programObject->isLinked())
5150 {
5151 return error(GL_INVALID_OPERATION);
5152 }
5153
5154 context->useProgram(program);
5155 }
5156 }
5157
glValidateProgram(GLuint program)5158 void APIENTRY glValidateProgram(GLuint program)
5159 {
5160 TRACE("(GLuint program = %d)", program);
5161
5162 gl::Context *context = gl::getContext();
5163
5164 if(context)
5165 {
5166 gl::Program *programObject = context->getProgram(program);
5167
5168 if(!programObject)
5169 {
5170 if(context->getShader(program))
5171 {
5172 return error(GL_INVALID_OPERATION);
5173 }
5174 else
5175 {
5176 return error(GL_INVALID_VALUE);
5177 }
5178 }
5179
5180 programObject->validate();
5181 }
5182 }
5183
glVertexAttrib1f(GLuint index,GLfloat x)5184 void APIENTRY glVertexAttrib1f(GLuint index, GLfloat x)
5185 {
5186 TRACE("(GLuint index = %d, GLfloat x = %f)", index, x);
5187
5188 if(index >= gl::MAX_VERTEX_ATTRIBS)
5189 {
5190 return error(GL_INVALID_VALUE);
5191 }
5192
5193 gl::Context *context = gl::getContext();
5194
5195 if(context)
5196 {
5197 if(context->getListIndex() != 0)
5198 {
5199 UNIMPLEMENTED();
5200 }
5201
5202 //GLfloat vals[4] = { x, 0, 0, 1 };
5203 context->setVertexAttrib(index, x, 0, 0, 1);
5204 }
5205 }
5206
glVertexAttrib1fv(GLuint index,const GLfloat * values)5207 void APIENTRY glVertexAttrib1fv(GLuint index, const GLfloat* values)
5208 {
5209 TRACE("(GLuint index = %d, const GLfloat* values = %p)", index, values);
5210
5211 if(index >= gl::MAX_VERTEX_ATTRIBS)
5212 {
5213 return error(GL_INVALID_VALUE);
5214 }
5215
5216 gl::Context *context = gl::getContext();
5217
5218 if(context)
5219 {
5220 if(context->getListIndex() != 0)
5221 {
5222 UNIMPLEMENTED();
5223 }
5224
5225 //GLfloat vals[4] = { values[0], 0, 0, 1 };
5226 context->setVertexAttrib(index, values[0], 0, 0, 1);
5227 }
5228 }
5229
glVertexAttrib2f(GLuint index,GLfloat x,GLfloat y)5230 void APIENTRY glVertexAttrib2f(GLuint index, GLfloat x, GLfloat y)
5231 {
5232 TRACE("(GLuint index = %d, GLfloat x = %f, GLfloat y = %f)", index, x, y);
5233
5234 if(index >= gl::MAX_VERTEX_ATTRIBS)
5235 {
5236 return error(GL_INVALID_VALUE);
5237 }
5238
5239 gl::Context *context = gl::getContext();
5240
5241 if(context)
5242 {
5243 if(context->getListIndex() != 0)
5244 {
5245 UNIMPLEMENTED();
5246 }
5247
5248 //GLfloat vals[4] = { x, y, 0, 1 };
5249 context->setVertexAttrib(index, x, y, 0, 1);
5250 }
5251 }
5252
glVertexAttrib2fv(GLuint index,const GLfloat * values)5253 void APIENTRY glVertexAttrib2fv(GLuint index, const GLfloat* values)
5254 {
5255 TRACE("(GLuint index = %d, const GLfloat* values = %p)", index, values);
5256
5257 if(index >= gl::MAX_VERTEX_ATTRIBS)
5258 {
5259 return error(GL_INVALID_VALUE);
5260 }
5261
5262 gl::Context *context = gl::getContext();
5263
5264 if(context)
5265 {
5266 if(context->getListIndex() != 0)
5267 {
5268 UNIMPLEMENTED();
5269 }
5270
5271 //GLfloat vals[4] = { };
5272 context->setVertexAttrib(index, values[0], values[1], 0, 1);
5273 }
5274 }
5275
glVertexAttrib3f(GLuint index,GLfloat x,GLfloat y,GLfloat z)5276 void APIENTRY glVertexAttrib3f(GLuint index, GLfloat x, GLfloat y, GLfloat z)
5277 {
5278 TRACE("(GLuint index = %d, GLfloat x = %f, GLfloat y = %f, GLfloat z = %f)", index, x, y, z);
5279
5280 if(index >= gl::MAX_VERTEX_ATTRIBS)
5281 {
5282 return error(GL_INVALID_VALUE);
5283 }
5284
5285 gl::Context *context = gl::getContext();
5286
5287 if(context)
5288 {
5289 if(context->getListIndex() != 0)
5290 {
5291 UNIMPLEMENTED();
5292 }
5293
5294 //GLfloat vals[4] = { x, y, z, 1 };
5295 context->setVertexAttrib(index, x, y, z, 1);
5296 }
5297 }
5298
glVertexAttrib3fv(GLuint index,const GLfloat * values)5299 void APIENTRY glVertexAttrib3fv(GLuint index, const GLfloat* values)
5300 {
5301 TRACE("(GLuint index = %d, const GLfloat* values = %p)", index, values);
5302
5303 if(index >= gl::MAX_VERTEX_ATTRIBS)
5304 {
5305 return error(GL_INVALID_VALUE);
5306 }
5307
5308 gl::Context *context = gl::getContext();
5309
5310 if(context)
5311 {
5312 if(context->getListIndex() != 0)
5313 {
5314 UNIMPLEMENTED();
5315 }
5316
5317 //GLfloat vals[4] = { values[0], values[1], values[2], 1 };
5318 context->setVertexAttrib(index, values[0], values[1], values[2], 1);
5319 }
5320 }
5321
glVertexAttrib4f(GLuint index,GLfloat x,GLfloat y,GLfloat z,GLfloat w)5322 void APIENTRY glVertexAttrib4f(GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
5323 {
5324 TRACE("(GLuint index = %d, GLfloat x = %f, GLfloat y = %f, GLfloat z = %f, GLfloat w = %f)", index, x, y, z, w);
5325
5326 if(index >= gl::MAX_VERTEX_ATTRIBS)
5327 {
5328 return error(GL_INVALID_VALUE);
5329 }
5330
5331 gl::Context *context = gl::getContext();
5332
5333 if(context)
5334 {
5335 if(context->getListIndex() != 0)
5336 {
5337 UNIMPLEMENTED();
5338 }
5339
5340 //GLfloat vals[4] = { x, y, z, w };
5341 context->setVertexAttrib(index, x, y, z, w);
5342 }
5343 }
5344
glVertexAttrib4fv(GLuint index,const GLfloat * values)5345 void APIENTRY glVertexAttrib4fv(GLuint index, const GLfloat* values)
5346 {
5347 TRACE("(GLuint index = %d, const GLfloat* values = %p)", index, values);
5348
5349 if(index >= gl::MAX_VERTEX_ATTRIBS)
5350 {
5351 return error(GL_INVALID_VALUE);
5352 }
5353
5354 gl::Context *context = gl::getContext();
5355
5356 if(context)
5357 {
5358 if(context->getListIndex() != 0)
5359 {
5360 UNIMPLEMENTED();
5361 }
5362
5363 context->setVertexAttrib(index, values[0], values[1], values[2], values[3]);
5364 }
5365 }
5366
glVertexAttribPointer(GLuint index,GLint size,GLenum type,GLboolean normalized,GLsizei stride,const GLvoid * ptr)5367 void APIENTRY glVertexAttribPointer(GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid* ptr)
5368 {
5369 TRACE("(GLuint index = %d, GLint size = %d, GLenum type = 0x%X, "
5370 "GLboolean normalized = %d, GLsizei stride = %d, const GLvoid* ptr = %p)",
5371 index, size, type, normalized, stride, ptr);
5372
5373 if(index >= gl::MAX_VERTEX_ATTRIBS)
5374 {
5375 return error(GL_INVALID_VALUE);
5376 }
5377
5378 if(size < 1 || size > 4)
5379 {
5380 return error(GL_INVALID_VALUE);
5381 }
5382
5383 switch(type)
5384 {
5385 case GL_BYTE:
5386 case GL_UNSIGNED_BYTE:
5387 case GL_SHORT:
5388 case GL_UNSIGNED_SHORT:
5389 case GL_FIXED:
5390 case GL_FLOAT:
5391 break;
5392 default:
5393 return error(GL_INVALID_ENUM);
5394 }
5395
5396 if(stride < 0)
5397 {
5398 return error(GL_INVALID_VALUE);
5399 }
5400
5401 gl::Context *context = gl::getContext();
5402
5403 if(context)
5404 {
5405 context->setVertexAttribState(index, context->getArrayBuffer(), size, type, (normalized == GL_TRUE), stride, ptr);
5406 }
5407 }
5408
glViewport(GLint x,GLint y,GLsizei width,GLsizei height)5409 void APIENTRY glViewport(GLint x, GLint y, GLsizei width, GLsizei height)
5410 {
5411 TRACE("(GLint x = %d, GLint y = %d, GLsizei width = %d, GLsizei height = %d)", x, y, width, height);
5412
5413 if(width < 0 || height < 0)
5414 {
5415 return error(GL_INVALID_VALUE);
5416 }
5417
5418 gl::Context *context = gl::getContext();
5419
5420 if(context)
5421 {
5422 if(context->getListIndex() != 0)
5423 {
5424 UNIMPLEMENTED();
5425 }
5426
5427 context->setViewportParams(x, y, width, height);
5428 }
5429 }
5430
glBlitFramebufferANGLE(GLint srcX0,GLint srcY0,GLint srcX1,GLint srcY1,GLint dstX0,GLint dstY0,GLint dstX1,GLint dstY1,GLbitfield mask,GLenum filter)5431 void APIENTRY glBlitFramebufferANGLE(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1,
5432 GLbitfield mask, GLenum filter)
5433 {
5434 TRACE("(GLint srcX0 = %d, GLint srcY0 = %d, GLint srcX1 = %d, GLint srcY1 = %d, "
5435 "GLint dstX0 = %d, GLint dstY0 = %d, GLint dstX1 = %d, GLint dstY1 = %d, "
5436 "GLbitfield mask = 0x%X, GLenum filter = 0x%X)",
5437 srcX0, srcY0, srcX1, srcX1, dstX0, dstY0, dstX1, dstY1, mask, filter);
5438
5439 switch(filter)
5440 {
5441 case GL_NEAREST:
5442 break;
5443 default:
5444 return error(GL_INVALID_ENUM);
5445 }
5446
5447 if((mask & ~(GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)) != 0)
5448 {
5449 return error(GL_INVALID_VALUE);
5450 }
5451
5452 if(srcX1 - srcX0 != dstX1 - dstX0 || srcY1 - srcY0 != dstY1 - dstY0)
5453 {
5454 ERR("Scaling and flipping in BlitFramebufferANGLE not supported by this implementation");
5455 return error(GL_INVALID_OPERATION);
5456 }
5457
5458 gl::Context *context = gl::getContext();
5459
5460 if(context)
5461 {
5462 if(context->getListIndex() != 0)
5463 {
5464 UNIMPLEMENTED();
5465 }
5466
5467 if(context->getReadFramebufferName() == context->getDrawFramebufferName())
5468 {
5469 ERR("Blits with the same source and destination framebuffer are not supported by this implementation.");
5470 return error(GL_INVALID_OPERATION);
5471 }
5472
5473 context->blitFramebuffer(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask);
5474 }
5475 }
5476
glTexImage3DOES(GLenum target,GLint level,GLenum internalformat,GLsizei width,GLsizei height,GLsizei depth,GLint border,GLenum format,GLenum type,const GLvoid * pixels)5477 void APIENTRY glTexImage3DOES(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth,
5478 GLint border, GLenum format, GLenum type, const GLvoid* pixels)
5479 {
5480 TRACE("(GLenum target = 0x%X, GLint level = %d, GLenum internalformat = 0x%X, "
5481 "GLsizei width = %d, GLsizei height = %d, GLsizei depth = %d, GLint border = %d, "
5482 "GLenum format = 0x%X, GLenum type = 0x%x, const GLvoid* pixels = %p)",
5483 target, level, internalformat, width, height, depth, border, format, type, pixels);
5484
5485 UNIMPLEMENTED(); // FIXME
5486 }
5487
GlmfBeginGlsBlock()5488 void WINAPI GlmfBeginGlsBlock()
5489 {
5490 UNIMPLEMENTED();
5491 }
5492
GlmfCloseMetaFile()5493 void WINAPI GlmfCloseMetaFile()
5494 {
5495 UNIMPLEMENTED();
5496 }
5497
GlmfEndGlsBlock()5498 void WINAPI GlmfEndGlsBlock()
5499 {
5500 UNIMPLEMENTED();
5501 }
5502
GlmfEndPlayback()5503 void WINAPI GlmfEndPlayback()
5504 {
5505 UNIMPLEMENTED();
5506 }
5507
GlmfInitPlayback()5508 void WINAPI GlmfInitPlayback()
5509 {
5510 UNIMPLEMENTED();
5511 }
5512
GlmfPlayGlsRecord()5513 void WINAPI GlmfPlayGlsRecord()
5514 {
5515 UNIMPLEMENTED();
5516 }
5517
glAccum(GLenum op,GLfloat value)5518 void APIENTRY glAccum(GLenum op, GLfloat value)
5519 {
5520 UNIMPLEMENTED();
5521 }
5522
glAlphaFunc(GLenum func,GLclampf ref)5523 void APIENTRY glAlphaFunc(GLenum func, GLclampf ref)
5524 {
5525 TRACE("(GLenum func = 0x%X, GLclampf ref = %f)", func, ref);
5526
5527 gl::Context *context = gl::getContext();
5528
5529 if(context)
5530 {
5531 if(context->getListIndex() != 0)
5532 {
5533 UNIMPLEMENTED();
5534 }
5535
5536 context->alphaFunc(func, ref);
5537 }
5538 }
5539
glAreTexturesResident(GLsizei n,const GLuint * textures,GLboolean * residences)5540 GLboolean APIENTRY glAreTexturesResident(GLsizei n, const GLuint *textures, GLboolean *residences)
5541 {
5542 UNIMPLEMENTED();
5543 return GL_FALSE;
5544 }
5545
glArrayElement(GLint i)5546 void APIENTRY glArrayElement(GLint i)
5547 {
5548 UNIMPLEMENTED();
5549 }
5550
glBegin(GLenum mode)5551 void APIENTRY glBegin(GLenum mode)
5552 {
5553 TRACE("(GLenum mode = 0x%X)", mode);
5554
5555 switch(mode)
5556 {
5557 case GL_POINTS:
5558 case GL_LINES:
5559 case GL_LINE_STRIP:
5560 case GL_LINE_LOOP:
5561 case GL_TRIANGLES:
5562 case GL_TRIANGLE_STRIP:
5563 case GL_TRIANGLE_FAN:
5564 case GL_QUADS:
5565 case GL_QUAD_STRIP:
5566 case GL_POLYGON:
5567 break;
5568 default:
5569 return error(GL_INVALID_ENUM);
5570 }
5571
5572 gl::Context *context = gl::getContext();
5573
5574 if(context)
5575 {
5576 if(context->getListIndex() != 0)
5577 {
5578 UNIMPLEMENTED();
5579 }
5580
5581 context->begin(mode);
5582 }
5583 }
5584
glBitmap(GLsizei width,GLsizei height,GLfloat xorig,GLfloat yorig,GLfloat xmove,GLfloat ymove,const GLubyte * bitmap)5585 void APIENTRY glBitmap(GLsizei width, GLsizei height, GLfloat xorig, GLfloat yorig, GLfloat xmove, GLfloat ymove, const GLubyte *bitmap)
5586 {
5587 UNIMPLEMENTED();
5588 }
5589
glCallList(GLuint list)5590 void APIENTRY glCallList(GLuint list)
5591 {
5592 TRACE("(GLuint list = %d)", list);
5593
5594 if(list == 0)
5595 {
5596 return error(GL_INVALID_VALUE);
5597 }
5598
5599 gl::Context *context = gl::getContext();
5600
5601 if(context)
5602 {
5603 if(context->getListIndex() != 0)
5604 {
5605 UNIMPLEMENTED();
5606 }
5607
5608 context->callList(list);
5609 }
5610 }
5611
glCallLists(GLsizei n,GLenum type,const GLvoid * lists)5612 void APIENTRY glCallLists(GLsizei n, GLenum type, const GLvoid *lists)
5613 {
5614 TRACE("(GLsizei n = %d, GLenum type = 0x%X, const GLvoid *lists)", n, type);
5615
5616 gl::Context *context = gl::getContext();
5617
5618 if(context)
5619 {
5620 if(context->getListIndex() != 0)
5621 {
5622 UNIMPLEMENTED();
5623 }
5624
5625 for(int i = 0; i < n; i++)
5626 {
5627 switch(type)
5628 {
5629 case GL_UNSIGNED_INT: context->callList(((unsigned int*)lists)[i]); break;
5630 default:
5631 UNIMPLEMENTED();
5632 UNREACHABLE(type);
5633 }
5634 }
5635 }
5636 }
5637
glClearAccum(GLfloat red,GLfloat green,GLfloat blue,GLfloat alpha)5638 void APIENTRY glClearAccum(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha)
5639 {
5640 UNIMPLEMENTED();
5641 }
5642
glClearDepth(GLclampd depth)5643 void APIENTRY glClearDepth(GLclampd depth)
5644 {
5645 TRACE("(GLclampd depth = %d)", depth);
5646
5647 glClearDepthf((float)depth); // FIXME
5648 }
5649
glClearIndex(GLfloat c)5650 void APIENTRY glClearIndex(GLfloat c)
5651 {
5652 UNIMPLEMENTED();
5653 }
5654
glClipPlane(GLenum plane,const GLdouble * equation)5655 void APIENTRY glClipPlane(GLenum plane, const GLdouble *equation)
5656 {
5657 UNIMPLEMENTED();
5658 }
5659
glColor3b(GLbyte red,GLbyte green,GLbyte blue)5660 void APIENTRY glColor3b(GLbyte red, GLbyte green, GLbyte blue)
5661 {
5662 UNIMPLEMENTED();
5663 }
5664
glColor3bv(const GLbyte * v)5665 void APIENTRY glColor3bv(const GLbyte *v)
5666 {
5667 UNIMPLEMENTED();
5668 }
5669
glColor3d(GLdouble red,GLdouble green,GLdouble blue)5670 void APIENTRY glColor3d(GLdouble red, GLdouble green, GLdouble blue)
5671 {
5672 UNIMPLEMENTED();
5673 }
5674
glColor3dv(const GLdouble * v)5675 void APIENTRY glColor3dv(const GLdouble *v)
5676 {
5677 UNIMPLEMENTED();
5678 }
5679
glColor3f(GLfloat red,GLfloat green,GLfloat blue)5680 void APIENTRY glColor3f(GLfloat red, GLfloat green, GLfloat blue)
5681 {
5682 TRACE("(GLfloat red = %f, GLfloat green = %f, GLfloat blue = %f)", red, green, blue);
5683
5684 gl::Context *context = gl::getContext();
5685
5686 if(context)
5687 {
5688 if(context->getListIndex() != 0)
5689 {
5690 UNIMPLEMENTED();
5691 }
5692
5693 //context->color(red, green, blue, 1.0f);
5694 //GLfloat vals[4] = {};
5695 context->setVertexAttrib(sw::Color0, red, green, blue, 1);
5696 }
5697 }
5698
glColor3fv(const GLfloat * v)5699 void APIENTRY glColor3fv(const GLfloat *v)
5700 {
5701 UNIMPLEMENTED();
5702 }
5703
glColor3i(GLint red,GLint green,GLint blue)5704 void APIENTRY glColor3i(GLint red, GLint green, GLint blue)
5705 {
5706 UNIMPLEMENTED();
5707 }
5708
glColor3iv(const GLint * v)5709 void APIENTRY glColor3iv(const GLint *v)
5710 {
5711 UNIMPLEMENTED();
5712 }
5713
glColor3s(GLshort red,GLshort green,GLshort blue)5714 void APIENTRY glColor3s(GLshort red, GLshort green, GLshort blue)
5715 {
5716 UNIMPLEMENTED();
5717 }
5718
glColor3sv(const GLshort * v)5719 void APIENTRY glColor3sv(const GLshort *v)
5720 {
5721 UNIMPLEMENTED();
5722 }
5723
glColor3ub(GLubyte red,GLubyte green,GLubyte blue)5724 void APIENTRY glColor3ub(GLubyte red, GLubyte green, GLubyte blue)
5725 {
5726 UNIMPLEMENTED();
5727 }
5728
glColor3ubv(const GLubyte * v)5729 void APIENTRY glColor3ubv(const GLubyte *v)
5730 {
5731 UNIMPLEMENTED();
5732 }
5733
glColor3ui(GLuint red,GLuint green,GLuint blue)5734 void APIENTRY glColor3ui(GLuint red, GLuint green, GLuint blue)
5735 {
5736 UNIMPLEMENTED();
5737 }
5738
glColor3uiv(const GLuint * v)5739 void APIENTRY glColor3uiv(const GLuint *v)
5740 {
5741 UNIMPLEMENTED();
5742 }
5743
glColor3us(GLushort red,GLushort green,GLushort blue)5744 void APIENTRY glColor3us(GLushort red, GLushort green, GLushort blue)
5745 {
5746 UNIMPLEMENTED();
5747 }
5748
glColor3usv(const GLushort * v)5749 void APIENTRY glColor3usv(const GLushort *v)
5750 {
5751 UNIMPLEMENTED();
5752 }
5753
glColor4b(GLbyte red,GLbyte green,GLbyte blue,GLbyte alpha)5754 void APIENTRY glColor4b(GLbyte red, GLbyte green, GLbyte blue, GLbyte alpha)
5755 {
5756 UNIMPLEMENTED();
5757 }
5758
glColor4bv(const GLbyte * v)5759 void APIENTRY glColor4bv(const GLbyte *v)
5760 {
5761 UNIMPLEMENTED();
5762 }
5763
glColor4d(GLdouble red,GLdouble green,GLdouble blue,GLdouble alpha)5764 void APIENTRY glColor4d(GLdouble red, GLdouble green, GLdouble blue, GLdouble alpha)
5765 {
5766 UNIMPLEMENTED();
5767 }
5768
glColor4dv(const GLdouble * v)5769 void APIENTRY glColor4dv(const GLdouble *v)
5770 {
5771 UNIMPLEMENTED();
5772 }
5773
glColor4f(GLfloat red,GLfloat green,GLfloat blue,GLfloat alpha)5774 void APIENTRY glColor4f(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha)
5775 {
5776 TRACE("(GLfloat red = %f, GLfloat green = %f, GLfloat blue = %f, GLfloat alpha = %f)", red, green, blue, alpha);
5777
5778 gl::Context *context = gl::getContext();
5779
5780 if(context)
5781 {
5782 if(context->getListIndex() != 0)
5783 {
5784 UNIMPLEMENTED();
5785 }
5786
5787 //context->color(red, green, blue, alpha);
5788 //GLfloat vals[4] = {red, green, blue, alpha};
5789 context->setVertexAttrib(sw::Color0, red, green, blue, alpha);
5790 }
5791 }
5792
glColor4fv(const GLfloat * v)5793 void APIENTRY glColor4fv(const GLfloat *v)
5794 {
5795 UNIMPLEMENTED();
5796 }
5797
glColor4i(GLint red,GLint green,GLint blue,GLint alpha)5798 void APIENTRY glColor4i(GLint red, GLint green, GLint blue, GLint alpha)
5799 {
5800 UNIMPLEMENTED();
5801 }
5802
glColor4iv(const GLint * v)5803 void APIENTRY glColor4iv(const GLint *v)
5804 {
5805 UNIMPLEMENTED();
5806 }
5807
glColor4s(GLshort red,GLshort green,GLshort blue,GLshort alpha)5808 void APIENTRY glColor4s(GLshort red, GLshort green, GLshort blue, GLshort alpha)
5809 {
5810 UNIMPLEMENTED();
5811 }
5812
glColor4sv(const GLshort * v)5813 void APIENTRY glColor4sv(const GLshort *v)
5814 {
5815 UNIMPLEMENTED();
5816 }
5817
glColor4ub(GLubyte red,GLubyte green,GLubyte blue,GLubyte alpha)5818 void APIENTRY glColor4ub(GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha)
5819 {
5820 UNIMPLEMENTED();
5821 }
5822
glColor4ubv(const GLubyte * v)5823 void APIENTRY glColor4ubv(const GLubyte *v)
5824 {
5825 UNIMPLEMENTED();
5826 }
5827
glColor4ui(GLuint red,GLuint green,GLuint blue,GLuint alpha)5828 void APIENTRY glColor4ui(GLuint red, GLuint green, GLuint blue, GLuint alpha)
5829 {
5830 UNIMPLEMENTED();
5831 }
5832
glColor4uiv(const GLuint * v)5833 void APIENTRY glColor4uiv(const GLuint *v)
5834 {
5835 UNIMPLEMENTED();
5836 }
5837
glColor4us(GLushort red,GLushort green,GLushort blue,GLushort alpha)5838 void APIENTRY glColor4us(GLushort red, GLushort green, GLushort blue, GLushort alpha)
5839 {
5840 UNIMPLEMENTED();
5841 }
5842
glColor4usv(const GLushort * v)5843 void APIENTRY glColor4usv(const GLushort *v)
5844 {
5845 UNIMPLEMENTED();
5846 }
5847
glColorMaterial(GLenum face,GLenum mode)5848 void APIENTRY glColorMaterial(GLenum face, GLenum mode)
5849 {
5850 TRACE("(GLenum face = 0x%X, GLenum mode = 0x%X)", face, mode);
5851
5852 // FIXME: Validate enums
5853
5854 gl::Context *context = gl::getContext();
5855
5856 if(context)
5857 {
5858 if(context->getListIndex() != 0)
5859 {
5860 UNIMPLEMENTED();
5861 }
5862
5863 switch(face)
5864 {
5865 case GL_FRONT:
5866 context->setColorMaterialMode(mode); // FIXME: Front only
5867 break;
5868 case GL_FRONT_AND_BACK:
5869 context->setColorMaterialMode(mode);
5870 break;
5871 default:
5872 UNIMPLEMENTED();
5873 return error(GL_INVALID_ENUM);
5874 }
5875 }
5876 }
5877
glColorPointer(GLint size,GLenum type,GLsizei stride,const GLvoid * pointer)5878 void APIENTRY glColorPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer)
5879 {
5880 TRACE("(*)");
5881
5882 glVertexAttribPointer(sw::Color0, size, type, true, stride, pointer);
5883 }
5884
glCopyPixels(GLint x,GLint y,GLsizei width,GLsizei height,GLenum type)5885 void APIENTRY glCopyPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum type)
5886 {
5887 UNIMPLEMENTED();
5888 }
5889
glCopyTexImage1D(GLenum target,GLint level,GLenum internalFormat,GLint x,GLint y,GLsizei width,GLint border)5890 void APIENTRY glCopyTexImage1D(GLenum target, GLint level, GLenum internalFormat, GLint x, GLint y, GLsizei width, GLint border)
5891 {
5892 UNIMPLEMENTED();
5893 }
5894
glCopyTexSubImage1D(GLenum target,GLint level,GLint xoffset,GLint x,GLint y,GLsizei width)5895 void APIENTRY glCopyTexSubImage1D(GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width)
5896 {
5897 UNIMPLEMENTED();
5898 }
5899
glDebugEntry()5900 void APIENTRY glDebugEntry()
5901 {
5902 UNIMPLEMENTED();
5903 }
5904
glDeleteLists(GLuint list,GLsizei range)5905 void APIENTRY glDeleteLists(GLuint list, GLsizei range)
5906 {
5907 TRACE("(GLuint list = %d, GLsizei range = %d)", list, range);
5908
5909 if(range < 0)
5910 {
5911 return error(GL_INVALID_VALUE);
5912 }
5913
5914 gl::Context *context = gl::getContext();
5915
5916 if(context)
5917 {
5918 for(GLuint i = list; i < list + range; i++)
5919 {
5920 context->deleteList(i);
5921 }
5922 }
5923 }
5924
glDepthRange(GLclampd zNear,GLclampd zFar)5925 void APIENTRY glDepthRange(GLclampd zNear, GLclampd zFar)
5926 {
5927 UNIMPLEMENTED();
5928 }
5929
glDisableClientState(GLenum array)5930 void APIENTRY glDisableClientState(GLenum array)
5931 {
5932 TRACE("(GLenum array = 0x%X)", array);
5933
5934 gl::Context *context = gl::getContext();
5935
5936 if(context)
5937 {
5938 GLenum texture = context->getClientActiveTexture();
5939
5940 switch(array)
5941 {
5942 case GL_VERTEX_ARRAY: context->setVertexAttribArrayEnabled(sw::Position, false); break;
5943 case GL_COLOR_ARRAY: context->setVertexAttribArrayEnabled(sw::Color0, false); break;
5944 case GL_TEXTURE_COORD_ARRAY: context->setVertexAttribArrayEnabled(sw::TexCoord0 + (texture - GL_TEXTURE0), false); break;
5945 case GL_NORMAL_ARRAY: context->setVertexAttribArrayEnabled(sw::Normal, false); break;
5946 default: UNIMPLEMENTED();
5947 }
5948 }
5949 }
5950
glDrawBuffer(GLenum mode)5951 void APIENTRY glDrawBuffer(GLenum mode)
5952 {
5953 UNIMPLEMENTED();
5954 }
5955
glDrawPixels(GLsizei width,GLsizei height,GLenum format,GLenum type,const GLvoid * pixels)5956 void APIENTRY glDrawPixels(GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels)
5957 {
5958 UNIMPLEMENTED();
5959 }
5960
glEdgeFlag(GLboolean flag)5961 void APIENTRY glEdgeFlag(GLboolean flag)
5962 {
5963 UNIMPLEMENTED();
5964 }
5965
glEdgeFlagPointer(GLsizei stride,const GLvoid * pointer)5966 void APIENTRY glEdgeFlagPointer(GLsizei stride, const GLvoid *pointer)
5967 {
5968 UNIMPLEMENTED();
5969 }
5970
glEdgeFlagv(const GLboolean * flag)5971 void APIENTRY glEdgeFlagv(const GLboolean *flag)
5972 {
5973 UNIMPLEMENTED();
5974 }
5975
glEnableClientState(GLenum array)5976 void APIENTRY glEnableClientState(GLenum array)
5977 {
5978 TRACE("(GLenum array = 0x%X)", array);
5979
5980 gl::Context *context = gl::getContext();
5981
5982 if(context)
5983 {
5984 GLenum texture = context->getClientActiveTexture();
5985
5986 switch(array)
5987 {
5988 case GL_VERTEX_ARRAY: context->setVertexAttribArrayEnabled(sw::Position, true); break;
5989 case GL_COLOR_ARRAY: context->setVertexAttribArrayEnabled(sw::Color0, true); break;
5990 case GL_TEXTURE_COORD_ARRAY: context->setVertexAttribArrayEnabled(sw::TexCoord0 + (texture - GL_TEXTURE0), true); break;
5991 case GL_NORMAL_ARRAY: context->setVertexAttribArrayEnabled(sw::Normal, true); break;
5992 default: UNIMPLEMENTED();
5993 }
5994 }
5995 }
5996
glEnd()5997 void APIENTRY glEnd()
5998 {
5999 TRACE("()");
6000
6001 gl::Context *context = gl::getContext();
6002
6003 if(context)
6004 {
6005 if(context->getListIndex() != 0)
6006 {
6007 UNIMPLEMENTED();
6008 }
6009
6010 context->end();
6011 }
6012 }
6013
glEndList()6014 void APIENTRY glEndList()
6015 {
6016 TRACE("()");
6017
6018 gl::Context *context = gl::getContext();
6019
6020 if(context)
6021 {
6022 context->endList();
6023 }
6024 }
6025
glEvalCoord1d(GLdouble u)6026 void APIENTRY glEvalCoord1d(GLdouble u)
6027 {
6028 UNIMPLEMENTED();
6029 }
6030
glEvalCoord1dv(const GLdouble * u)6031 void APIENTRY glEvalCoord1dv(const GLdouble *u)
6032 {
6033 UNIMPLEMENTED();
6034 }
6035
glEvalCoord1f(GLfloat u)6036 void APIENTRY glEvalCoord1f(GLfloat u)
6037 {
6038 UNIMPLEMENTED();
6039 }
6040
glEvalCoord1fv(const GLfloat * u)6041 void APIENTRY glEvalCoord1fv(const GLfloat *u)
6042 {
6043 UNIMPLEMENTED();
6044 }
6045
glEvalCoord2d(GLdouble u,GLdouble v)6046 void APIENTRY glEvalCoord2d(GLdouble u, GLdouble v)
6047 {
6048 UNIMPLEMENTED();
6049 }
6050
glEvalCoord2dv(const GLdouble * u)6051 void APIENTRY glEvalCoord2dv(const GLdouble *u)
6052 {
6053 UNIMPLEMENTED();
6054 }
6055
glEvalCoord2f(GLfloat u,GLfloat v)6056 void APIENTRY glEvalCoord2f(GLfloat u, GLfloat v)
6057 {
6058 UNIMPLEMENTED();
6059 }
6060
glEvalCoord2fv(const GLfloat * u)6061 void APIENTRY glEvalCoord2fv(const GLfloat *u)
6062 {
6063 UNIMPLEMENTED();
6064 }
6065
glEvalMesh1(GLenum mode,GLint i1,GLint i2)6066 void APIENTRY glEvalMesh1(GLenum mode, GLint i1, GLint i2)
6067 {
6068 UNIMPLEMENTED();
6069 }
6070
glEvalMesh2(GLenum mode,GLint i1,GLint i2,GLint j1,GLint j2)6071 void APIENTRY glEvalMesh2(GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2)
6072 {
6073 UNIMPLEMENTED();
6074 }
6075
glEvalPoint1(GLint i)6076 void APIENTRY glEvalPoint1(GLint i)
6077 {
6078 UNIMPLEMENTED();
6079 }
6080
glEvalPoint2(GLint i,GLint j)6081 void APIENTRY glEvalPoint2(GLint i, GLint j)
6082 {
6083 UNIMPLEMENTED();
6084 }
6085
glFeedbackBuffer(GLsizei size,GLenum type,GLfloat * buffer)6086 void APIENTRY glFeedbackBuffer(GLsizei size, GLenum type, GLfloat *buffer)
6087 {
6088 UNIMPLEMENTED();
6089 }
6090
glFogf(GLenum pname,GLfloat param)6091 void APIENTRY glFogf(GLenum pname, GLfloat param)
6092 {
6093 TRACE("(GLenum pname = 0x%X, GLfloat param = %f)", pname, param);
6094
6095 gl::Context *context = gl::getContext();
6096
6097 if(context)
6098 {
6099 if(context->getListIndex() != 0)
6100 {
6101 UNIMPLEMENTED();
6102 }
6103
6104 gl::Device *device = gl::getDevice(); // FIXME
6105
6106 switch(pname)
6107 {
6108 case GL_FOG_START: device->setFogStart(param); break;
6109 case GL_FOG_END: device->setFogEnd(param); break;
6110 default:
6111 UNIMPLEMENTED();
6112 return error(GL_INVALID_ENUM);
6113 }
6114 }
6115 }
6116
glFogfv(GLenum pname,const GLfloat * params)6117 void APIENTRY glFogfv(GLenum pname, const GLfloat *params)
6118 {
6119 TRACE("(GLenum pname = 0x%X, const GLfloat *params)", pname);
6120
6121 gl::Context *context = gl::getContext();
6122
6123 if(context)
6124 {
6125 if(context->getListIndex() != 0)
6126 {
6127 UNIMPLEMENTED();
6128 }
6129
6130 switch(pname)
6131 {
6132 case GL_FOG_COLOR:
6133 {
6134 gl::Device *device = gl::getDevice(); // FIXME
6135 device->setFogColor(sw::Color<float>(params[0], params[1], params[2], params[3]));
6136 }
6137 break;
6138 default:
6139 UNIMPLEMENTED();
6140 return error(GL_INVALID_ENUM);
6141 }
6142 }
6143 }
6144
glFogi(GLenum pname,GLint param)6145 void APIENTRY glFogi(GLenum pname, GLint param)
6146 {
6147 TRACE("(GLenum pname = 0x%X, GLint param = %d)", pname, param);
6148
6149 gl::Context *context = gl::getContext();
6150
6151 if(context)
6152 {
6153 if(context->getListIndex() != 0)
6154 {
6155 UNIMPLEMENTED();
6156 }
6157
6158 switch(pname)
6159 {
6160 case GL_FOG_MODE:
6161 {
6162 gl::Device *device = gl::getDevice(); // FIXME
6163 switch(param)
6164 {
6165 case GL_LINEAR: device->setVertexFogMode(sw::FOG_LINEAR); break;
6166 default:
6167 UNIMPLEMENTED();
6168 return error(GL_INVALID_ENUM);
6169 }
6170 }
6171 break;
6172 default:
6173 UNIMPLEMENTED();
6174 return error(GL_INVALID_ENUM);
6175 }
6176 }
6177 }
6178
glFogiv(GLenum pname,const GLint * params)6179 void APIENTRY glFogiv(GLenum pname, const GLint *params)
6180 {
6181 UNIMPLEMENTED();
6182 }
6183
glFrustum(GLdouble left,GLdouble right,GLdouble bottom,GLdouble top,GLdouble zNear,GLdouble zFar)6184 void APIENTRY glFrustum(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar)
6185 {
6186 TRACE("(GLdouble left = %f, GLdouble right = %f, GLdouble bottom = %f, GLdouble top = %f, GLdouble zNear = %f, GLdouble zFar = %f)", left, right, bottom, top, zNear, zFar);
6187
6188 gl::Context *context = gl::getContext();
6189
6190 if(context)
6191 {
6192 if(context->getListIndex() != 0)
6193 {
6194 UNIMPLEMENTED();
6195 }
6196
6197 context->frustum(left, right, bottom, top, zNear, zFar);
6198 }
6199 }
6200
glGenLists(GLsizei range)6201 GLuint APIENTRY glGenLists(GLsizei range)
6202 {
6203 TRACE("(GLsizei range = %d)", range);
6204
6205 if(range < 0)
6206 {
6207 return error(GL_INVALID_VALUE, 0);
6208 }
6209
6210 gl::Context *context = gl::getContext();
6211
6212 if(context)
6213 {
6214 return context->genLists(range);
6215 }
6216
6217 return 0;
6218 }
6219
glGetClipPlane(GLenum plane,GLdouble * equation)6220 void APIENTRY glGetClipPlane(GLenum plane, GLdouble *equation)
6221 {
6222 UNIMPLEMENTED();
6223 }
6224
glGetDoublev(GLenum pname,GLdouble * params)6225 void APIENTRY glGetDoublev(GLenum pname, GLdouble *params)
6226 {
6227 UNIMPLEMENTED();
6228 }
6229
glGetLightfv(GLenum light,GLenum pname,GLfloat * params)6230 void APIENTRY glGetLightfv(GLenum light, GLenum pname, GLfloat *params)
6231 {
6232 UNIMPLEMENTED();
6233 }
6234
glGetLightiv(GLenum light,GLenum pname,GLint * params)6235 void APIENTRY glGetLightiv(GLenum light, GLenum pname, GLint *params)
6236 {
6237 UNIMPLEMENTED();
6238 }
6239
glGetMapdv(GLenum target,GLenum query,GLdouble * v)6240 void APIENTRY glGetMapdv(GLenum target, GLenum query, GLdouble *v)
6241 {
6242 UNIMPLEMENTED();
6243 }
6244
glGetMapfv(GLenum target,GLenum query,GLfloat * v)6245 void APIENTRY glGetMapfv(GLenum target, GLenum query, GLfloat *v)
6246 {
6247 UNIMPLEMENTED();
6248 }
6249
glGetMapiv(GLenum target,GLenum query,GLint * v)6250 void APIENTRY glGetMapiv(GLenum target, GLenum query, GLint *v)
6251 {
6252 UNIMPLEMENTED();
6253 }
6254
glGetMaterialfv(GLenum face,GLenum pname,GLfloat * params)6255 void APIENTRY glGetMaterialfv(GLenum face, GLenum pname, GLfloat *params)
6256 {
6257 UNIMPLEMENTED();
6258 }
6259
glGetMaterialiv(GLenum face,GLenum pname,GLint * params)6260 void APIENTRY glGetMaterialiv(GLenum face, GLenum pname, GLint *params)
6261 {
6262 UNIMPLEMENTED();
6263 }
6264
glGetPixelMapfv(GLenum map,GLfloat * values)6265 void APIENTRY glGetPixelMapfv(GLenum map, GLfloat *values)
6266 {
6267 UNIMPLEMENTED();
6268 }
6269
glGetPixelMapuiv(GLenum map,GLuint * values)6270 void APIENTRY glGetPixelMapuiv(GLenum map, GLuint *values)
6271 {
6272 UNIMPLEMENTED();
6273 }
6274
glGetPixelMapusv(GLenum map,GLushort * values)6275 void APIENTRY glGetPixelMapusv(GLenum map, GLushort *values)
6276 {
6277 UNIMPLEMENTED();
6278 }
6279
glGetPointerv(GLenum pname,GLvoid ** params)6280 void APIENTRY glGetPointerv(GLenum pname, GLvoid* *params)
6281 {
6282 UNIMPLEMENTED();
6283 }
6284
glGetPolygonStipple(GLubyte * mask)6285 void APIENTRY glGetPolygonStipple(GLubyte *mask)
6286 {
6287 UNIMPLEMENTED();
6288 }
6289
glGetTexEnvfv(GLenum target,GLenum pname,GLfloat * params)6290 void APIENTRY glGetTexEnvfv(GLenum target, GLenum pname, GLfloat *params)
6291 {
6292 UNIMPLEMENTED();
6293 }
6294
glGetTexEnviv(GLenum target,GLenum pname,GLint * params)6295 void APIENTRY glGetTexEnviv(GLenum target, GLenum pname, GLint *params)
6296 {
6297 UNIMPLEMENTED();
6298 }
6299
glGetTexGendv(GLenum coord,GLenum pname,GLdouble * params)6300 void APIENTRY glGetTexGendv(GLenum coord, GLenum pname, GLdouble *params)
6301 {
6302 UNIMPLEMENTED();
6303 }
6304
glGetTexGenfv(GLenum coord,GLenum pname,GLfloat * params)6305 void APIENTRY glGetTexGenfv(GLenum coord, GLenum pname, GLfloat *params)
6306 {
6307 UNIMPLEMENTED();
6308 }
6309
glGetTexGeniv(GLenum coord,GLenum pname,GLint * params)6310 void APIENTRY glGetTexGeniv(GLenum coord, GLenum pname, GLint *params)
6311 {
6312 UNIMPLEMENTED();
6313 }
6314
glGetTexImage(GLenum target,GLint level,GLenum format,GLenum type,GLvoid * pixels)6315 void APIENTRY glGetTexImage(GLenum target, GLint level, GLenum format, GLenum type, GLvoid *pixels)
6316 {
6317 TRACE("(GLenum target = 0x%X, GLint level = %d, GLenum format = 0x%X, GLenum type = 0x%X, GLint *pixels%p)", target, level, format, type, pixels);
6318
6319 gl::Context *context = gl::getContext();
6320
6321 if(context)
6322 {
6323 gl::Texture *texture;
6324
6325 switch(target)
6326 {
6327 case GL_TEXTURE_2D:
6328 texture = context->getTexture2D(target);
6329 break;
6330 case GL_TEXTURE_CUBE_MAP:
6331 texture = context->getTextureCubeMap();
6332 break;
6333 default:
6334 UNIMPLEMENTED();
6335 return error(GL_INVALID_ENUM);
6336 }
6337
6338 if(format == texture->getFormat(target, level) && type == texture->getType(target, level))
6339 {
6340 gl::Image *image = texture->getRenderTarget(target, level);
6341 void *source = image->lock(0, 0, sw::LOCK_READONLY);
6342 memcpy(pixels, source, image->getPitch() * image->getHeight());
6343 image->unlock();
6344 }
6345 else
6346 {
6347 UNIMPLEMENTED();
6348 }
6349 }
6350 }
6351
glGetTexLevelParameterfv(GLenum target,GLint level,GLenum pname,GLfloat * params)6352 void APIENTRY glGetTexLevelParameterfv(GLenum target, GLint level, GLenum pname, GLfloat *params)
6353 {
6354 UNIMPLEMENTED();
6355 }
6356
glGetTexLevelParameteriv(GLenum target,GLint level,GLenum pname,GLint * params)6357 void APIENTRY glGetTexLevelParameteriv(GLenum target, GLint level, GLenum pname, GLint *params)
6358 {
6359 TRACE("(GLenum target = 0x%X, GLint level = %d, GLenum pname = 0x%X, GLint *params = %p)", target, level, pname, params);
6360
6361 gl::Context *context = gl::getContext();
6362
6363 if(context)
6364 {
6365 gl::Texture *texture;
6366
6367 switch(target)
6368 {
6369 case GL_TEXTURE_2D:
6370 case GL_PROXY_TEXTURE_2D:
6371 texture = context->getTexture2D(target);
6372 break;
6373 case GL_TEXTURE_CUBE_MAP:
6374 texture = context->getTextureCubeMap();
6375 break;
6376 default:
6377 UNIMPLEMENTED();
6378 return error(GL_INVALID_ENUM);
6379 }
6380
6381 switch(pname)
6382 {
6383 case GL_TEXTURE_MAG_FILTER:
6384 *params = texture->getMagFilter();
6385 break;
6386 case GL_TEXTURE_MIN_FILTER:
6387 *params = texture->getMinFilter();
6388 break;
6389 case GL_TEXTURE_WRAP_S:
6390 *params = texture->getWrapS();
6391 break;
6392 case GL_TEXTURE_WRAP_T:
6393 *params = texture->getWrapT();
6394 break;
6395 case GL_TEXTURE_WIDTH:
6396 *params = texture->getWidth(target, level);
6397 break;
6398 case GL_TEXTURE_HEIGHT:
6399 *params = texture->getHeight(target, level);
6400 break;
6401 case GL_TEXTURE_INTERNAL_FORMAT:
6402 *params = texture->getInternalFormat(target, level);
6403 break;
6404 case GL_TEXTURE_BORDER_COLOR:
6405 UNIMPLEMENTED();
6406 break;
6407 case GL_TEXTURE_BORDER:
6408 UNIMPLEMENTED();
6409 break;
6410 case GL_TEXTURE_MAX_ANISOTROPY_EXT:
6411 *params = (GLint)texture->getMaxAnisotropy();
6412 break;
6413 default:
6414 return error(GL_INVALID_ENUM);
6415 }
6416 }
6417 }
6418
glIndexMask(GLuint mask)6419 void APIENTRY glIndexMask(GLuint mask)
6420 {
6421 UNIMPLEMENTED();
6422 }
6423
glIndexPointer(GLenum type,GLsizei stride,const GLvoid * pointer)6424 void APIENTRY glIndexPointer(GLenum type, GLsizei stride, const GLvoid *pointer)
6425 {
6426 UNIMPLEMENTED();
6427 }
6428
glIndexd(GLdouble c)6429 void APIENTRY glIndexd(GLdouble c)
6430 {
6431 UNIMPLEMENTED();
6432 }
6433
glIndexdv(const GLdouble * c)6434 void APIENTRY glIndexdv(const GLdouble *c)
6435 {
6436 UNIMPLEMENTED();
6437 }
6438
glIndexf(GLfloat c)6439 void APIENTRY glIndexf(GLfloat c)
6440 {
6441 UNIMPLEMENTED();
6442 }
6443
glIndexfv(const GLfloat * c)6444 void APIENTRY glIndexfv(const GLfloat *c)
6445 {
6446 UNIMPLEMENTED();
6447 }
6448
glIndexi(GLint c)6449 void APIENTRY glIndexi(GLint c)
6450 {
6451 UNIMPLEMENTED();
6452 }
6453
glIndexiv(const GLint * c)6454 void APIENTRY glIndexiv(const GLint *c)
6455 {
6456 UNIMPLEMENTED();
6457 }
6458
glIndexs(GLshort c)6459 void APIENTRY glIndexs(GLshort c)
6460 {
6461 UNIMPLEMENTED();
6462 }
6463
glIndexsv(const GLshort * c)6464 void APIENTRY glIndexsv(const GLshort *c)
6465 {
6466 UNIMPLEMENTED();
6467 }
6468
glIndexub(GLubyte c)6469 void APIENTRY glIndexub(GLubyte c)
6470 {
6471 UNIMPLEMENTED();
6472 }
6473
glIndexubv(const GLubyte * c)6474 void APIENTRY glIndexubv(const GLubyte *c)
6475 {
6476 UNIMPLEMENTED();
6477 }
6478
glInitNames(void)6479 void APIENTRY glInitNames(void)
6480 {
6481 UNIMPLEMENTED();
6482 }
6483
glInterleavedArrays(GLenum format,GLsizei stride,const GLvoid * pointer)6484 void APIENTRY glInterleavedArrays(GLenum format, GLsizei stride, const GLvoid *pointer)
6485 {
6486 UNIMPLEMENTED();
6487 }
6488
glIsList(GLuint list)6489 GLboolean APIENTRY glIsList(GLuint list)
6490 {
6491 UNIMPLEMENTED();
6492 return GL_FALSE;
6493 }
6494
glLightModelf(GLenum pname,GLfloat param)6495 void APIENTRY glLightModelf(GLenum pname, GLfloat param)
6496 {
6497 UNIMPLEMENTED();
6498 }
6499
glLightModelfv(GLenum pname,const GLfloat * params)6500 void APIENTRY glLightModelfv(GLenum pname, const GLfloat *params)
6501 {
6502 TRACE("(GLenum pname = 0x%X, const GLint *params)", pname);
6503
6504 gl::Context *context = gl::getContext();
6505
6506 if(context)
6507 {
6508 if(context->getListIndex() != 0)
6509 {
6510 UNIMPLEMENTED();
6511 }
6512
6513 gl::Device *device = gl::getDevice(); // FIXME
6514
6515 switch(pname)
6516 {
6517 case GL_LIGHT_MODEL_AMBIENT:
6518 device->setGlobalAmbient(sw::Color<float>(params[0], params[1], params[2], params[3]));
6519 break;
6520 default:
6521 UNIMPLEMENTED();
6522 return error(GL_INVALID_ENUM);
6523 }
6524 }
6525 }
6526
glLightModeli(GLenum pname,GLint param)6527 void APIENTRY glLightModeli(GLenum pname, GLint param)
6528 {
6529 UNIMPLEMENTED();
6530 }
6531
glLightModeliv(GLenum pname,const GLint * params)6532 void APIENTRY glLightModeliv(GLenum pname, const GLint *params)
6533 {
6534 TRACE("(GLenum pname = 0x%X, const GLint *params)", pname);
6535 UNIMPLEMENTED();
6536 }
6537
glLightf(GLenum light,GLenum pname,GLfloat param)6538 void APIENTRY glLightf(GLenum light, GLenum pname, GLfloat param)
6539 {
6540 UNIMPLEMENTED();
6541 }
6542
glLightfv(GLenum light,GLenum pname,const GLfloat * params)6543 void APIENTRY glLightfv(GLenum light, GLenum pname, const GLfloat *params)
6544 {
6545 TRACE("(GLenum light = 0x%X, GLenum pname = 0x%X, const GLint *params)", light, pname);
6546
6547 gl::Context *context = gl::getContext();
6548
6549 if(context)
6550 {
6551 if(context->getListIndex() != 0)
6552 {
6553 UNIMPLEMENTED();
6554 }
6555
6556 gl::Device *device = gl::getDevice(); // FIXME
6557
6558 switch(pname)
6559 {
6560 case GL_AMBIENT: device->setLightAmbient(light - GL_LIGHT0, sw::Color<float>(params[0], params[1], params[2], params[3])); break;
6561 case GL_DIFFUSE: device->setLightDiffuse(light - GL_LIGHT0, sw::Color<float>(params[0], params[1], params[2], params[3])); break;
6562 case GL_SPECULAR: device->setLightSpecular(light - GL_LIGHT0, sw::Color<float>(params[0], params[1], params[2], params[3])); break;
6563 case GL_POSITION:
6564 if(params[3] == 0.0f) // Directional light
6565 {
6566 // Create a very far out point light
6567 float max = sw::max(abs(params[0]), abs(params[1]), abs(params[2]));
6568 device->setLightPosition(light - GL_LIGHT0, sw::Point(params[0] / max * 1e10f, params[1] / max * 1e10f, params[2] / max * 1e10f));
6569 }
6570 else
6571 {
6572 device->setLightPosition(light - GL_LIGHT0, sw::Point(params[0] / params[3], params[1] / params[3], params[2] / params[3]));
6573 }
6574 break;
6575 default:
6576 UNIMPLEMENTED();
6577 return error(GL_INVALID_ENUM);
6578 }
6579 }
6580 }
6581
glLighti(GLenum light,GLenum pname,GLint param)6582 void APIENTRY glLighti(GLenum light, GLenum pname, GLint param)
6583 {
6584 UNIMPLEMENTED();
6585 }
6586
glLightiv(GLenum light,GLenum pname,const GLint * params)6587 void APIENTRY glLightiv(GLenum light, GLenum pname, const GLint *params)
6588 {
6589 UNIMPLEMENTED();
6590 }
6591
glLineStipple(GLint factor,GLushort pattern)6592 void APIENTRY glLineStipple(GLint factor, GLushort pattern)
6593 {
6594 UNIMPLEMENTED();
6595 }
6596
glListBase(GLuint base)6597 void APIENTRY glListBase(GLuint base)
6598 {
6599 UNIMPLEMENTED();
6600 }
6601
glLoadIdentity()6602 void APIENTRY glLoadIdentity()
6603 {
6604 TRACE("()");
6605
6606 gl::Context *context = gl::getContext();
6607
6608 if(context)
6609 {
6610 if(context->getListIndex() != 0)
6611 {
6612 UNIMPLEMENTED();
6613 }
6614
6615 context->loadIdentity();
6616 }
6617 }
6618
glLoadMatrixd(const GLdouble * m)6619 void APIENTRY glLoadMatrixd(const GLdouble *m)
6620 {
6621 UNIMPLEMENTED();
6622 }
6623
glLoadMatrixf(const GLfloat * m)6624 void APIENTRY glLoadMatrixf(const GLfloat *m)
6625 {
6626 UNIMPLEMENTED();
6627 }
6628
glLoadName(GLuint name)6629 void APIENTRY glLoadName(GLuint name)
6630 {
6631 UNIMPLEMENTED();
6632 }
6633
glLogicOp(GLenum opcode)6634 void APIENTRY glLogicOp(GLenum opcode)
6635 {
6636 TRACE("(GLenum opcode = 0x%X)", opcode);
6637
6638 switch(opcode)
6639 {
6640 case GL_CLEAR:
6641 case GL_SET:
6642 case GL_COPY:
6643 case GL_COPY_INVERTED:
6644 case GL_NOOP:
6645 case GL_INVERT:
6646 case GL_AND:
6647 case GL_NAND:
6648 case GL_OR:
6649 case GL_NOR:
6650 case GL_XOR:
6651 case GL_EQUIV:
6652 case GL_AND_REVERSE:
6653 case GL_AND_INVERTED:
6654 case GL_OR_REVERSE:
6655 case GL_OR_INVERTED:
6656 break;
6657 default:
6658 return error(GL_INVALID_ENUM);
6659 }
6660
6661 gl::Context *context = gl::getContext();
6662
6663 if(context)
6664 {
6665 if(context->getListIndex() != 0)
6666 {
6667 UNIMPLEMENTED();
6668 }
6669
6670 context->setLogicalOperation(opcode);
6671 }
6672 }
6673
glMap1d(GLenum target,GLdouble u1,GLdouble u2,GLint stride,GLint order,const GLdouble * points)6674 void APIENTRY glMap1d(GLenum target, GLdouble u1, GLdouble u2, GLint stride, GLint order, const GLdouble *points)
6675 {
6676 UNIMPLEMENTED();
6677 }
6678
glMap1f(GLenum target,GLfloat u1,GLfloat u2,GLint stride,GLint order,const GLfloat * points)6679 void APIENTRY glMap1f(GLenum target, GLfloat u1, GLfloat u2, GLint stride, GLint order, const GLfloat *points)
6680 {
6681 UNIMPLEMENTED();
6682 }
6683
glMap2d(GLenum target,GLdouble u1,GLdouble u2,GLint ustride,GLint uorder,GLdouble v1,GLdouble v2,GLint vstride,GLint vorder,const GLdouble * points)6684 void APIENTRY glMap2d(GLenum target, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, const GLdouble *points)
6685 {
6686 UNIMPLEMENTED();
6687 }
6688
glMap2f(GLenum target,GLfloat u1,GLfloat u2,GLint ustride,GLint uorder,GLfloat v1,GLfloat v2,GLint vstride,GLint vorder,const GLfloat * points)6689 void APIENTRY glMap2f(GLenum target, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, const GLfloat *points)
6690 {
6691 UNIMPLEMENTED();
6692 }
6693
glMapGrid1d(GLint un,GLdouble u1,GLdouble u2)6694 void APIENTRY glMapGrid1d(GLint un, GLdouble u1, GLdouble u2)
6695 {
6696 UNIMPLEMENTED();
6697 }
6698
glMapGrid1f(GLint un,GLfloat u1,GLfloat u2)6699 void APIENTRY glMapGrid1f(GLint un, GLfloat u1, GLfloat u2)
6700 {
6701 UNIMPLEMENTED();
6702 }
6703
glMapGrid2d(GLint un,GLdouble u1,GLdouble u2,GLint vn,GLdouble v1,GLdouble v2)6704 void APIENTRY glMapGrid2d(GLint un, GLdouble u1, GLdouble u2, GLint vn, GLdouble v1, GLdouble v2)
6705 {
6706 UNIMPLEMENTED();
6707 }
6708
glMapGrid2f(GLint un,GLfloat u1,GLfloat u2,GLint vn,GLfloat v1,GLfloat v2)6709 void APIENTRY glMapGrid2f(GLint un, GLfloat u1, GLfloat u2, GLint vn, GLfloat v1, GLfloat v2)
6710 {
6711 UNIMPLEMENTED();
6712 }
6713
glMaterialf(GLenum face,GLenum pname,GLfloat param)6714 void APIENTRY glMaterialf(GLenum face, GLenum pname, GLfloat param)
6715 {
6716 UNIMPLEMENTED();
6717 }
6718
glMaterialfv(GLenum face,GLenum pname,const GLfloat * params)6719 void APIENTRY glMaterialfv(GLenum face, GLenum pname, const GLfloat *params)
6720 {
6721 UNIMPLEMENTED();
6722 }
6723
glMateriali(GLenum face,GLenum pname,GLint param)6724 void APIENTRY glMateriali(GLenum face, GLenum pname, GLint param)
6725 {
6726 UNIMPLEMENTED();
6727 }
6728
glMaterialiv(GLenum face,GLenum pname,const GLint * params)6729 void APIENTRY glMaterialiv(GLenum face, GLenum pname, const GLint *params)
6730 {
6731 UNIMPLEMENTED();
6732 }
6733
glMatrixMode(GLenum mode)6734 void APIENTRY glMatrixMode(GLenum mode)
6735 {
6736 TRACE("(*)");
6737
6738 gl::Context *context = gl::getContext();
6739
6740 if(context)
6741 {
6742 if(context->getListIndex() != 0)
6743 {
6744 UNIMPLEMENTED();
6745 }
6746
6747 context->setMatrixMode(mode);
6748 }
6749 }
6750
glMultMatrixd(const GLdouble * m)6751 void APIENTRY glMultMatrixd(const GLdouble *m)
6752 {
6753 TRACE("(*)");
6754
6755 gl::Context *context = gl::getContext();
6756
6757 if(context)
6758 {
6759 if(context->getListIndex() != 0)
6760 {
6761 UNIMPLEMENTED();
6762 }
6763
6764 context->multiply(m);
6765 }
6766 }
6767
glMultMatrixm(sw::Matrix m)6768 void APIENTRY glMultMatrixm(sw::Matrix m)
6769 {
6770 gl::Context *context = gl::getContext();
6771
6772 if(context)
6773 {
6774 context->multiply((GLfloat*)m.m);
6775 }
6776 }
6777
glMultMatrixf(const GLfloat * m)6778 void APIENTRY glMultMatrixf(const GLfloat *m)
6779 {
6780 TRACE("(*)");
6781
6782 gl::Context *context = gl::getContext();
6783
6784 if(context)
6785 {
6786 if(context->getListIndex() != 0)
6787 {
6788 return context->listCommand(gl::newCommand(glMultMatrixm, sw::Matrix(m)));
6789 }
6790
6791 context->multiply(m);
6792 }
6793 }
6794
glNewList(GLuint list,GLenum mode)6795 void APIENTRY glNewList(GLuint list, GLenum mode)
6796 {
6797 TRACE("(GLuint list = %d, GLenum mode = 0x%X)", list, mode);
6798
6799 if(list == 0)
6800 {
6801 return error(GL_INVALID_VALUE);
6802 }
6803
6804 switch(mode)
6805 {
6806 case GL_COMPILE:
6807 case GL_COMPILE_AND_EXECUTE:
6808 break;
6809 default:
6810 return error(GL_INVALID_ENUM);
6811 }
6812
6813 gl::Context *context = gl::getContext();
6814
6815 if(context)
6816 {
6817 if(context->getListIndex() != 0)
6818 {
6819 UNIMPLEMENTED();
6820 }
6821
6822 context->newList(list, mode);
6823 }
6824 }
6825
glNormal3b(GLbyte nx,GLbyte ny,GLbyte nz)6826 void APIENTRY glNormal3b(GLbyte nx, GLbyte ny, GLbyte nz)
6827 {
6828 UNIMPLEMENTED();
6829 }
6830
glNormal3bv(const GLbyte * v)6831 void APIENTRY glNormal3bv(const GLbyte *v)
6832 {
6833 UNIMPLEMENTED();
6834 }
6835
glNormal3d(GLdouble nx,GLdouble ny,GLdouble nz)6836 void APIENTRY glNormal3d(GLdouble nx, GLdouble ny, GLdouble nz)
6837 {
6838 UNIMPLEMENTED();
6839 }
6840
glNormal3dv(const GLdouble * v)6841 void APIENTRY glNormal3dv(const GLdouble *v)
6842 {
6843 UNIMPLEMENTED();
6844 }
6845
glNormal3f(GLfloat nx,GLfloat ny,GLfloat nz)6846 void APIENTRY glNormal3f(GLfloat nx, GLfloat ny, GLfloat nz)
6847 {
6848 TRACE("(GLfloat nx = %f, GLfloat ny = %f, GLfloat nz = %f)", nx, ny, nz);
6849
6850 gl::Context *context = gl::getContext();
6851
6852 if(context)
6853 {
6854 if(context->getListIndex() != 0)
6855 {
6856 UNIMPLEMENTED();
6857 }
6858
6859 //context->normal(nx, ny, nz);
6860 context->setVertexAttrib(sw::Normal, nx, ny, nz, 0);
6861 }
6862 }
6863
glNormal3fv(const GLfloat * v)6864 void APIENTRY glNormal3fv(const GLfloat *v)
6865 {
6866 UNIMPLEMENTED();
6867 }
6868
glNormal3i(GLint nx,GLint ny,GLint nz)6869 void APIENTRY glNormal3i(GLint nx, GLint ny, GLint nz)
6870 {
6871 UNIMPLEMENTED();
6872 }
6873
glNormal3iv(const GLint * v)6874 void APIENTRY glNormal3iv(const GLint *v)
6875 {
6876 UNIMPLEMENTED();
6877 }
6878
glNormal3s(GLshort nx,GLshort ny,GLshort nz)6879 void APIENTRY glNormal3s(GLshort nx, GLshort ny, GLshort nz)
6880 {
6881 UNIMPLEMENTED();
6882 }
6883
glNormal3sv(const GLshort * v)6884 void APIENTRY glNormal3sv(const GLshort *v)
6885 {
6886 UNIMPLEMENTED();
6887 }
6888
glNormalPointer(GLenum type,GLsizei stride,const GLvoid * pointer)6889 void APIENTRY glNormalPointer(GLenum type, GLsizei stride, const GLvoid *pointer)
6890 {
6891 TRACE("(*)");
6892
6893 glVertexAttribPointer(sw::Normal, 3, type, true, stride, pointer);
6894 }
6895
glOrtho(GLdouble left,GLdouble right,GLdouble bottom,GLdouble top,GLdouble zNear,GLdouble zFar)6896 void APIENTRY glOrtho(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar)
6897 {
6898 TRACE("(*)");
6899
6900 gl::Context *context = gl::getContext();
6901
6902 if(context)
6903 {
6904 if(context->getListIndex() != 0)
6905 {
6906 UNIMPLEMENTED();
6907 }
6908
6909 context->ortho(left, right, bottom, top, zNear, zFar);
6910 }
6911 }
6912
glPassThrough(GLfloat token)6913 void APIENTRY glPassThrough(GLfloat token)
6914 {
6915 UNIMPLEMENTED();
6916 }
6917
glPixelMapfv(GLenum map,GLsizei mapsize,const GLfloat * values)6918 void APIENTRY glPixelMapfv(GLenum map, GLsizei mapsize, const GLfloat *values)
6919 {
6920 UNIMPLEMENTED();
6921 }
6922
glPixelMapuiv(GLenum map,GLsizei mapsize,const GLuint * values)6923 void APIENTRY glPixelMapuiv(GLenum map, GLsizei mapsize, const GLuint *values)
6924 {
6925 UNIMPLEMENTED();
6926 }
6927
glPixelMapusv(GLenum map,GLsizei mapsize,const GLushort * values)6928 void APIENTRY glPixelMapusv(GLenum map, GLsizei mapsize, const GLushort *values)
6929 {
6930 UNIMPLEMENTED();
6931 }
6932
glPixelStoref(GLenum pname,GLfloat param)6933 void APIENTRY glPixelStoref(GLenum pname, GLfloat param)
6934 {
6935 UNIMPLEMENTED();
6936 }
6937
glPixelTransferf(GLenum pname,GLfloat param)6938 void APIENTRY glPixelTransferf(GLenum pname, GLfloat param)
6939 {
6940 UNIMPLEMENTED();
6941 }
6942
glPixelTransferi(GLenum pname,GLint param)6943 void APIENTRY glPixelTransferi(GLenum pname, GLint param)
6944 {
6945 UNIMPLEMENTED();
6946 }
6947
glPixelZoom(GLfloat xfactor,GLfloat yfactor)6948 void APIENTRY glPixelZoom(GLfloat xfactor, GLfloat yfactor)
6949 {
6950 UNIMPLEMENTED();
6951 }
6952
glPointSize(GLfloat size)6953 void APIENTRY glPointSize(GLfloat size)
6954 {
6955 UNIMPLEMENTED();
6956 }
6957
glPolygonMode(GLenum face,GLenum mode)6958 void APIENTRY glPolygonMode(GLenum face, GLenum mode)
6959 {
6960 UNIMPLEMENTED();
6961 }
6962
glPolygonStipple(const GLubyte * mask)6963 void APIENTRY glPolygonStipple(const GLubyte *mask)
6964 {
6965 UNIMPLEMENTED();
6966 }
6967
glPopAttrib(void)6968 void APIENTRY glPopAttrib(void)
6969 {
6970 UNIMPLEMENTED();
6971 }
6972
glPopClientAttrib(void)6973 void APIENTRY glPopClientAttrib(void)
6974 {
6975 UNIMPLEMENTED();
6976 }
6977
glPopMatrix(void)6978 void APIENTRY glPopMatrix(void)
6979 {
6980 TRACE("()");
6981
6982 gl::Context *context = gl::getContext();
6983
6984 if(context)
6985 {
6986 if(context->getListIndex() != 0)
6987 {
6988 return context->listCommand(gl::newCommand(glPopMatrix));
6989 }
6990
6991 context->popMatrix();
6992 }
6993 }
6994
glPopName(void)6995 void APIENTRY glPopName(void)
6996 {
6997 UNIMPLEMENTED();
6998 }
6999
glPrioritizeTextures(GLsizei n,const GLuint * textures,const GLclampf * priorities)7000 void APIENTRY glPrioritizeTextures(GLsizei n, const GLuint *textures, const GLclampf *priorities)
7001 {
7002 UNIMPLEMENTED();
7003 }
7004
glPushAttrib(GLbitfield mask)7005 void APIENTRY glPushAttrib(GLbitfield mask)
7006 {
7007 UNIMPLEMENTED();
7008 }
7009
glPushClientAttrib(GLbitfield mask)7010 void APIENTRY glPushClientAttrib(GLbitfield mask)
7011 {
7012 UNIMPLEMENTED();
7013 }
7014
glPushMatrix(void)7015 void APIENTRY glPushMatrix(void)
7016 {
7017 TRACE("()");
7018
7019 gl::Context *context = gl::getContext();
7020
7021 if(context)
7022 {
7023 if(context->getListIndex() != 0)
7024 {
7025 return context->listCommand(gl::newCommand(glPushMatrix));
7026 }
7027
7028 context->pushMatrix();
7029 }
7030 }
7031
glPushName(GLuint name)7032 void APIENTRY glPushName(GLuint name)
7033 {
7034 UNIMPLEMENTED();
7035 }
7036
glRasterPos2d(GLdouble x,GLdouble y)7037 void APIENTRY glRasterPos2d(GLdouble x, GLdouble y)
7038 {
7039 UNIMPLEMENTED();
7040 }
7041
glRasterPos2dv(const GLdouble * v)7042 void APIENTRY glRasterPos2dv(const GLdouble *v)
7043 {
7044 UNIMPLEMENTED();
7045 }
7046
glRasterPos2f(GLfloat x,GLfloat y)7047 void APIENTRY glRasterPos2f(GLfloat x, GLfloat y)
7048 {
7049 UNIMPLEMENTED();
7050 }
7051
glRasterPos2fv(const GLfloat * v)7052 void APIENTRY glRasterPos2fv(const GLfloat *v)
7053 {
7054 UNIMPLEMENTED();
7055 }
7056
glRasterPos2i(GLint x,GLint y)7057 void APIENTRY glRasterPos2i(GLint x, GLint y)
7058 {
7059 UNIMPLEMENTED();
7060 }
7061
glRasterPos2iv(const GLint * v)7062 void APIENTRY glRasterPos2iv(const GLint *v)
7063 {
7064 UNIMPLEMENTED();
7065 }
7066
glRasterPos2s(GLshort x,GLshort y)7067 void APIENTRY glRasterPos2s(GLshort x, GLshort y)
7068 {
7069 UNIMPLEMENTED();
7070 }
7071
glRasterPos2sv(const GLshort * v)7072 void APIENTRY glRasterPos2sv(const GLshort *v)
7073 {
7074 UNIMPLEMENTED();
7075 }
7076
glRasterPos3d(GLdouble x,GLdouble y,GLdouble z)7077 void APIENTRY glRasterPos3d(GLdouble x, GLdouble y, GLdouble z)
7078 {
7079 UNIMPLEMENTED();
7080 }
7081
glRasterPos3dv(const GLdouble * v)7082 void APIENTRY glRasterPos3dv(const GLdouble *v)
7083 {
7084 UNIMPLEMENTED();
7085 }
7086
glRasterPos3f(GLfloat x,GLfloat y,GLfloat z)7087 void APIENTRY glRasterPos3f(GLfloat x, GLfloat y, GLfloat z)
7088 {
7089 UNIMPLEMENTED();
7090 }
7091
glRasterPos3fv(const GLfloat * v)7092 void APIENTRY glRasterPos3fv(const GLfloat *v)
7093 {
7094 UNIMPLEMENTED();
7095 }
7096
glRasterPos3i(GLint x,GLint y,GLint z)7097 void APIENTRY glRasterPos3i(GLint x, GLint y, GLint z)
7098 {
7099 UNIMPLEMENTED();
7100 }
7101
glRasterPos3iv(const GLint * v)7102 void APIENTRY glRasterPos3iv(const GLint *v)
7103 {
7104 UNIMPLEMENTED();
7105 }
7106
glRasterPos3s(GLshort x,GLshort y,GLshort z)7107 void APIENTRY glRasterPos3s(GLshort x, GLshort y, GLshort z)
7108 {
7109 UNIMPLEMENTED();
7110 }
7111
glRasterPos3sv(const GLshort * v)7112 void APIENTRY glRasterPos3sv(const GLshort *v)
7113 {
7114 UNIMPLEMENTED();
7115 }
7116
glRasterPos4d(GLdouble x,GLdouble y,GLdouble z,GLdouble w)7117 void APIENTRY glRasterPos4d(GLdouble x, GLdouble y, GLdouble z, GLdouble w)
7118 {
7119 UNIMPLEMENTED();
7120 }
7121
glRasterPos4dv(const GLdouble * v)7122 void APIENTRY glRasterPos4dv(const GLdouble *v)
7123 {
7124 UNIMPLEMENTED();
7125 }
7126
glRasterPos4f(GLfloat x,GLfloat y,GLfloat z,GLfloat w)7127 void APIENTRY glRasterPos4f(GLfloat x, GLfloat y, GLfloat z, GLfloat w)
7128 {
7129 UNIMPLEMENTED();
7130 }
7131
glRasterPos4fv(const GLfloat * v)7132 void APIENTRY glRasterPos4fv(const GLfloat *v)
7133 {
7134 UNIMPLEMENTED();
7135 }
7136
glRasterPos4i(GLint x,GLint y,GLint z,GLint w)7137 void APIENTRY glRasterPos4i(GLint x, GLint y, GLint z, GLint w)
7138 {
7139 UNIMPLEMENTED();
7140 }
7141
glRasterPos4iv(const GLint * v)7142 void APIENTRY glRasterPos4iv(const GLint *v)
7143 {
7144 UNIMPLEMENTED();
7145 }
7146
glRasterPos4s(GLshort x,GLshort y,GLshort z,GLshort w)7147 void APIENTRY glRasterPos4s(GLshort x, GLshort y, GLshort z, GLshort w)
7148 {
7149 UNIMPLEMENTED();
7150 }
7151
glRasterPos4sv(const GLshort * v)7152 void APIENTRY glRasterPos4sv(const GLshort *v)
7153 {
7154 UNIMPLEMENTED();
7155 }
7156
glReadBuffer(GLenum mode)7157 void APIENTRY glReadBuffer(GLenum mode)
7158 {
7159 UNIMPLEMENTED();
7160 }
7161
glRectd(GLdouble x1,GLdouble y1,GLdouble x2,GLdouble y2)7162 void APIENTRY glRectd(GLdouble x1, GLdouble y1, GLdouble x2, GLdouble y2)
7163 {
7164 UNIMPLEMENTED();
7165 }
7166
glRectdv(const GLdouble * v1,const GLdouble * v2)7167 void APIENTRY glRectdv(const GLdouble *v1, const GLdouble *v2)
7168 {
7169 UNIMPLEMENTED();
7170 }
7171
glRectf(GLfloat x1,GLfloat y1,GLfloat x2,GLfloat y2)7172 void APIENTRY glRectf(GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2)
7173 {
7174 UNIMPLEMENTED();
7175 }
7176
glRectfv(const GLfloat * v1,const GLfloat * v2)7177 void APIENTRY glRectfv(const GLfloat *v1, const GLfloat *v2)
7178 {
7179 UNIMPLEMENTED();
7180 }
7181
glRecti(GLint x1,GLint y1,GLint x2,GLint y2)7182 void APIENTRY glRecti(GLint x1, GLint y1, GLint x2, GLint y2)
7183 {
7184 UNIMPLEMENTED();
7185 }
7186
glRectiv(const GLint * v1,const GLint * v2)7187 void APIENTRY glRectiv(const GLint *v1, const GLint *v2)
7188 {
7189 UNIMPLEMENTED();
7190 }
7191
glRects(GLshort x1,GLshort y1,GLshort x2,GLshort y2)7192 void APIENTRY glRects(GLshort x1, GLshort y1, GLshort x2, GLshort y2)
7193 {
7194 UNIMPLEMENTED();
7195 }
7196
glRectsv(const GLshort * v1,const GLshort * v2)7197 void APIENTRY glRectsv(const GLshort *v1, const GLshort *v2)
7198 {
7199 UNIMPLEMENTED();
7200 }
7201
glRenderMode(GLenum mode)7202 GLint APIENTRY glRenderMode(GLenum mode)
7203 {
7204 UNIMPLEMENTED();
7205 return 0;
7206 }
7207
glRotated(GLdouble angle,GLdouble x,GLdouble y,GLdouble z)7208 void APIENTRY glRotated(GLdouble angle, GLdouble x, GLdouble y, GLdouble z)
7209 {
7210 UNIMPLEMENTED();
7211 }
7212
glRotatef(GLfloat angle,GLfloat x,GLfloat y,GLfloat z)7213 void APIENTRY glRotatef(GLfloat angle, GLfloat x, GLfloat y, GLfloat z)
7214 {
7215 TRACE("(*)");
7216
7217 gl::Context *context = gl::getContext();
7218
7219 if(context)
7220 {
7221 if(context->getListIndex() != 0)
7222 {
7223 UNIMPLEMENTED();
7224 }
7225
7226 context->rotate(angle, x, y, z);
7227 }
7228 }
7229
glScaled(GLdouble x,GLdouble y,GLdouble z)7230 void APIENTRY glScaled(GLdouble x, GLdouble y, GLdouble z)
7231 {
7232 UNIMPLEMENTED();
7233 }
7234
glScalef(GLfloat x,GLfloat y,GLfloat z)7235 void APIENTRY glScalef(GLfloat x, GLfloat y, GLfloat z)
7236 {
7237 TRACE("(GLfloat x = %f, GLfloat y = %f, GLfloat z = %f)", x, y, z);
7238
7239 gl::Context *context = gl::getContext();
7240
7241 if(context)
7242 {
7243 if(context->getListIndex() != 0)
7244 {
7245 return context->listCommand(gl::newCommand(glScalef, x, y, z));
7246 }
7247
7248 context->scale(x, y, z);
7249 }
7250 }
7251
glSelectBuffer(GLsizei size,GLuint * buffer)7252 void APIENTRY glSelectBuffer(GLsizei size, GLuint *buffer)
7253 {
7254 UNIMPLEMENTED();
7255 }
7256
glShadeModel(GLenum mode)7257 void APIENTRY glShadeModel(GLenum mode)
7258 {
7259 TRACE("(*)");
7260
7261 gl::Context *context = gl::getContext();
7262
7263 if(context)
7264 {
7265 if(context->getListIndex() != 0)
7266 {
7267 UNIMPLEMENTED();
7268 }
7269
7270 context->setShadeModel(mode);
7271 }
7272 }
7273
glTexCoord1d(GLdouble s)7274 void APIENTRY glTexCoord1d(GLdouble s)
7275 {
7276 UNIMPLEMENTED();
7277 }
7278
glTexCoord1dv(const GLdouble * v)7279 void APIENTRY glTexCoord1dv(const GLdouble *v)
7280 {
7281 UNIMPLEMENTED();
7282 }
7283
glTexCoord1f(GLfloat s)7284 void APIENTRY glTexCoord1f(GLfloat s)
7285 {
7286 UNIMPLEMENTED();
7287 }
7288
glTexCoord1fv(const GLfloat * v)7289 void APIENTRY glTexCoord1fv(const GLfloat *v)
7290 {
7291 UNIMPLEMENTED();
7292 }
7293
glTexCoord1i(GLint s)7294 void APIENTRY glTexCoord1i(GLint s)
7295 {
7296 UNIMPLEMENTED();
7297 }
7298
glTexCoord1iv(const GLint * v)7299 void APIENTRY glTexCoord1iv(const GLint *v)
7300 {
7301 UNIMPLEMENTED();
7302 }
7303
glTexCoord1s(GLshort s)7304 void APIENTRY glTexCoord1s(GLshort s)
7305 {
7306 UNIMPLEMENTED();
7307 }
7308
glTexCoord1sv(const GLshort * v)7309 void APIENTRY glTexCoord1sv(const GLshort *v)
7310 {
7311 UNIMPLEMENTED();
7312 }
7313
glTexCoord2d(GLdouble s,GLdouble t)7314 void APIENTRY glTexCoord2d(GLdouble s, GLdouble t)
7315 {
7316 UNIMPLEMENTED();
7317 }
7318
glTexCoord2dv(const GLdouble * v)7319 void APIENTRY glTexCoord2dv(const GLdouble *v)
7320 {
7321 UNIMPLEMENTED();
7322 }
7323
glTexCoord2f(GLfloat s,GLfloat t)7324 void APIENTRY glTexCoord2f(GLfloat s, GLfloat t)
7325 {
7326 TRACE("(GLfloat s = %f, GLfloat t = %f)", s, t);
7327
7328 gl::Context *context = gl::getContext();
7329
7330 if(context)
7331 {
7332 if(context->getListIndex() != 0)
7333 {
7334 UNIMPLEMENTED();
7335 }
7336
7337 //context->texCoord(s, t, 0.0f, 1.0f);
7338 unsigned int texture = context->getActiveTexture();
7339 context->setVertexAttrib(sw::TexCoord0/* + texture*/, s, t, 0.0f, 1.0f);
7340 }
7341 }
7342
glTexCoord2fv(const GLfloat * v)7343 void APIENTRY glTexCoord2fv(const GLfloat *v)
7344 {
7345 UNIMPLEMENTED();
7346 }
7347
glTexCoord2i(GLint s,GLint t)7348 void APIENTRY glTexCoord2i(GLint s, GLint t)
7349 {
7350 UNIMPLEMENTED();
7351 }
7352
glTexCoord2iv(const GLint * v)7353 void APIENTRY glTexCoord2iv(const GLint *v)
7354 {
7355 UNIMPLEMENTED();
7356 }
7357
glTexCoord2s(GLshort s,GLshort t)7358 void APIENTRY glTexCoord2s(GLshort s, GLshort t)
7359 {
7360 UNIMPLEMENTED();
7361 }
7362
glTexCoord2sv(const GLshort * v)7363 void APIENTRY glTexCoord2sv(const GLshort *v)
7364 {
7365 UNIMPLEMENTED();
7366 }
7367
glTexCoord3d(GLdouble s,GLdouble t,GLdouble r)7368 void APIENTRY glTexCoord3d(GLdouble s, GLdouble t, GLdouble r)
7369 {
7370 UNIMPLEMENTED();
7371 }
7372
glTexCoord3dv(const GLdouble * v)7373 void APIENTRY glTexCoord3dv(const GLdouble *v)
7374 {
7375 UNIMPLEMENTED();
7376 }
7377
glTexCoord3f(GLfloat s,GLfloat t,GLfloat r)7378 void APIENTRY glTexCoord3f(GLfloat s, GLfloat t, GLfloat r)
7379 {
7380 UNIMPLEMENTED();
7381 }
7382
glTexCoord3fv(const GLfloat * v)7383 void APIENTRY glTexCoord3fv(const GLfloat *v)
7384 {
7385 UNIMPLEMENTED();
7386 }
7387
glTexCoord3i(GLint s,GLint t,GLint r)7388 void APIENTRY glTexCoord3i(GLint s, GLint t, GLint r)
7389 {
7390 UNIMPLEMENTED();
7391 }
7392
glTexCoord3iv(const GLint * v)7393 void APIENTRY glTexCoord3iv(const GLint *v)
7394 {
7395 UNIMPLEMENTED();
7396 }
7397
glTexCoord3s(GLshort s,GLshort t,GLshort r)7398 void APIENTRY glTexCoord3s(GLshort s, GLshort t, GLshort r)
7399 {
7400 UNIMPLEMENTED();
7401 }
7402
glTexCoord3sv(const GLshort * v)7403 void APIENTRY glTexCoord3sv(const GLshort *v)
7404 {
7405 UNIMPLEMENTED();
7406 }
7407
glTexCoord4d(GLdouble s,GLdouble t,GLdouble r,GLdouble q)7408 void APIENTRY glTexCoord4d(GLdouble s, GLdouble t, GLdouble r, GLdouble q)
7409 {
7410 UNIMPLEMENTED();
7411 }
7412
glTexCoord4dv(const GLdouble * v)7413 void APIENTRY glTexCoord4dv(const GLdouble *v)
7414 {
7415 UNIMPLEMENTED();
7416 }
7417
glTexCoord4f(GLfloat s,GLfloat t,GLfloat r,GLfloat q)7418 void APIENTRY glTexCoord4f(GLfloat s, GLfloat t, GLfloat r, GLfloat q)
7419 {
7420 UNIMPLEMENTED();
7421 }
7422
glTexCoord4fv(const GLfloat * v)7423 void APIENTRY glTexCoord4fv(const GLfloat *v)
7424 {
7425 UNIMPLEMENTED();
7426 }
7427
glTexCoord4i(GLint s,GLint t,GLint r,GLint q)7428 void APIENTRY glTexCoord4i(GLint s, GLint t, GLint r, GLint q)
7429 {
7430 UNIMPLEMENTED();
7431 }
7432
glTexCoord4iv(const GLint * v)7433 void APIENTRY glTexCoord4iv(const GLint *v)
7434 {
7435 UNIMPLEMENTED();
7436 }
7437
glTexCoord4s(GLshort s,GLshort t,GLshort r,GLshort q)7438 void APIENTRY glTexCoord4s(GLshort s, GLshort t, GLshort r, GLshort q)
7439 {
7440 UNIMPLEMENTED();
7441 }
7442
glTexCoord4sv(const GLshort * v)7443 void APIENTRY glTexCoord4sv(const GLshort *v)
7444 {
7445 UNIMPLEMENTED();
7446 }
7447
glTexCoordPointer(GLint size,GLenum type,GLsizei stride,const GLvoid * pointer)7448 void APIENTRY glTexCoordPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer)
7449 {
7450 TRACE("(*)");
7451
7452 gl::Context *context = gl::getContext();
7453
7454 if(context)
7455 {
7456 GLenum texture = context->getClientActiveTexture();
7457
7458 glVertexAttribPointer(sw::TexCoord0 + (texture - GL_TEXTURE0), size, type, false, stride, pointer);
7459 }
7460 }
7461
glTexEnvf(GLenum target,GLenum pname,GLfloat param)7462 void APIENTRY glTexEnvf(GLenum target, GLenum pname, GLfloat param)
7463 {
7464 UNIMPLEMENTED();
7465 }
7466
glTexEnvfv(GLenum target,GLenum pname,const GLfloat * params)7467 void APIENTRY glTexEnvfv(GLenum target, GLenum pname, const GLfloat *params)
7468 {
7469 UNIMPLEMENTED();
7470 }
7471
glTexEnvi(GLenum target,GLenum pname,GLint param)7472 void APIENTRY glTexEnvi(GLenum target, GLenum pname, GLint param)
7473 {
7474 UNIMPLEMENTED();
7475 }
7476
glTexEnviv(GLenum target,GLenum pname,const GLint * params)7477 void APIENTRY glTexEnviv(GLenum target, GLenum pname, const GLint *params)
7478 {
7479 UNIMPLEMENTED();
7480 }
7481
glTexGend(GLenum coord,GLenum pname,GLdouble param)7482 void APIENTRY glTexGend(GLenum coord, GLenum pname, GLdouble param)
7483 {
7484 UNIMPLEMENTED();
7485 }
7486
glTexGendv(GLenum coord,GLenum pname,const GLdouble * params)7487 void APIENTRY glTexGendv(GLenum coord, GLenum pname, const GLdouble *params)
7488 {
7489 UNIMPLEMENTED();
7490 }
7491
glTexGenf(GLenum coord,GLenum pname,GLfloat param)7492 void APIENTRY glTexGenf(GLenum coord, GLenum pname, GLfloat param)
7493 {
7494 UNIMPLEMENTED();
7495 }
7496
glTexGenfv(GLenum coord,GLenum pname,const GLfloat * params)7497 void APIENTRY glTexGenfv(GLenum coord, GLenum pname, const GLfloat *params)
7498 {
7499 UNIMPLEMENTED();
7500 }
7501
glTexGeni(GLenum coord,GLenum pname,GLint param)7502 void APIENTRY glTexGeni(GLenum coord, GLenum pname, GLint param)
7503 {
7504 UNIMPLEMENTED();
7505 }
7506
glTexGeniv(GLenum coord,GLenum pname,const GLint * params)7507 void APIENTRY glTexGeniv(GLenum coord, GLenum pname, const GLint *params)
7508 {
7509 UNIMPLEMENTED();
7510 }
7511
glTexImage1D(GLenum target,GLint level,GLint internalformat,GLsizei width,GLint border,GLenum format,GLenum type,const GLvoid * pixels)7512 void APIENTRY glTexImage1D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const GLvoid *pixels)
7513 {
7514 UNIMPLEMENTED();
7515 }
7516
glTexSubImage1D(GLenum target,GLint level,GLint xoffset,GLsizei width,GLenum format,GLenum type,const GLvoid * pixels)7517 void APIENTRY glTexSubImage1D(GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid *pixels)
7518 {
7519 UNIMPLEMENTED();
7520 }
7521
glTranslated(GLdouble x,GLdouble y,GLdouble z)7522 void APIENTRY glTranslated(GLdouble x, GLdouble y, GLdouble z)
7523 {
7524 TRACE("(*)");
7525
7526 gl::Context *context = gl::getContext();
7527
7528 if(context)
7529 {
7530 if(context->getListIndex() != 0)
7531 {
7532 return context->listCommand(gl::newCommand(glTranslated, x, y, z));
7533 }
7534
7535 context->translate(x, y, z); // FIXME
7536 }
7537 }
7538
glTranslatef(GLfloat x,GLfloat y,GLfloat z)7539 void APIENTRY glTranslatef(GLfloat x, GLfloat y, GLfloat z)
7540 {
7541 TRACE("(GLfloat x = %f, GLfloat y = %f, GLfloat z = %f)", x, y, z);
7542
7543 gl::Context *context = gl::getContext();
7544
7545 if(context)
7546 {
7547 if(context->getListIndex() != 0)
7548 {
7549 return context->listCommand(gl::newCommand(glTranslatef, x, y, z));
7550 }
7551
7552 context->translate(x, y, z);
7553 }
7554 }
7555
glVertex2d(GLdouble x,GLdouble y)7556 void APIENTRY glVertex2d(GLdouble x, GLdouble y)
7557 {
7558 UNIMPLEMENTED();
7559 }
7560
glVertex2dv(const GLdouble * v)7561 void APIENTRY glVertex2dv(const GLdouble *v)
7562 {
7563 UNIMPLEMENTED();
7564 }
7565
glVertex2f(GLfloat x,GLfloat y)7566 void APIENTRY glVertex2f(GLfloat x, GLfloat y)
7567 {
7568 UNIMPLEMENTED();
7569 }
7570
glVertex2fv(const GLfloat * v)7571 void APIENTRY glVertex2fv(const GLfloat *v)
7572 {
7573 UNIMPLEMENTED();
7574 }
7575
glVertex2i(GLint x,GLint y)7576 void APIENTRY glVertex2i(GLint x, GLint y)
7577 {
7578 UNIMPLEMENTED();
7579 }
7580
glVertex2iv(const GLint * v)7581 void APIENTRY glVertex2iv(const GLint *v)
7582 {
7583 UNIMPLEMENTED();
7584 }
7585
glVertex2s(GLshort x,GLshort y)7586 void APIENTRY glVertex2s(GLshort x, GLshort y)
7587 {
7588 UNIMPLEMENTED();
7589 }
7590
glVertex2sv(const GLshort * v)7591 void APIENTRY glVertex2sv(const GLshort *v)
7592 {
7593 UNIMPLEMENTED();
7594 }
7595
glVertex3d(GLdouble x,GLdouble y,GLdouble z)7596 void APIENTRY glVertex3d(GLdouble x, GLdouble y, GLdouble z)
7597 {
7598 UNIMPLEMENTED();
7599 }
7600
glVertex3dv(const GLdouble * v)7601 void APIENTRY glVertex3dv(const GLdouble *v)
7602 {
7603 UNIMPLEMENTED();
7604 }
7605
glVertex3f(GLfloat x,GLfloat y,GLfloat z)7606 void APIENTRY glVertex3f(GLfloat x, GLfloat y, GLfloat z)
7607 {
7608 TRACE("(GLfloat x = %f, GLfloat y = %f, GLfloat z = %f)", x, y, z);
7609
7610 gl::Context *context = gl::getContext();
7611
7612 if(context)
7613 {
7614 if(context->getListIndex() != 0)
7615 {
7616 UNIMPLEMENTED();
7617 }
7618
7619 context->position(x, y, z, 1.0f);
7620 }
7621 }
7622
glVertex3fv(const GLfloat * v)7623 void APIENTRY glVertex3fv(const GLfloat *v)
7624 {
7625 UNIMPLEMENTED();
7626 }
7627
glVertex3i(GLint x,GLint y,GLint z)7628 void APIENTRY glVertex3i(GLint x, GLint y, GLint z)
7629 {
7630 UNIMPLEMENTED();
7631 }
7632
glVertex3iv(const GLint * v)7633 void APIENTRY glVertex3iv(const GLint *v)
7634 {
7635 UNIMPLEMENTED();
7636 }
7637
glVertex3s(GLshort x,GLshort y,GLshort z)7638 void APIENTRY glVertex3s(GLshort x, GLshort y, GLshort z)
7639 {
7640 UNIMPLEMENTED();
7641 }
7642
glVertex3sv(const GLshort * v)7643 void APIENTRY glVertex3sv(const GLshort *v)
7644 {
7645 UNIMPLEMENTED();
7646 }
7647
glVertex4d(GLdouble x,GLdouble y,GLdouble z,GLdouble w)7648 void APIENTRY glVertex4d(GLdouble x, GLdouble y, GLdouble z, GLdouble w)
7649 {
7650 UNIMPLEMENTED();
7651 }
7652
glVertex4dv(const GLdouble * v)7653 void APIENTRY glVertex4dv(const GLdouble *v)
7654 {
7655 UNIMPLEMENTED();
7656 }
7657
glVertex4f(GLfloat x,GLfloat y,GLfloat z,GLfloat w)7658 void APIENTRY glVertex4f(GLfloat x, GLfloat y, GLfloat z, GLfloat w)
7659 {
7660 UNIMPLEMENTED();
7661 }
7662
glVertex4fv(const GLfloat * v)7663 void APIENTRY glVertex4fv(const GLfloat *v)
7664 {
7665 UNIMPLEMENTED();
7666 }
7667
glVertex4i(GLint x,GLint y,GLint z,GLint w)7668 void APIENTRY glVertex4i(GLint x, GLint y, GLint z, GLint w)
7669 {
7670 UNIMPLEMENTED();
7671 }
7672
glVertex4iv(const GLint * v)7673 void APIENTRY glVertex4iv(const GLint *v)
7674 {
7675 UNIMPLEMENTED();
7676 }
7677
glVertex4s(GLshort x,GLshort y,GLshort z,GLshort w)7678 void APIENTRY glVertex4s(GLshort x, GLshort y, GLshort z, GLshort w)
7679 {
7680 UNIMPLEMENTED();
7681 }
7682
glVertex4sv(const GLshort * v)7683 void APIENTRY glVertex4sv(const GLshort *v)
7684 {
7685 UNIMPLEMENTED();
7686 }
7687
glVertexPointer(GLint size,GLenum type,GLsizei stride,const GLvoid * pointer)7688 void APIENTRY glVertexPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer)
7689 {
7690 TRACE("(GLint size = %d, GLenum type = 0x%X, GLsizei stride = %d, const GLvoid *pointer = %p)", size, type, stride, pointer);
7691
7692 glVertexAttribPointer(sw::Position, size, type, false, stride, pointer);
7693 }
7694
glDrawRangeElements(GLenum mode,GLuint start,GLuint end,GLsizei count,GLenum type,const void * indices)7695 void APIENTRY glDrawRangeElements(GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void *indices) {UNIMPLEMENTED();}
glTexImage3D(GLenum target,GLint level,GLint internalformat,GLsizei width,GLsizei height,GLsizei depth,GLint border,GLenum format,GLenum type,const void * pixels)7696 void APIENTRY glTexImage3D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void *pixels) {UNIMPLEMENTED();}
glTexSubImage3D(GLenum target,GLint level,GLint xoffset,GLint yoffset,GLint zoffset,GLsizei width,GLsizei height,GLsizei depth,GLenum format,GLenum type,const void * pixels)7697 void APIENTRY glTexSubImage3D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels) {UNIMPLEMENTED();}
glCopyTexSubImage3D(GLenum target,GLint level,GLint xoffset,GLint yoffset,GLint zoffset,GLint x,GLint y,GLsizei width,GLsizei height)7698 void APIENTRY glCopyTexSubImage3D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height) {UNIMPLEMENTED();}
7699
glClientActiveTexture(GLenum texture)7700 void APIENTRY glClientActiveTexture(GLenum texture)
7701 {
7702 TRACE("(GLenum texture = 0x%X)", texture);
7703
7704 switch(texture)
7705 {
7706 case GL_TEXTURE0:
7707 case GL_TEXTURE1:
7708 break;
7709 default:
7710 UNIMPLEMENTED();
7711 UNREACHABLE(texture);
7712 }
7713
7714 gl::Context *context = gl::getContext();
7715
7716 if(context)
7717 {
7718 context->clientActiveTexture(texture);
7719 }
7720 }
7721
glCompressedTexImage1D(GLenum target,GLint level,GLenum internalformat,GLsizei width,GLint border,GLsizei imageSize,const void * data)7722 void APIENTRY glCompressedTexImage1D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const void *data) {UNIMPLEMENTED();}
glCompressedTexImage3D(GLenum target,GLint level,GLenum internalformat,GLsizei width,GLsizei height,GLsizei depth,GLint border,GLsizei imageSize,const void * data)7723 void APIENTRY glCompressedTexImage3D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void *data) {UNIMPLEMENTED();}
glCompressedTexSubImage1D(GLenum target,GLint level,GLint xoffset,GLsizei width,GLenum format,GLsizei imageSize,const void * data)7724 void APIENTRY glCompressedTexSubImage1D(GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void *data) {UNIMPLEMENTED();}
glCompressedTexSubImage3D(GLenum target,GLint level,GLint xoffset,GLint yoffset,GLint zoffset,GLsizei width,GLsizei height,GLsizei depth,GLenum format,GLsizei imageSize,const void * data)7725 void APIENTRY glCompressedTexSubImage3D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *data) {UNIMPLEMENTED();}
glGetCompressedTexImage(GLenum target,GLint level,void * img)7726 void APIENTRY glGetCompressedTexImage(GLenum target, GLint level, void *img) {UNIMPLEMENTED();}
glMultiTexCoord1f(GLenum target,GLfloat s)7727 void APIENTRY glMultiTexCoord1f(GLenum target, GLfloat s) {UNIMPLEMENTED();}
glMultiTexCoord1d(GLenum target,GLdouble s)7728 void APIENTRY glMultiTexCoord1d(GLenum target, GLdouble s) {UNIMPLEMENTED();}
7729
glMultiTexCoord2f(GLenum texture,GLfloat s,GLfloat t)7730 void APIENTRY glMultiTexCoord2f(GLenum texture, GLfloat s, GLfloat t)
7731 {
7732 TRACE("(GLenum texture = 0x%X, GLfloat s = %f, GLfloat t = %f)", texture, s, t);
7733
7734 gl::Context *context = gl::getContext();
7735
7736 if(context)
7737 {
7738 if(context->getListIndex() != 0)
7739 {
7740 UNIMPLEMENTED();
7741 }
7742
7743 //context->texCoord(s, t, 0.0f, 1.0f);
7744 context->setVertexAttrib(sw::TexCoord0 + (texture - GL_TEXTURE0), s, t, 0.0f, 1.0f);
7745 }
7746 }
7747
glMultiTexCoord2d(GLenum target,GLdouble s,GLdouble t)7748 void APIENTRY glMultiTexCoord2d(GLenum target, GLdouble s, GLdouble t) {UNIMPLEMENTED();}
glMultiTexCoord3f(GLenum target,GLfloat s,GLfloat t,GLfloat r)7749 void APIENTRY glMultiTexCoord3f(GLenum target, GLfloat s, GLfloat t, GLfloat r) {UNIMPLEMENTED();}
glMultiTexCoord3d(GLenum target,GLdouble s,GLdouble t,GLdouble r)7750 void APIENTRY glMultiTexCoord3d(GLenum target, GLdouble s, GLdouble t, GLdouble r) {UNIMPLEMENTED();}
glMultiTexCoord4f(GLenum target,GLfloat s,GLfloat t,GLfloat r,GLfloat q)7751 void APIENTRY glMultiTexCoord4f(GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q) {UNIMPLEMENTED();}
glMultiTexCoord4d(GLenum target,GLdouble s,GLdouble t,GLdouble r,GLdouble q)7752 void APIENTRY glMultiTexCoord4d(GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q) {UNIMPLEMENTED();}
glLoadTransposeMatrixf(const GLfloat * m)7753 void APIENTRY glLoadTransposeMatrixf(const GLfloat *m) {UNIMPLEMENTED();}
glLoadTransposeMatrixd(const GLdouble * m)7754 void APIENTRY glLoadTransposeMatrixd(const GLdouble *m) {UNIMPLEMENTED();}
glMultTransposeMatrixf(const GLfloat * m)7755 void APIENTRY glMultTransposeMatrixf(const GLfloat *m) {UNIMPLEMENTED();}
glMultTransposeMatrixd(const GLdouble * m)7756 void APIENTRY glMultTransposeMatrixd(const GLdouble *m) {UNIMPLEMENTED();}
glFogCoordf(GLfloat coord)7757 void APIENTRY glFogCoordf(GLfloat coord) {UNIMPLEMENTED();}
glFogCoordd(GLdouble coord)7758 void APIENTRY glFogCoordd(GLdouble coord) {UNIMPLEMENTED();}
glFogCoordPointer(GLenum type,GLsizei stride,const void * pointer)7759 void APIENTRY glFogCoordPointer(GLenum type, GLsizei stride, const void *pointer) {UNIMPLEMENTED();}
glMultiDrawArrays(GLenum mode,const GLint * first,const GLsizei * count,GLsizei drawcount)7760 void APIENTRY glMultiDrawArrays(GLenum mode, const GLint *first, const GLsizei *count, GLsizei drawcount) {UNIMPLEMENTED();}
glPointParameteri(GLenum pname,GLint param)7761 void APIENTRY glPointParameteri(GLenum pname, GLint param) {UNIMPLEMENTED();}
glPointParameterf(GLenum pname,GLfloat param)7762 void APIENTRY glPointParameterf(GLenum pname, GLfloat param) {UNIMPLEMENTED();}
glPointParameteriv(GLenum pname,const GLint * params)7763 void APIENTRY glPointParameteriv(GLenum pname, const GLint *params) {UNIMPLEMENTED();}
glPointParameterfv(GLenum pname,const GLfloat * params)7764 void APIENTRY glPointParameterfv(GLenum pname, const GLfloat *params) {UNIMPLEMENTED();}
glSecondaryColor3b(GLbyte red,GLbyte green,GLbyte blue)7765 void APIENTRY glSecondaryColor3b(GLbyte red, GLbyte green, GLbyte blue) {UNIMPLEMENTED();}
glSecondaryColor3f(GLfloat red,GLfloat green,GLfloat blue)7766 void APIENTRY glSecondaryColor3f(GLfloat red, GLfloat green, GLfloat blue) {UNIMPLEMENTED();}
glSecondaryColor3d(GLdouble red,GLdouble green,GLdouble blue)7767 void APIENTRY glSecondaryColor3d(GLdouble red, GLdouble green, GLdouble blue) {UNIMPLEMENTED();}
glSecondaryColor3ub(GLubyte red,GLubyte green,GLubyte blue)7768 void APIENTRY glSecondaryColor3ub(GLubyte red, GLubyte green, GLubyte blue) {UNIMPLEMENTED();}
glSecondaryColorPointer(GLint size,GLenum type,GLsizei stride,const void * pointer)7769 void APIENTRY glSecondaryColorPointer(GLint size, GLenum type, GLsizei stride, const void *pointer) {UNIMPLEMENTED();}
glWindowPos2f(GLfloat x,GLfloat y)7770 void APIENTRY glWindowPos2f(GLfloat x, GLfloat y) {UNIMPLEMENTED();}
glWindowPos2d(GLdouble x,GLdouble y)7771 void APIENTRY glWindowPos2d(GLdouble x, GLdouble y) {UNIMPLEMENTED();}
glWindowPos2i(GLint x,GLint y)7772 void APIENTRY glWindowPos2i(GLint x, GLint y) {UNIMPLEMENTED();}
glWindowPos3f(GLfloat x,GLfloat y,GLfloat z)7773 void APIENTRY glWindowPos3f(GLfloat x, GLfloat y, GLfloat z) {UNIMPLEMENTED();}
glWindowPos3d(GLdouble x,GLdouble y,GLdouble z)7774 void APIENTRY glWindowPos3d(GLdouble x, GLdouble y, GLdouble z) {UNIMPLEMENTED();}
glWindowPos3i(GLint x,GLint y,GLint z)7775 void APIENTRY glWindowPos3i(GLint x, GLint y, GLint z) {UNIMPLEMENTED();}
glGetBufferSubData(GLenum target,GLintptr offset,GLsizeiptr size,void * data)7776 void APIENTRY glGetBufferSubData(GLenum target, GLintptr offset, GLsizeiptr size, void *data) {UNIMPLEMENTED();}
glMapBuffer(GLenum target,GLenum access)7777 void *APIENTRY glMapBuffer(GLenum target, GLenum access) {UNIMPLEMENTED(); return 0;}
glUnmapBuffer(GLenum target)7778 GLboolean APIENTRY glUnmapBuffer(GLenum target) {UNIMPLEMENTED(); return GL_FALSE;}
glGetBufferPointerv(GLenum target,GLenum pname,void ** params)7779 void APIENTRY glGetBufferPointerv(GLenum target, GLenum pname, void **params) {UNIMPLEMENTED();}
glGenQueries(GLsizei n,GLuint * ids)7780 void APIENTRY glGenQueries(GLsizei n, GLuint *ids) {UNIMPLEMENTED();}
glDeleteQueries(GLsizei n,const GLuint * ids)7781 void APIENTRY glDeleteQueries(GLsizei n, const GLuint *ids) {UNIMPLEMENTED();}
glIsQuery(GLuint id)7782 GLboolean APIENTRY glIsQuery(GLuint id) {UNIMPLEMENTED(); return 0;}
glBeginQuery(GLenum target,GLuint id)7783 void APIENTRY glBeginQuery(GLenum target, GLuint id) {UNIMPLEMENTED();}
glEndQuery(GLenum target)7784 void APIENTRY glEndQuery(GLenum target) {UNIMPLEMENTED();}
glGetQueryiv(GLenum target,GLenum pname,GLint * params)7785 void APIENTRY glGetQueryiv(GLenum target, GLenum pname, GLint *params) {UNIMPLEMENTED();}
glGetQueryObjectiv(GLuint id,GLenum pname,GLint * params)7786 void APIENTRY glGetQueryObjectiv(GLuint id, GLenum pname, GLint *params) {UNIMPLEMENTED();}
glGetQueryObjectuiv(GLuint id,GLenum pname,GLuint * params)7787 void APIENTRY glGetQueryObjectuiv(GLuint id, GLenum pname, GLuint *params) {UNIMPLEMENTED();}
glVertexAttrib1s(GLuint index,GLshort x)7788 void APIENTRY glVertexAttrib1s(GLuint index, GLshort x) {UNIMPLEMENTED();}
glVertexAttrib1d(GLuint index,GLdouble x)7789 void APIENTRY glVertexAttrib1d(GLuint index, GLdouble x) {UNIMPLEMENTED();}
glVertexAttrib2s(GLuint index,GLshort x,GLshort y)7790 void APIENTRY glVertexAttrib2s(GLuint index, GLshort x, GLshort y) {UNIMPLEMENTED();}
glVertexAttrib2d(GLuint index,GLdouble x,GLdouble y)7791 void APIENTRY glVertexAttrib2d(GLuint index, GLdouble x, GLdouble y) {UNIMPLEMENTED();}
glVertexAttrib3s(GLuint index,GLshort x,GLshort y,GLshort z)7792 void APIENTRY glVertexAttrib3s(GLuint index, GLshort x, GLshort y, GLshort z) {UNIMPLEMENTED();}
glVertexAttrib3d(GLuint index,GLdouble x,GLdouble y,GLdouble z)7793 void APIENTRY glVertexAttrib3d(GLuint index, GLdouble x, GLdouble y, GLdouble z) {UNIMPLEMENTED();}
glVertexAttrib4s(GLuint index,GLshort x,GLshort y,GLshort z,GLshort w)7794 void APIENTRY glVertexAttrib4s(GLuint index, GLshort x, GLshort y, GLshort z, GLshort w) {UNIMPLEMENTED();}
glVertexAttrib4d(GLuint index,GLdouble x,GLdouble y,GLdouble z,GLdouble w)7795 void APIENTRY glVertexAttrib4d(GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w) {UNIMPLEMENTED();}
glVertexAttrib4Nub(GLuint index,GLubyte x,GLubyte y,GLubyte z,GLubyte w)7796 void APIENTRY glVertexAttrib4Nub(GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w) {UNIMPLEMENTED();}
glGetVertexAttribdv(GLuint index,GLenum pname,GLdouble * params)7797 void APIENTRY glGetVertexAttribdv(GLuint index, GLenum pname, GLdouble *params) {UNIMPLEMENTED();}
glDrawBuffers(GLsizei n,const GLenum * bufs)7798 void APIENTRY glDrawBuffers(GLsizei n, const GLenum *bufs) {UNIMPLEMENTED();}
glUniformMatrix2x3fv(GLint location,GLsizei count,GLboolean transpose,const GLfloat * value)7799 void APIENTRY glUniformMatrix2x3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value) {UNIMPLEMENTED();}
glUniformMatrix3x2fv(GLint location,GLsizei count,GLboolean transpose,const GLfloat * value)7800 void APIENTRY glUniformMatrix3x2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value) {UNIMPLEMENTED();}
glUniformMatrix2x4fv(GLint location,GLsizei count,GLboolean transpose,const GLfloat * value)7801 void APIENTRY glUniformMatrix2x4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value) {UNIMPLEMENTED();}
glUniformMatrix4x2fv(GLint location,GLsizei count,GLboolean transpose,const GLfloat * value)7802 void APIENTRY glUniformMatrix4x2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value) {UNIMPLEMENTED();}
glUniformMatrix3x4fv(GLint location,GLsizei count,GLboolean transpose,const GLfloat * value)7803 void APIENTRY glUniformMatrix3x4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value) {UNIMPLEMENTED();}
glUniformMatrix4x3fv(GLint location,GLsizei count,GLboolean transpose,const GLfloat * value)7804 void APIENTRY glUniformMatrix4x3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value) {UNIMPLEMENTED();}
7805
glFramebufferTextureLayer(GLenum target,GLenum attachment,GLuint texture,GLint level,GLint layer)7806 void APIENTRY glFramebufferTextureLayer(GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer) {UNIMPLEMENTED();}
glRenderbufferStorageMultisample(GLenum target,GLsizei samples,GLenum internalformat,GLsizei width,GLsizei height)7807 void APIENTRY glRenderbufferStorageMultisample(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height) {UNIMPLEMENTED();}
glBlitFramebuffer(GLint srcX0,GLint srcY0,GLint srcX1,GLint srcY1,GLint dstX0,GLint dstY0,GLint dstX1,GLint dstY1,GLbitfield mask,GLenum filter)7808 void APIENTRY glBlitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter) {UNIMPLEMENTED();}
7809
wglSwapIntervalEXT(int interval)7810 BOOL WINAPI wglSwapIntervalEXT(int interval)
7811 {
7812 gl::Surface *drawSurface = static_cast<gl::Surface*>(gl::getCurrentDrawSurface());
7813
7814 if(drawSurface)
7815 {
7816 drawSurface->setSwapInterval(interval);
7817 return TRUE;
7818 }
7819
7820 SetLastError(ERROR_DC_NOT_FOUND);
7821 return FALSE;
7822 }
7823
wglChoosePixelFormat(HDC hdc,const PIXELFORMATDESCRIPTOR * ppfd)7824 int WINAPI wglChoosePixelFormat(HDC hdc, const PIXELFORMATDESCRIPTOR *ppfd)
7825 {
7826 TRACE("(*)");
7827
7828 return 1;
7829 }
7830
wglCopyContext(HGLRC,HGLRC,UINT)7831 BOOL WINAPI wglCopyContext(HGLRC, HGLRC, UINT)
7832 {
7833 UNIMPLEMENTED();
7834 return FALSE;
7835 }
7836
wglCreateContext(HDC hdc)7837 HGLRC WINAPI wglCreateContext(HDC hdc)
7838 {
7839 TRACE("(*)");
7840
7841 gl::Display *display = gl::Display::getDisplay(hdc);
7842 display->initialize();
7843
7844 gl::Context *context = display->createContext(nullptr);
7845
7846 return (HGLRC)context;
7847 }
7848
wglCreateLayerContext(HDC,int)7849 HGLRC WINAPI wglCreateLayerContext(HDC, int)
7850 {
7851 UNIMPLEMENTED();
7852 return 0;
7853 }
7854
wglDeleteContext(HGLRC context)7855 BOOL WINAPI wglDeleteContext(HGLRC context)
7856 {
7857 gl::Display *display = gl::getDisplay();
7858
7859 if(display && context)
7860 {
7861 display->destroyContext(reinterpret_cast<gl::Context*>(context));
7862
7863 return TRUE;
7864 }
7865
7866 return FALSE;
7867 }
7868
wglDescribeLayerPlane(HDC,int,int,UINT,LPLAYERPLANEDESCRIPTOR)7869 BOOL WINAPI wglDescribeLayerPlane(HDC, int, int, UINT, LPLAYERPLANEDESCRIPTOR)
7870 {
7871 UNIMPLEMENTED();
7872 return FALSE;
7873 }
7874
wglDescribePixelFormat(HDC hdc,int iPixelFormat,UINT nBytes,LPPIXELFORMATDESCRIPTOR ppfd)7875 int WINAPI wglDescribePixelFormat(HDC hdc, int iPixelFormat, UINT nBytes, LPPIXELFORMATDESCRIPTOR ppfd)
7876 {
7877 TRACE("(*)");
7878
7879 ASSERT(nBytes == sizeof(PIXELFORMATDESCRIPTOR)); // FIXME
7880
7881 ppfd->nSize = sizeof(PIXELFORMATDESCRIPTOR);
7882 ppfd->nVersion = 1;
7883 ppfd->dwFlags = PFD_DRAW_TO_WINDOW | PFD_DRAW_TO_BITMAP | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER;
7884 ppfd->iPixelType = PFD_TYPE_RGBA;
7885 ppfd->cColorBits = 32;
7886 ppfd->cRedBits = 8;
7887 ppfd->cRedShift = 16;
7888 ppfd->cGreenBits = 8;
7889 ppfd->cGreenShift = 8;
7890 ppfd->cBlueBits = 8;
7891 ppfd->cBlueShift = 0;
7892 ppfd->cAlphaBits = 0;
7893 ppfd->cAlphaShift = 24;
7894 ppfd->cAccumBits = 0;
7895 ppfd->cAccumRedBits = 0;
7896 ppfd->cAccumGreenBits = 0;
7897 ppfd->cAccumBlueBits = 0;
7898 ppfd->cAccumAlphaBits = 0;
7899 ppfd->cDepthBits = 24;
7900 ppfd->cStencilBits = 0;
7901 ppfd->cAuxBuffers = 0;
7902 ppfd->iLayerType = 0;
7903 ppfd->bReserved = 0;
7904 ppfd->dwLayerMask = 0;
7905 ppfd->dwVisibleMask = 0;
7906 ppfd->dwDamageMask = 0;
7907
7908 return 1;
7909 }
7910
wglGetCurrentContext(VOID)7911 HGLRC WINAPI wglGetCurrentContext(VOID)
7912 {
7913 TRACE("(*)");
7914 return (HGLRC)gl::getContext();
7915 }
7916
wglGetCurrentDC(VOID)7917 HDC WINAPI wglGetCurrentDC(VOID)
7918 {
7919 TRACE("(*)");
7920 gl::Display *display = gl::getDisplay();
7921 return display ? display->getNativeDisplay() : 0;
7922 }
7923
wglGetDefaultProcAddress()7924 void WINAPI wglGetDefaultProcAddress()
7925 {
7926 UNIMPLEMENTED();
7927 }
7928
wglGetLayerPaletteEntries(HDC,int,int,int,COLORREF *)7929 int WINAPI wglGetLayerPaletteEntries(HDC, int, int, int, COLORREF*)
7930 {
7931 UNIMPLEMENTED();
7932 return 0;
7933 }
7934
wglGetPixelFormat()7935 void WINAPI wglGetPixelFormat()
7936 {
7937 UNIMPLEMENTED();
7938 }
7939
wglGetExtensionsStringARB(HDC hdc)7940 const char *WINAPI wglGetExtensionsStringARB(HDC hdc)
7941 {
7942 TRACE("(*)");
7943
7944 return "GL_ARB_framebuffer_object "
7945 "WGL_EXT_extensions_string "
7946 "WGL_EXT_swap_control";
7947 }
7948
wglGetExtensionsStringEXT()7949 const char *WINAPI wglGetExtensionsStringEXT()
7950 {
7951 TRACE("(*)");
7952 return wglGetExtensionsStringARB(0);
7953 }
7954
wglGetProcAddress(LPCSTR lpszProc)7955 PROC WINAPI wglGetProcAddress(LPCSTR lpszProc)
7956 {
7957 TRACE("(LPCSTR lpszProc = \"%s\")", lpszProc);
7958
7959 struct Extension
7960 {
7961 const char *name;
7962 PROC address;
7963 };
7964
7965 static const Extension glExtensions[] =
7966 {
7967 #define EXT(function) {#function, (PROC)function}
7968
7969 // Core 2.1
7970 EXT(glDrawRangeElements),
7971 EXT(glTexImage3D),
7972 EXT(glTexSubImage3D),
7973 EXT(glCopyTexSubImage3D),
7974 EXT(glActiveTexture),
7975 EXT(glClientActiveTexture),
7976 EXT(glCompressedTexImage1D),
7977 EXT(glCompressedTexImage2D),
7978 EXT(glCompressedTexImage3D),
7979 EXT(glCompressedTexSubImage1D),
7980 EXT(glCompressedTexSubImage2D),
7981 EXT(glCompressedTexSubImage3D),
7982 EXT(glGetCompressedTexImage),
7983 EXT(glMultiTexCoord1f),
7984 EXT(glMultiTexCoord1d),
7985 EXT(glMultiTexCoord2f),
7986 EXT(glMultiTexCoord2d),
7987 EXT(glMultiTexCoord3f),
7988 EXT(glMultiTexCoord3d),
7989 EXT(glMultiTexCoord4f),
7990 EXT(glMultiTexCoord4d),
7991 EXT(glLoadTransposeMatrixf),
7992 EXT(glLoadTransposeMatrixd),
7993 EXT(glMultTransposeMatrixf),
7994 EXT(glMultTransposeMatrixd),
7995 EXT(glSampleCoverage),
7996 EXT(glBlendEquation),
7997 EXT(glBlendColor),
7998 EXT(glFogCoordf),
7999 EXT(glFogCoordd),
8000 EXT(glFogCoordPointer),
8001 EXT(glMultiDrawArrays),
8002 EXT(glPointParameteri),
8003 EXT(glPointParameterf),
8004 EXT(glPointParameteriv),
8005 EXT(glPointParameterfv),
8006 EXT(glSecondaryColor3b),
8007 EXT(glSecondaryColor3f),
8008 EXT(glSecondaryColor3d),
8009 EXT(glSecondaryColor3ub),
8010 EXT(glSecondaryColorPointer),
8011 EXT(glBlendFuncSeparate),
8012 EXT(glWindowPos2f),
8013 EXT(glWindowPos2d),
8014 EXT(glWindowPos2i),
8015 EXT(glWindowPos3f),
8016 EXT(glWindowPos3d),
8017 EXT(glWindowPos3i),
8018 EXT(glBindBuffer),
8019 EXT(glDeleteBuffers),
8020 EXT(glGenBuffers),
8021 EXT(glIsBuffer),
8022 EXT(glBufferData),
8023 EXT(glBufferSubData),
8024 EXT(glGetBufferSubData),
8025 EXT(glMapBuffer),
8026 EXT(glUnmapBuffer),
8027 EXT(glGetBufferParameteriv),
8028 EXT(glGetBufferPointerv),
8029 EXT(glGenQueries),
8030 EXT(glDeleteQueries),
8031 EXT(glIsQuery),
8032 EXT(glBeginQuery),
8033 EXT(glEndQuery),
8034 EXT(glGetQueryiv),
8035 EXT(glGetQueryObjectiv),
8036 EXT(glGetQueryObjectuiv),
8037 EXT(glShaderSource),
8038 EXT(glCreateShader),
8039 EXT(glIsShader),
8040 EXT(glCompileShader),
8041 EXT(glDeleteShader),
8042 EXT(glCreateProgram),
8043 EXT(glIsProgram),
8044 EXT(glAttachShader),
8045 EXT(glDetachShader),
8046 EXT(glLinkProgram),
8047 EXT(glUseProgram),
8048 EXT(glValidateProgram),
8049 EXT(glDeleteProgram),
8050 EXT(glUniform1f),
8051 EXT(glUniform2f),
8052 EXT(glUniform3f),
8053 EXT(glUniform4f),
8054 EXT(glUniform1i),
8055 EXT(glUniform2i),
8056 EXT(glUniform3i),
8057 EXT(glUniform4i),
8058 EXT(glUniform1fv),
8059 EXT(glUniform2fv),
8060 EXT(glUniform3fv),
8061 EXT(glUniform4fv),
8062 EXT(glUniform1iv),
8063 EXT(glUniform2iv),
8064 EXT(glUniform3iv),
8065 EXT(glUniform4iv),
8066 EXT(glUniformMatrix2fv),
8067 EXT(glUniformMatrix3fv),
8068 EXT(glUniformMatrix4fv),
8069 EXT(glGetShaderiv),
8070 EXT(glGetProgramiv),
8071 EXT(glGetShaderInfoLog),
8072 EXT(glGetProgramInfoLog),
8073 EXT(glGetAttachedShaders),
8074 EXT(glGetUniformLocation),
8075 EXT(glGetActiveUniform),
8076 EXT(glGetUniformfv),
8077 EXT(glGetUniformiv),
8078 EXT(glGetShaderSource),
8079 EXT(glVertexAttrib1s),
8080 EXT(glVertexAttrib1f),
8081 EXT(glVertexAttrib1d),
8082 EXT(glVertexAttrib2s),
8083 EXT(glVertexAttrib2f),
8084 EXT(glVertexAttrib2d),
8085 EXT(glVertexAttrib3s),
8086 EXT(glVertexAttrib3f),
8087 EXT(glVertexAttrib3d),
8088 EXT(glVertexAttrib4s),
8089 EXT(glVertexAttrib4f),
8090 EXT(glVertexAttrib4d),
8091 EXT(glVertexAttrib4Nub),
8092 EXT(glVertexAttribPointer),
8093 EXT(glEnableVertexAttribArray),
8094 EXT(glDisableVertexAttribArray),
8095 EXT(glGetVertexAttribfv),
8096 EXT(glGetVertexAttribdv),
8097 EXT(glGetVertexAttribiv),
8098 EXT(glGetVertexAttribPointerv),
8099 EXT(glBindAttribLocation),
8100 EXT(glGetActiveAttrib),
8101 EXT(glGetAttribLocation),
8102 EXT(glDrawBuffers),
8103 EXT(glStencilOpSeparate),
8104 EXT(glStencilFuncSeparate),
8105 EXT(glStencilMaskSeparate),
8106 EXT(glBlendEquationSeparate),
8107 EXT(glUniformMatrix2x3fv),
8108 EXT(glUniformMatrix3x2fv),
8109 EXT(glUniformMatrix2x4fv),
8110 EXT(glUniformMatrix4x2fv),
8111 EXT(glUniformMatrix3x4fv),
8112 EXT(glUniformMatrix4x3fv),
8113 EXT(glGenFencesNV),
8114 EXT(glDeleteFencesNV),
8115 EXT(glSetFenceNV),
8116 EXT(glTestFenceNV),
8117 EXT(glFinishFenceNV),
8118 EXT(glIsFenceNV),
8119 EXT(glGetFenceivNV),
8120
8121 EXT(glIsRenderbuffer),
8122 EXT(glBindRenderbuffer),
8123 EXT(glDeleteRenderbuffers),
8124 EXT(glGenRenderbuffers),
8125 EXT(glRenderbufferStorage),
8126 EXT(glGetRenderbufferParameteriv),
8127 EXT(glIsFramebuffer),
8128 EXT(glBindFramebuffer),
8129 EXT(glDeleteFramebuffers),
8130 EXT(glGenFramebuffers),
8131 EXT(glCheckFramebufferStatus),
8132 EXT(glFramebufferTexture1D),
8133 EXT(glFramebufferTexture2D),
8134 EXT(glFramebufferTexture3D),
8135 EXT(glFramebufferRenderbuffer),
8136 EXT(glGetFramebufferAttachmentParameteriv),
8137 EXT(glGenerateMipmap),
8138 EXT(glReleaseShaderCompiler),
8139 EXT(glShaderBinary),
8140 EXT(glGetShaderPrecisionFormat),
8141 EXT(glDepthRangef),
8142 EXT(glClearDepthf),
8143
8144 // ARB
8145 EXT(wglGetExtensionsStringARB),
8146 EXT(glIsRenderbuffer),
8147 EXT(glBindRenderbuffer),
8148 EXT(glDeleteRenderbuffers),
8149 EXT(glGenRenderbuffers),
8150 EXT(glRenderbufferStorage),
8151 EXT(glRenderbufferStorageMultisample),
8152 EXT(glGetRenderbufferParameteriv),
8153 EXT(glIsFramebuffer),
8154 EXT(glBindFramebuffer),
8155 EXT(glDeleteFramebuffers),
8156 EXT(glGenFramebuffers),
8157 EXT(glCheckFramebufferStatus),
8158 EXT(glFramebufferTexture1D),
8159 EXT(glFramebufferTexture2D),
8160 EXT(glFramebufferTexture3D),
8161 EXT(glFramebufferTextureLayer),
8162 EXT(glFramebufferRenderbuffer),
8163 EXT(glGetFramebufferAttachmentParameteriv),
8164 EXT(glBlitFramebuffer),
8165 EXT(glGenerateMipmap),
8166
8167 // EXT
8168 EXT(wglSwapIntervalEXT),
8169 EXT(wglGetExtensionsStringEXT),
8170 #undef EXT
8171 };
8172
8173 for(int ext = 0; ext < sizeof(glExtensions) / sizeof(Extension); ext++)
8174 {
8175 if(strcmp(lpszProc, glExtensions[ext].name) == 0)
8176 {
8177 return (PROC)glExtensions[ext].address;
8178 }
8179 }
8180
8181 FARPROC proc = GetProcAddress(GetModuleHandle("opengl32.dll"), lpszProc); // FIXME?
8182
8183 if(proc)
8184 {
8185 return proc;
8186 }
8187
8188 TRACE("(LPCSTR lpszProc = \"%s\") NOT FOUND!!!", lpszProc);
8189
8190 return 0;
8191 }
8192
wglMakeCurrent(HDC hdc,HGLRC hglrc)8193 BOOL WINAPI wglMakeCurrent(HDC hdc, HGLRC hglrc)
8194 {
8195 TRACE("(*)");
8196
8197 if(hdc && hglrc)
8198 {
8199 gl::Display *display = (gl::Display*)gl::Display::getDisplay(hdc);
8200 gl::makeCurrent((gl::Context*)hglrc, display, display->getPrimarySurface());
8201 gl::setCurrentDrawSurface(display->getPrimarySurface());
8202 gl::setCurrentDisplay(display);
8203 }
8204 else
8205 {
8206 gl::makeCurrent(0, 0, 0);
8207 }
8208
8209 return TRUE;
8210 }
8211
wglRealizeLayerPalette(HDC,int,BOOL)8212 BOOL WINAPI wglRealizeLayerPalette(HDC, int, BOOL)
8213 {
8214 UNIMPLEMENTED();
8215 return FALSE;
8216 }
8217
wglSetLayerPaletteEntries(HDC,int,int,int,CONST COLORREF *)8218 int WINAPI wglSetLayerPaletteEntries(HDC, int, int, int, CONST COLORREF*)
8219 {
8220 UNIMPLEMENTED();
8221 return 0;
8222 }
8223
wglSetPixelFormat(HDC hdc,int iPixelFormat,const PIXELFORMATDESCRIPTOR * ppfd)8224 BOOL WINAPI wglSetPixelFormat(HDC hdc, int iPixelFormat, const PIXELFORMATDESCRIPTOR *ppfd)
8225 {
8226 TRACE("(*)");
8227 //UNIMPLEMENTED();
8228
8229 return TRUE;
8230 }
8231
wglShareLists(HGLRC,HGLRC)8232 BOOL WINAPI wglShareLists(HGLRC, HGLRC)
8233 {
8234 UNIMPLEMENTED();
8235 return FALSE;
8236 }
8237
wglSwapBuffers(HDC hdc)8238 BOOL WINAPI wglSwapBuffers(HDC hdc)
8239 {
8240 TRACE("(*)");
8241
8242 gl::Display *display = gl::getDisplay();
8243
8244 if(display)
8245 {
8246 display->getPrimarySurface()->swap();
8247 return TRUE;
8248 }
8249
8250 return FALSE;
8251 }
8252
wglSwapLayerBuffers(HDC,UINT)8253 BOOL WINAPI wglSwapLayerBuffers(HDC, UINT)
8254 {
8255 UNIMPLEMENTED();
8256 return FALSE;
8257 }
8258
wglSwapMultipleBuffers(UINT,CONST WGLSWAP *)8259 DWORD WINAPI wglSwapMultipleBuffers(UINT, CONST WGLSWAP*)
8260 {
8261 UNIMPLEMENTED();
8262 return 0;
8263 }
8264
wglUseFontBitmapsA(HDC,DWORD,DWORD,DWORD)8265 BOOL WINAPI wglUseFontBitmapsA(HDC, DWORD, DWORD, DWORD)
8266 {
8267 UNIMPLEMENTED();
8268 return FALSE;
8269 }
8270
wglUseFontBitmapsW(HDC,DWORD,DWORD,DWORD)8271 BOOL WINAPI wglUseFontBitmapsW(HDC, DWORD, DWORD, DWORD)
8272 {
8273 UNIMPLEMENTED();
8274 return FALSE;
8275 }
8276
wglUseFontOutlinesA(HDC,DWORD,DWORD,DWORD,FLOAT,FLOAT,int,LPGLYPHMETRICSFLOAT)8277 BOOL WINAPI wglUseFontOutlinesA(HDC, DWORD, DWORD, DWORD, FLOAT, FLOAT, int, LPGLYPHMETRICSFLOAT)
8278 {
8279 UNIMPLEMENTED();
8280 return FALSE;
8281 }
8282
wglUseFontOutlinesW(HDC,DWORD,DWORD,DWORD,FLOAT,FLOAT,int,LPGLYPHMETRICSFLOAT)8283 BOOL WINAPI wglUseFontOutlinesW(HDC, DWORD, DWORD, DWORD, FLOAT, FLOAT, int, LPGLYPHMETRICSFLOAT)
8284 {
8285 UNIMPLEMENTED();
8286 return FALSE;
8287 }
8288
8289 }
8290