EmscriptenGL2ES.cpp 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586
  1. //-----------------------------------------------------------------------------
  2. // Copyright (c) 2013 GarageGames, LLC
  3. //
  4. // Permission is hereby granted, free of charge, to any person obtaining a copy
  5. // of this software and associated documentation files (the "Software"), to
  6. // deal in the Software without restriction, including without limitation the
  7. // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  8. // sell copies of the Software, and to permit persons to whom the Software is
  9. // furnished to do so, subject to the following conditions:
  10. //
  11. // The above copyright notice and this permission notice shall be included in
  12. // all copies or substantial portions of the Software.
  13. //
  14. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  19. // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
  20. // IN THE SOFTWARE.
  21. //-----------------------------------------------------------------------------
  22. #include "EmscriptenGL2ES.h"
  23. #include "platform/platformAssert.h"
  24. #include "EmscriptenOGLVideo.h"
  25. #include "math/mMatrix.h"
  26. #include "math/mPoint.h"
  27. #define INV_255 0.0039215686f
  28. #define INV_32767 3.0518509476e-5f
  29. /* EAGL and GL functions calling wrappers that log on error */
  30. #define CALL_EAGL_FUNCTION(__FUNC__, ...) ({ EAGLError __error = __FUNC__( __VA_ARGS__ ); if(__error != kEAGLErrorSuccess) Con::printf("%s() called from %s returned error %i\n", #__FUNC__, __FUNCTION__, __error); (__error ? 0 : 1); })
  31. #define CHECK_GL_ERROR() ({ int __error = glGetError(); if(__error) Con::printf("OpenGL error 0x%04X in %s\n", __error, __FUNCTION__); (__error ? 0 : 1); })
  32. // define this to print out glErrors, un-define to get rid of it
  33. #define TEST_FOR_OPENGL_ERRORS CHECK_GL_ERROR();
  34. /////////////////////////////////////////////////////////////////////////////
  35. //
  36. // Wrapper around the matrix stack ops, to see if ever have over/underflow
  37. //
  38. extern "C"
  39. {
  40. static GLenum currentMatrixMode = GL_MODELVIEW;
  41. static int currentProjStackDepth = 0;
  42. static GLfloat projStack[256];
  43. static int currentTexStackDepth = 0;
  44. static GLfloat texStack[256];
  45. static int currentModelStackDepth = 0;
  46. static GLfloat modStack[256];
  47. #undef glPushMatrix // temporarily
  48. void EmscriptenGLPushMatrix() {
  49. GLint depth;
  50. switch (currentMatrixMode) {
  51. case GL_MODELVIEW:
  52. if (currentModelStackDepth > 15) {
  53. AssertFatal( 0, "ModelView Stack overflow" );
  54. } else {
  55. glGetFloatv( GL_MODELVIEW_MATRIX, &modStack[currentModelStackDepth*16] );
  56. currentModelStackDepth++;
  57. glGetIntegerv( GL_MODELVIEW_STACK_DEPTH, &depth );
  58. // AssertWarn( (currentModelStackDepth > depth), "Native ModelView stack depth has been exceeded" );
  59. }
  60. break;
  61. case GL_PROJECTION:
  62. if (currentProjStackDepth > 15) {
  63. AssertFatal( 0, "Projection Stack overflow" );
  64. } else {
  65. glGetFloatv( GL_PROJECTION_MATRIX, &projStack[currentProjStackDepth*16] );
  66. currentProjStackDepth++;
  67. glGetIntegerv( GL_PROJECTION_STACK_DEPTH, &depth );
  68. // AssertWarn( (currentProjStackDepth > depth), "Native Projection stack depth has been exceeded" );
  69. }
  70. break;
  71. case GL_TEXTURE:
  72. if (currentTexStackDepth > 15) {
  73. AssertFatal( 0, "Texture Stack overflow" );
  74. } else {
  75. glGetFloatv( GL_TEXTURE_MATRIX, &texStack[currentTexStackDepth*16] );
  76. currentTexStackDepth++;
  77. glGetIntegerv( GL_TEXTURE_STACK_DEPTH, &depth );
  78. // AssertWarn( (currentTexStackDepth > depth), "Native Texture stack depth has been exceeded" );
  79. }
  80. break;
  81. default:
  82. glPushMatrix();
  83. GLenum err;
  84. err = glGetError();
  85. AssertFatal( !(err == GL_STACK_OVERFLOW), "GL Stack overflow" );
  86. break;
  87. }
  88. }
  89. #define glPushMatrix EmscriptenGLPushMatrix
  90. #undef glPopMatrix // temporarily
  91. void EmscriptenGLPopMatrix() {
  92. switch (currentMatrixMode) {
  93. case GL_MODELVIEW:
  94. if (currentModelStackDepth <= 0) {
  95. AssertFatal( 0, "ModelView Stack underflow" );
  96. } else {
  97. currentModelStackDepth--;
  98. glLoadMatrixf( &modStack[currentModelStackDepth*16] );
  99. }
  100. break;
  101. case GL_PROJECTION:
  102. if (currentProjStackDepth <= 0) {
  103. AssertFatal( 0, "Projection Stack underflow" );
  104. } else {
  105. currentProjStackDepth--;
  106. glLoadMatrixf( &projStack[currentProjStackDepth*16] );
  107. }
  108. break;
  109. case GL_TEXTURE:
  110. if (currentTexStackDepth <= 0) {
  111. AssertFatal( 0, "Texture Stack underflow" );
  112. } else {
  113. currentTexStackDepth--;
  114. glLoadMatrixf( &texStack[currentTexStackDepth*16] );
  115. }
  116. break;
  117. default:
  118. glPopMatrix();
  119. GLenum err;
  120. err = glGetError();
  121. AssertFatal( !(err == GL_STACK_UNDERFLOW), "GL Stack underflow" );
  122. break;
  123. }
  124. }
  125. #define glPopMatrix EmscriptenGLPopMatrix
  126. #undef glMatrixMode // temporarily
  127. void EmscriptenGLMatrixMode( GLenum mode ) {
  128. currentMatrixMode = mode;
  129. glMatrixMode( mode );
  130. }
  131. #define glMatrixMode EmscriptenGLMatrixMode // redefine for everyone else
  132. }
  133. /////////////////////////////////////////////////////////////////////////////
  134. //
  135. // The following API functions are wrappers to add opengl functionality to opengl-es
  136. //
  137. static GLint beginEndMode = -1;
  138. // tex coord array
  139. static GLfloat * beginEndTexCoord2f = NULL; // 2 entries per coord
  140. static int beginEndTexCoord2f_alloc = 0; // number of bytes allocated to the array
  141. static int beginEndTexCoord2f_size = 0; // number of coords in the array
  142. // vertex array
  143. static GLfloat * beginEndVertex = NULL; // 4 entries per vertex
  144. static int beginEndVertex_alloc = 0; // number of bytes allocated to the array
  145. static int beginEndVertex_size = 0; // number of vertexes in the array
  146. // color array -- needed if glColor is called inside begin/end
  147. static GLfloat * beginEndColor = NULL; // 4 entries per color
  148. static int beginEndColor_size = 0; // number of colors in the array
  149. // normal array
  150. static GLfloat * beginEndNormal = NULL; // 3 entries per normal
  151. static int beginEndNormal_alloc = 0; // number of bytes allocated to the array
  152. static int beginEndNormal_size = 0; // number of normals in the array
  153. // macros to handle re-sizing the arrays as needed
  154. #define CHECK_ARRAY_SIZE( ppArray, pAlloc, pSize, nType, nGroup ) \
  155. if (*ppArray == NULL) { \
  156. *pAlloc = 32 * sizeof(nType) * nGroup; \
  157. *ppArray = (nType*)dMalloc( 32 * sizeof(nType) * nGroup ); \
  158. } \
  159. if (*pSize >= *pAlloc / (nGroup * sizeof(nType))) { \
  160. *ppArray = (nType*)dRealloc( *ppArray, 2 * (*pAlloc) ); \
  161. *pAlloc *= 2; \
  162. }
  163. void glBegin( GLint mode )
  164. {
  165. if (beginEndMode >= 0) {
  166. AssertFatal(0, "glBegin(): called without a glEnd");
  167. }
  168. beginEndMode = mode;
  169. beginEndTexCoord2f_size = 0;
  170. beginEndVertex_size = 0;
  171. beginEndColor_size = 0;
  172. beginEndNormal_size = 0;
  173. int glError;
  174. glError = TEST_FOR_OPENGL_ERRORS
  175. }
  176. void glEnd()
  177. {
  178. if (beginEndMode < 0) {
  179. AssertFatal(0, "glEnd(): called without a glBegin");
  180. }
  181. if (beginEndVertex_size > 0) {
  182. glEnableClientState( GL_VERTEX_ARRAY );
  183. glVertexPointer( 4, GL_FLOAT, 4*sizeof(GL_FLOAT), beginEndVertex );
  184. }
  185. if (beginEndNormal_size > 0) {
  186. glEnableClientState( GL_NORMAL_ARRAY );
  187. glNormalPointer( GL_FLOAT, 3*sizeof(GL_FLOAT), beginEndNormal );
  188. }
  189. if (beginEndColor_size > 0) {
  190. glEnableClientState( GL_COLOR_ARRAY );
  191. glColorPointer( 4, GL_FLOAT, 4*sizeof(GL_FLOAT), beginEndColor );
  192. }
  193. if (beginEndTexCoord2f_size > 0) {
  194. glEnableClientState( GL_TEXTURE_COORD_ARRAY );
  195. glTexCoordPointer( 2, GL_FLOAT, 2*sizeof(GL_FLOAT), beginEndTexCoord2f );
  196. }
  197. switch (beginEndMode) {
  198. case GL_POINTS:
  199. glDrawArrays( GL_POINTS, 0, beginEndVertex_size );
  200. break;
  201. case GL_LINES:
  202. glDrawArrays( GL_LINES, 0, beginEndVertex_size );
  203. break;
  204. case GL_LINE_STRIP:
  205. glDrawArrays( GL_LINE_STRIP, 0, beginEndVertex_size );
  206. break;
  207. case GL_LINE_LOOP:
  208. glDrawArrays( GL_LINE_LOOP, 0, beginEndVertex_size );
  209. break;
  210. case GL_TRIANGLES:
  211. glDrawArrays( GL_TRIANGLES, 0, beginEndVertex_size );
  212. break;
  213. case GL_TRIANGLE_STRIP:
  214. glDrawArrays( GL_TRIANGLE_STRIP, 0, beginEndVertex_size );
  215. break;
  216. case GL_TRIANGLE_FAN:
  217. glDrawArrays( GL_TRIANGLE_FAN, 0, beginEndVertex_size );
  218. break;
  219. case GL_QUADS:
  220. #if 1 // %%PUAP%% TESTING
  221. // for now, just draw a couple lines to indicate the edges of the quads
  222. glDrawArrays( GL_LINES, 0, beginEndVertex_size );
  223. #else
  224. // draw these as individual pairs of triangle_strips
  225. glDrawArrays( GL_TRIANGLE_STRIP, 0, beginEndVertex_size );
  226. #endif
  227. break;
  228. case GL_QUAD_STRIP:
  229. #if 1 // %%PUAP%% TESTING
  230. glDrawArrays( GL_LINES, 0, beginEndVertex_size );
  231. #endif
  232. break;
  233. case GL_POLYGON:
  234. // see if it is really just a triangle...
  235. if (beginEndVertex_size == 3) {
  236. glDrawArrays( GL_TRIANGLES, 0, 3 );
  237. } else
  238. // see if it is really just a quad...
  239. if (beginEndVertex_size == 4) {
  240. glDrawArrays( GL_TRIANGLE_STRIP, 0, 4 );
  241. } else
  242. AssertFatal( 0, "glBegin(GL_POLYGON): this method call needs to be implemented");
  243. break;
  244. }
  245. if (beginEndVertex_size > 0) {
  246. glDisableClientState( GL_VERTEX_ARRAY );
  247. }
  248. if (beginEndNormal_size > 0) {
  249. glDisableClientState( GL_NORMAL_ARRAY );
  250. }
  251. if (beginEndColor_size > 0) {
  252. glDisableClientState( GL_COLOR_ARRAY );
  253. }
  254. if (beginEndTexCoord2f_size > 0) {
  255. glDisableClientState( GL_TEXTURE_COORD_ARRAY );
  256. }
  257. beginEndMode = -1;
  258. int glError;
  259. glError = TEST_FOR_OPENGL_ERRORS
  260. }
  261. void glTexCoord2f( GLfloat x, GLfloat y)
  262. {
  263. AssertFatal( (beginEndMode >= 0), "glTexCoord2f(): called outside glBegin/glEnd");
  264. CHECK_ARRAY_SIZE( &beginEndTexCoord2f, &beginEndTexCoord2f_alloc, &beginEndTexCoord2f_size, GLfloat, 2 );
  265. beginEndTexCoord2f[ beginEndTexCoord2f_size*2 ] = x;
  266. beginEndTexCoord2f[ beginEndTexCoord2f_size*2+1 ] = y;
  267. beginEndTexCoord2f_size++;
  268. int glError;
  269. glError = TEST_FOR_OPENGL_ERRORS
  270. }
  271. void glVertex4f( GLfloat x, GLfloat y, GLfloat z, GLfloat w)
  272. {
  273. AssertFatal( (beginEndMode >= 0), "glVertex3f(): called outside glBegin/glEnd");
  274. CHECK_ARRAY_SIZE( &beginEndVertex, &beginEndVertex_alloc, &beginEndVertex_size, GLfloat, 4 );
  275. beginEndVertex[ beginEndVertex_size*4 ] = x;
  276. beginEndVertex[ beginEndVertex_size*4+1 ] = y;
  277. beginEndVertex[ beginEndVertex_size*4+2 ] = z;
  278. beginEndVertex[ beginEndVertex_size*4+3 ] = w;
  279. beginEndVertex_size++;
  280. int glError;
  281. glError = TEST_FOR_OPENGL_ERRORS
  282. }
  283. void glVertex2f( GLfloat x, GLfloat y )
  284. {
  285. AssertFatal( (beginEndMode >= 0), "glVertex2f(): called outside glBegin/glEnd");
  286. glVertex4f( x, y, 0.0f, 1.0f );
  287. int glError;
  288. glError = TEST_FOR_OPENGL_ERRORS
  289. }
  290. void glVertex3f( GLfloat x, GLfloat y, GLfloat z )
  291. {
  292. AssertFatal( (beginEndMode >= 0), "glVertex3f(): called outside glBegin/glEnd");
  293. glVertex4f( x, y, z, 1.0f );
  294. int glError;
  295. glError = TEST_FOR_OPENGL_ERRORS
  296. }
  297. void glVertex2fv( const F32 * pv )
  298. {
  299. AssertFatal( (beginEndMode >= 0), "glVertex2fv(): called outside glBegin/glEnd");
  300. glVertex4f( pv[0], pv[1], 0.0f, 1.0f );
  301. int glError;
  302. glError = TEST_FOR_OPENGL_ERRORS
  303. }
  304. void glVertex2i( GLint x, GLint y)
  305. {
  306. AssertFatal( (beginEndMode >= 0), "glVertex2i(): called outside glBegin/glEnd");
  307. glVertex4f( GLfloat(x), GLfloat(y), 0.0f, 1.0f );
  308. int glError;
  309. glError = TEST_FOR_OPENGL_ERRORS
  310. }
  311. void glVertex3fv( const F32 * pv )
  312. {
  313. AssertFatal( (beginEndMode >= 0), "glVertex3fv(): called outside glBegin/glEnd");
  314. glVertex4f( pv[0], pv[1], pv[2], 1.0f );
  315. int glError;
  316. glError = TEST_FOR_OPENGL_ERRORS
  317. }
  318. void glVertex4fv( const F32 * pv )
  319. {
  320. AssertFatal( (beginEndMode >= 0), "glVertex3fv(): called outside glBegin/glEnd");
  321. glVertex4f( pv[0], pv[1], pv[2], pv[3] );
  322. int glError;
  323. glError = TEST_FOR_OPENGL_ERRORS
  324. }
  325. void glNormal3f( GLfloat x, GLfloat y, GLfloat z, GLfloat w)
  326. {
  327. AssertFatal( (beginEndMode >= 0), "glNormal3f(): called outside glBegin/glEnd");
  328. CHECK_ARRAY_SIZE( &beginEndNormal, &beginEndNormal_alloc, &beginEndNormal_size, GLfloat, 3 );
  329. beginEndNormal[ beginEndNormal_size*3 ] = x;
  330. beginEndNormal[ beginEndNormal_size*3+1 ] = y;
  331. beginEndNormal[ beginEndNormal_size*3+2 ] = z;
  332. beginEndNormal_size++;
  333. int glError;
  334. glError = TEST_FOR_OPENGL_ERRORS
  335. }
  336. void glNormal3fv( const F32 * pv)
  337. {
  338. AssertFatal( (beginEndMode >= 0), "glNormal3fv(): called outside glBegin/glEnd");
  339. glNormal3f( pv[0], pv[1], pv[2] );
  340. int glError;
  341. glError = TEST_FOR_OPENGL_ERRORS
  342. }
  343. void glColor3fv( const F32 * pv)
  344. {
  345. glColor4f( pv[0], pv[1], pv[2], 1.0f );
  346. int glError;
  347. glError = TEST_FOR_OPENGL_ERRORS
  348. }
  349. void glColor4fv( const F32 * pv)
  350. {
  351. glColor4f( pv[0], pv[1], pv[2], pv[3] );
  352. int glError;
  353. glError = TEST_FOR_OPENGL_ERRORS
  354. }
  355. void glActiveTextureARB( GLint index )
  356. {
  357. glActiveTexture( index );
  358. int glError;
  359. glError = TEST_FOR_OPENGL_ERRORS
  360. }
  361. void glMultiTexCoord2fARB( GLint, GLfloat, GLfloat)
  362. {
  363. AssertWarn( 0, "glMultiTexCoord2fARB(): this method call needs to be implemented");
  364. }
  365. void glPushAttrib( GLint )
  366. {
  367. AssertWarn( 0, "glPushAttrib(): this method call needs to be implemented");
  368. }
  369. void glPopAttrib()
  370. {
  371. AssertWarn( 0, "glPopAttrib(): this method call needs to be implemented");
  372. }
  373. //void glOrtho( GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar)
  374. //{
  375. // GLfloat tx = -(right+left)/(right-left);
  376. // GLfloat ty = -(top+bottom)/(top-bottom);
  377. // GLfloat tz = -(zFar+zNear)/(zFar-zNear);
  378. // MatrixF m = MatrixF(true);
  379. // ((F32*)m)[0] = 2.0f/(right-left);
  380. // ((F32*)m)[3] = tx;
  381. // ((F32*)m)[5] = 2.0f/(top-bottom);
  382. // ((F32*)m)[7] = ty;
  383. // ((F32*)m)[10] = -2.0f/(zFar-zNear);
  384. // ((F32*)m)[11] = tz;
  385. //
  386. // glMultMatrixf( (F32*)(m.transpose())); // make col major for opengl
  387. //}
  388. //void glFrustum( GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar )
  389. //{
  390. // MatrixF m = MatrixF(true);
  391. // ((F32*)m)[0] = 2.0f*zNear/(right-left);
  392. // ((F32*)m)[2] = (right+left)/(right-left);
  393. // ((F32*)m)[5] = 2.0f*zNear/(top-bottom);
  394. // ((F32*)m)[6] = (top+bottom)/(top-bottom);
  395. // ((F32*)m)[10] = -(zFar+zNear)/(zFar-zNear);
  396. // ((F32*)m)[11] = -2.0f*zFar*zNear/(zFar-zNear);
  397. // ((F32*)m)[14] = -1.0f;
  398. // ((F32*)m)[15] = 0.0f;
  399. //
  400. // glMultMatrixf( (F32*)(m.transpose())); // make col major for opengl
  401. //}
  402. void glReadBuffer( GLint )
  403. {
  404. AssertWarn( 0, "glReadBuffer(): this method call needs to be implemented");
  405. int glError;
  406. glError = TEST_FOR_OPENGL_ERRORS
  407. }
  408. void glClientActiveTextureARB( GLint texture )
  409. {
  410. glClientActiveTexture( texture );
  411. int glError;
  412. glError = TEST_FOR_OPENGL_ERRORS
  413. }
  414. void glColor3i( GLint r, GLint g, GLint b )
  415. {
  416. glColor4f( ((GLfloat)r) * INV_32767, ((GLfloat)g) * INV_32767, ((GLfloat)b) * INV_32767, 1.0f );
  417. int glError;
  418. glError = TEST_FOR_OPENGL_ERRORS
  419. }
  420. void glColor3ubv( const GLubyte *v )
  421. {
  422. glColor4f( ((GLfloat)v[0]) * INV_255, ((GLfloat)v[1]) * INV_255, ((GLfloat)v[2]) * INV_255, 1.0f );
  423. int glError;
  424. glError = TEST_FOR_OPENGL_ERRORS
  425. }
  426. void glColor4ubv( const GLubyte *v )
  427. {
  428. glColor4f( ((GLfloat)v[0]) * INV_255, ((GLfloat)v[1]) * INV_255, ((GLfloat)v[2]) * INV_255, ((GLfloat)v[3]) * INV_255 );
  429. int glError;
  430. glError = TEST_FOR_OPENGL_ERRORS
  431. }
  432. void glRecti( GLint x1, GLint y1, GLint x2, GLint y2 )
  433. {
  434. AssertFatal( beginEndMode<0, "glRecti(): called inside glBegin/glEnd");
  435. glBegin(GL_LINE_LOOP);
  436. glVertex2i(x1, y1);
  437. glVertex2i(x2, y1);
  438. glVertex2i(x2, y2);
  439. glVertex2i(x1, y2);
  440. glEnd();
  441. int glError;
  442. glError = TEST_FOR_OPENGL_ERRORS
  443. }
  444. void glGetDoublev( GLint pname, GLdouble * params )
  445. {
  446. int i;
  447. GLfloat fparams[16];
  448. glGetFloatv( pname, fparams );
  449. AssertFatal((glGetError() == GL_NO_ERROR), "glGetDoublev parameter invalid");
  450. params[0] = (double)fparams[0];
  451. if ((pname == GL_ALIASED_POINT_SIZE_RANGE) ||
  452. (pname == GL_ALIASED_LINE_WIDTH_RANGE) ||
  453. (pname == GL_DEPTH_RANGE) ||
  454. (pname == GL_MAX_VIEWPORT_DIMS) ||
  455. (pname == GL_SMOOTH_LINE_WIDTH_RANGE) ||
  456. (pname == GL_SMOOTH_POINT_SIZE_RANGE)) {
  457. // 2 items
  458. params[1] = (double)fparams[1];
  459. return;
  460. }
  461. if ((pname == GL_COLOR_CLEAR_VALUE) ||
  462. (pname == GL_COLOR_WRITEMASK) ||
  463. (pname == GL_FOG_COLOR) ||
  464. (pname == GL_LIGHT_MODEL_AMBIENT) ||
  465. (pname == GL_SCISSOR_BOX) ||
  466. (pname == GL_VIEWPORT) ) {
  467. // 4 items
  468. params[1] = (double)fparams[1];
  469. params[2] = (double)fparams[2];
  470. params[3] = (double)fparams[3];
  471. return;
  472. }
  473. if ((pname == GL_PROJECTION_MATRIX) ||
  474. //Luma: Added MODDELVIEW support
  475. (pname == GL_MODELVIEW_MATRIX) ||
  476. //(pname == GL_MODELVIEW_MATRIX_FLOAT_AS_INT_BITS) ||
  477. //(pname == GL_PROJECTION_MATRIX_FLOAT_AS_INT_BITS) ||
  478. (pname == GL_TEXTURE_MATRIX) ) {
  479. // 16 items
  480. for (i=1; i<16; i++) {
  481. params[i] = (double)fparams[i];
  482. }
  483. return;
  484. }
  485. }
  486. void glPolygonMode( GLint, GLint )
  487. {
  488. //AssertFatal( 0, "glPolygonMode(): this method call needs to be implemented");
  489. }
  490. void glLockArraysEXT( GLint, GLint )
  491. {
  492. AssertFatal( 0, "glLockArraysEXT(): this method call needs to be implemented");
  493. }
  494. void glUnlockArraysEXT()
  495. {
  496. AssertFatal( 0, "glUnlockArraysEXT(): this method call needs to be implemented");
  497. }
  498. void glColor3ub( GLint r, GLint g, GLint b )
  499. {
  500. glColor4f( ((GLfloat)r) * INV_255, ((GLfloat)g) * INV_255, ((GLfloat)b) * INV_255, 1.0f );
  501. int glError;
  502. glError = TEST_FOR_OPENGL_ERRORS
  503. }
  504. void glFogi( GLint pname, GLint param )
  505. {
  506. glFogf( pname, (GLfloat)param );
  507. int glError;
  508. glError = TEST_FOR_OPENGL_ERRORS
  509. }
  510. /* -Mat note: only guiCanvas uses this, and before adding this GL2ES stuff we didn't need to use it (it was one of the first things if'ed out)
  511. void glDrawBuffer( GLint buffid )
  512. {
  513. ((EAGLView *)platState.ctx).currentRenderBuffer = buffid;
  514. TEST_FOR_OPENGL_ERRORS
  515. }
  516. */
  517. void glColorTableEXT( GLint, GLint, GLint, GLint, GLint, const ColorI * )
  518. {
  519. AssertFatal( 0, "glColorTableEXT(): this method call needs to be implemented");
  520. }
  521. void glBlendColorEXT( GLfloat, GLfloat, GLfloat, GLfloat )
  522. {
  523. AssertFatal( 0, "glBlendColorEXT(): this method call needs to be implemented");
  524. }
  525. void glBlendEquationEXT( GLint )
  526. {
  527. AssertFatal( 0, "glBlendEquationEXT(): this method call needs to be implemented");
  528. }
  529. void glArrayElement( GLint )
  530. {
  531. AssertFatal( 0, "glArrayElement(): this method call needs to be implemented");
  532. }
  533. void glFogCoordPointerEXT(GLenum, GLsizei, void *)
  534. {
  535. AssertFatal( 0, "glFogCoordPointerEXT(): this method call needs to be implemented");
  536. }
  537. //void glDepthRange( GLfloat, GLfloat )
  538. //{
  539. // AssertFatal( 0, "glDepthRange(): this method call needs to be implemented");
  540. //}
  541. void glTexGeni( GLenum coord, GLenum pname, GLint param )
  542. {
  543. AssertFatal( 0, "glTexGeni(): this method call needs to be implemented");
  544. }
  545. void glTexGenfv( GLenum coord, GLenum pname, const GLfloat *params )
  546. {
  547. AssertFatal( 0, "glTexGenfv(): this method call needs to be implemented");
  548. }
  549. void glClipPlane( GLuint plane, GLdouble * equation )
  550. {
  551. GLfloat fequ[4];
  552. fequ[0] = (GLfloat)equation[0];
  553. fequ[1] = (GLfloat)equation[1];
  554. fequ[2] = (GLfloat)equation[2];
  555. fequ[3] = (GLfloat)equation[3];
  556. glClipPlanef( plane, fequ );
  557. int glError;
  558. glError = TEST_FOR_OPENGL_ERRORS
  559. }
  560. GLboolean glAreTexturesResident( GLsizei, const GLuint *, GLboolean*)
  561. {
  562. int glError;
  563. glError = TEST_FOR_OPENGL_ERRORS
  564. return GL_FALSE;
  565. }