[GB.OPENGL]

* BUG: Fix Gl.RenderMode() return values. It can return an Integer[][] (with Gl.GL_SELECT)
  or a Float[] (with Gl.GL_FEEDBACK)



git-svn-id: svn://localhost/gambas/trunk@2257 867c0c6c-44f3-4631-809d-bfa615b0a4ec
This commit is contained in:
Laurent Carlier 2009-08-21 21:59:47 +00:00
parent 080f1d20b9
commit e0dfa431e6
2 changed files with 19 additions and 17 deletions

View File

@ -253,7 +253,7 @@ GB_DESC Cgl[] =
GB_STATIC_METHOD("PassThrough", NULL, GLPASSTHROUGH, "(Token)f"), GB_STATIC_METHOD("PassThrough", NULL, GLPASSTHROUGH, "(Token)f"),
GB_STATIC_METHOD("PopName", NULL, GLPOPNAME, NULL), GB_STATIC_METHOD("PopName", NULL, GLPOPNAME, NULL),
GB_STATIC_METHOD("PushName", NULL, GLPUSHNAME, "(Name)i"), GB_STATIC_METHOD("PushName", NULL, GLPUSHNAME, "(Name)i"),
GB_STATIC_METHOD("RenderMode", "v", GLRENDERMODE, "(Mode)i"), GB_STATIC_METHOD("RenderMode", "Object[];", GLRENDERMODE, "(Mode)i"),
GB_STATIC_METHOD("SelectBuffer", NULL, GLSELECTBUFFER, NULL), GB_STATIC_METHOD("SelectBuffer", NULL, GLSELECTBUFFER, NULL),
/* glGetxxxx calls - see GLinfo.h/c */ /* glGetxxxx calls - see GLinfo.h/c */

View File

@ -76,7 +76,7 @@ END_METHOD
BEGIN_METHOD(GLRENDERMODE, GB_INTEGER Mode) BEGIN_METHOD(GLRENDERMODE, GB_INTEGER Mode)
static GLuint oldrendermode = GL_RENDER; /* default render mode */ static GLuint oldrendermode = GL_RENDER; /* default render mode */
GLint mode = VARG(Mode); GLint result, mode = VARG(Mode);
/* invalid mode or same render mode: /* invalid mode or same render mode:
return null object, and let propagate an opengl error */ return null object, and let propagate an opengl error */
@ -87,16 +87,16 @@ BEGIN_METHOD(GLRENDERMODE, GB_INTEGER Mode)
return; return;
} }
mode = glRenderMode(mode); result = glRenderMode(mode);
if (!mode) if (!result)
{ {
GB.ReturnNull(); GB.ReturnNull();
oldrendermode = mode; oldrendermode = mode;
return; return;
} }
if (mode < 0) if (result < 0)
{ {
GB.Error ("Gl.RenderMode, buffer is too small !"); GB.Error ("Gl.RenderMode, buffer is too small !");
return; return;
@ -108,25 +108,27 @@ BEGIN_METHOD(GLRENDERMODE, GB_INTEGER Mode)
GLuint *hitbuffer = selectbuffer; GLuint *hitbuffer = selectbuffer;
int idxhit, idxname; int idxhit, idxname;
GB.Array.New(&hitArray, GB_T_OBJECT, mode); //GB.New(&hitArray, GB_T_OBJECT, result);
GB.New(POINTER(&hitArray), GB.FindClass("Integer[][]"), NULL, NULL);
for (idxhit=0; idxhit < mode; idxhit++) for (idxhit=0; idxhit < result; idxhit++)
{ {
GB_ARRAY childhitArray; GB_ARRAY childhitArray;
int names = (*hitbuffer) + 3; int names = *hitbuffer;
GB.Array.New(&childhitArray, GB_T_INTEGER, names); GB.Array.New(&childhitArray, GB_T_INTEGER, names + 3);
*((GLuint *)GB.Array.Get(childhitArray, 0)) = *hitbuffer++; // maxname *((GLuint *)GB.Array.Get(childhitArray, 0)) = *hitbuffer++; // maxname
*((GLuint *)GB.Array.Get(childhitArray, 1)) = *hitbuffer++; // zmin *((GLuint *)GB.Array.Get(childhitArray, 1)) = *hitbuffer++; // zmin
*((GLuint *)GB.Array.Get(childhitArray, 2)) = *hitbuffer++; // zmax *((GLuint *)GB.Array.Get(childhitArray, 2)) = *hitbuffer++; // zmax
for (idxname=3; idxname < names; idxname++) for (idxname=0; idxname < names; idxname++)
*((GLuint *)GB.Array.Get(childhitArray, 2)) = *hitbuffer++; // names *((GLuint *)GB.Array.Get(childhitArray, 3 + idxname)) = *hitbuffer++; // names
*((GB_ARRAY *)GB.Array.Get(hitArray, idxhit)) = childhitArray; GB.Ref(childhitArray);
*((GB_ARRAY *)GB.Array.Add(hitArray)) = childhitArray;
} }
GB.ReturnObject(&hitArray); GB.ReturnObject(hitArray);
return; return;
} }
@ -136,12 +138,12 @@ BEGIN_METHOD(GLRENDERMODE, GB_INTEGER Mode)
GLfloat *resultbuffer = feedbuffer; GLfloat *resultbuffer = feedbuffer;
int idxfeed; int idxfeed;
GB.Array.New(&feedArray, GB_T_FLOAT, mode); GB.Array.New(&feedArray, GB_T_FLOAT, result);
for (idxfeed=0; idxfeed < mode; idxfeed++) for (idxfeed=0; idxfeed < result; idxfeed++)
*((GLfloat *)GB.Array.Get(feedArray, idxfeed)) = *resultbuffer++; *((GLfloat *)GB.Array.Get(feedArray, idxfeed)) = *resultbuffer++;
GB.ReturnObject(&feedArray); GB.ReturnObject(feedArray);
return; return;
} }