Ejemplo n.º 1
0
OOP gst_opengl_gluUnProject4 (GLdouble winX, GLdouble winY, GLdouble winZ, GLdouble clipW, 
				OOP modelMatrix, OOP projectionMatrix, OOP viewportVertex, 
				GLdouble nearVal, GLdouble farVal)
{
  GLdouble objX, objY, objZ, objW ;
  GLdouble model[16], *pmodel ;
  GLdouble projection[16], *pproj ;
  GLint viewport[4], *pvport ;
  OOP result = nil ;

  pmodel = gst_opengl_oop_to_dbl_array (model, modelMatrix, 16);
  pproj = gst_opengl_oop_to_dbl_array (projection, projectionMatrix, 16);
  pvport = gst_opengl_oop_to_int_array (viewport, viewportVertex, 4);

  if (!pmodel || !pproj || !pvport)
    return nil;					/* Should fire an exception */

  if(GL_TRUE == gluUnProject4 (winX, winY, winZ, clipW, model, projection, viewport, nearVal, farVal, &objX, &objY, &objZ, &objW)) 
	{
	  result = vm_proxy->objectAlloc(vm_proxy->arrayClass, 4) ; /* Create an array of 4 variables */  

	  vm_proxy->OOPAtPut(result, 0, vm_proxy->longDoubleToOOP(objX)) ;
	  vm_proxy->OOPAtPut(result, 1, vm_proxy->longDoubleToOOP(objY)) ;
	  vm_proxy->OOPAtPut(result, 2, vm_proxy->longDoubleToOOP(objZ)) ;
	  vm_proxy->OOPAtPut(result, 3, vm_proxy->longDoubleToOOP(objW)) ;
	}
  return result ;
}
Ejemplo n.º 2
0
/* The model, proj, view, near, and far arguments are omitted. */
int l_gluUnProject4(lua_State* L)
{
    GLint viewport[4];
    GLdouble model[16], proj[16], near,far, x,y,z,w;
   
    glGetDoublev(GL_MODELVIEW_MATRIX,model);
    glGetDoublev(GL_PROJECTION_MATRIX,proj);
    glGetIntegerv(GL_VIEWPORT,viewport);
    if(!gluUnProject4(
                luaL_checknumber(L,1), 
                luaL_checknumber(L,2),
                luaL_checknumber(L,3),
                luaL_checknumber(L,4),
                model,proj,viewport, near,far,
                &x,&y,&z,&w)) 
    {
        luaL_error(L,"gluUnProject4() failed");
    }
    lua_pushnumber(L,x);
    lua_pushnumber(L,y);
    lua_pushnumber(L,z);
    lua_pushnumber(L,w);
    return 4;
}