|
1 /* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). |
|
2 * |
|
3 * Permission is hereby granted, free of charge, to any person obtaining a |
|
4 * copy of this software and associated documentation files (the "Software"), |
|
5 * to deal in the Software without restriction, including without limitation |
|
6 * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
|
7 * and/or sell copies of the Software, and to permit persons to whom the |
|
8 * Software is furnished to do so, subject to the following conditions: |
|
9 * |
|
10 * The above copyright notice and this permission notice shall be included |
|
11 * in all copies or substantial portions of the Software. |
|
12 * |
|
13 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
|
14 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
|
15 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
|
16 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN |
|
17 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN |
|
18 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
|
19 * |
|
20 * Initial Contributors: |
|
21 * Nokia Corporation - initial contribution. |
|
22 * |
|
23 * Contributors: |
|
24 * |
|
25 * Description: |
|
26 * |
|
27 */ |
|
28 |
|
29 #include "common.h" |
|
30 #include "hgl.h" |
|
31 #include "context.h" |
|
32 |
|
33 static GLboolean dglIsValidCapability(GLenum cap) |
|
34 { |
|
35 switch(cap) |
|
36 { |
|
37 case GL_TEXTURE_2D: |
|
38 case GL_CULL_FACE: |
|
39 case GL_POLYGON_OFFSET_FILL: |
|
40 case GL_SAMPLE_ALPHA_TO_COVERAGE: |
|
41 case GL_SAMPLE_COVERAGE: |
|
42 case GL_SCISSOR_TEST: |
|
43 case GL_STENCIL_TEST: |
|
44 case GL_DEPTH_TEST: |
|
45 case GL_BLEND: |
|
46 case GL_DITHER: |
|
47 return GL_TRUE; |
|
48 |
|
49 default: |
|
50 return GL_FALSE; |
|
51 } |
|
52 } |
|
53 |
|
54 GL_APICALL_BUILD void GL_APIENTRY glColorMask(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha) |
|
55 { |
|
56 DGLES2_ENTER(); |
|
57 ctx->hgl.ColorMask(red, green, blue, alpha); |
|
58 DGLES2_LEAVE(); |
|
59 } |
|
60 |
|
61 GL_APICALL_BUILD void GL_APIENTRY glCullFace(GLenum mode) |
|
62 { |
|
63 DGLES2_ENTER(); |
|
64 ctx->hgl.CullFace(mode); |
|
65 DGLES2_LEAVE(); |
|
66 } |
|
67 |
|
68 GL_APICALL_BUILD void GL_APIENTRY glDisable(GLenum cap) |
|
69 { |
|
70 DGLES2_ENTER(); |
|
71 DGLES2_ERROR_IF(!dglIsValidCapability(cap), GL_INVALID_ENUM); |
|
72 ctx->hgl.Disable(cap); |
|
73 DGLES2_LEAVE(); |
|
74 } |
|
75 |
|
76 GL_APICALL_BUILD void GL_APIENTRY glEnable(GLenum cap) |
|
77 { |
|
78 DGLES2_ENTER(); |
|
79 DGLES2_ERROR_IF(!dglIsValidCapability(cap), GL_INVALID_ENUM); |
|
80 ctx->hgl.Enable(cap); |
|
81 DGLES2_LEAVE(); |
|
82 } |
|
83 |
|
84 GL_APICALL_BUILD void GL_APIENTRY glFinish(void) |
|
85 { |
|
86 DGLES2_ENTER(); |
|
87 DGLES2_BEGIN_DRAWING(); |
|
88 ctx->hgl.Finish(); |
|
89 DGLES2_END_DRAWING(); |
|
90 DGLES2_LEAVE(); |
|
91 } |
|
92 |
|
93 GL_APICALL_BUILD void GL_APIENTRY glFlush(void) |
|
94 { |
|
95 DGLES2_ENTER(); |
|
96 DGLES2_BEGIN_DRAWING(); |
|
97 ctx->hgl.Flush(); |
|
98 DGLES2_END_DRAWING(); |
|
99 DGLES2_LEAVE(); |
|
100 } |
|
101 |
|
102 GL_APICALL_BUILD void GL_APIENTRY glFrontFace(GLenum mode) |
|
103 { |
|
104 DGLES2_ENTER(); |
|
105 ctx->hgl.FrontFace(mode); |
|
106 DGLES2_LEAVE(); |
|
107 } |
|
108 |
|
109 GL_APICALL_BUILD GLboolean GL_APIENTRY glIsEnabled(GLenum cap) |
|
110 { |
|
111 DGLES2_ENTER_RET(GL_FALSE); |
|
112 DGLES2_ERROR_IF_RET(!dglIsValidCapability(cap), GL_INVALID_ENUM, GL_FALSE); |
|
113 DGLES2_LEAVE_RET(ctx->hgl.IsEnabled(cap)); |
|
114 } |
|
115 |
|
116 GL_APICALL_BUILD void GL_APIENTRY glHint(GLenum target, GLenum mode) |
|
117 { |
|
118 DGLES2_ENTER(); |
|
119 DGLES2_ERROR_IF(target != GL_GENERATE_MIPMAP_HINT, GL_INVALID_ENUM); |
|
120 ctx->hgl.Hint(target, mode); |
|
121 DGLES2_LEAVE(); |
|
122 } |
|
123 |
|
124 GL_APICALL_BUILD void GL_APIENTRY glLineWidth (GLfloat width) |
|
125 { |
|
126 DGLES2_ENTER(); |
|
127 ctx->hgl.LineWidth(width); |
|
128 DGLES2_LEAVE(); |
|
129 } |
|
130 |
|
131 GL_APICALL_BUILD void GL_APIENTRY glPolygonOffset(GLfloat factor, GLfloat units) |
|
132 { |
|
133 DGLES2_ENTER(); |
|
134 ctx->hgl.PolygonOffset(factor, units); |
|
135 DGLES2_LEAVE(); |
|
136 } |
|
137 |
|
138 GL_APICALL_BUILD void GL_APIENTRY glSampleCoverage(GLclampf value, GLboolean invert) |
|
139 { |
|
140 DGLES2_ENTER(); |
|
141 ctx->hgl.SampleCoverage(value, invert); |
|
142 DGLES2_LEAVE(); |
|
143 } |
|
144 |
|
145 GL_APICALL_BUILD void GL_APIENTRY glScissor(GLint x, GLint y, GLsizei width, GLsizei height) |
|
146 { |
|
147 DGLES2_ENTER(); |
|
148 ctx->hgl.Scissor(x, y, width, height); |
|
149 DGLES2_LEAVE(); |
|
150 } |
|
151 |
|
152 GL_APICALL_BUILD void GL_APIENTRY glViewport(GLint x, GLint y, GLsizei width, GLsizei height) |
|
153 { |
|
154 DGLES2_ENTER(); |
|
155 ctx->hgl.Viewport(x, y, width, height); |
|
156 DGLES2_LEAVE(); |
|
157 } |
|
158 |