[Bf-python] Added some GLU functions to BGL Module

Satish Chandra Balaji Rama Goda sgoda at cs.stevens-tech.edu
Wed Jul 21 20:00:29 CEST 2004


Hello.

I have added 6 GLU functions to the BGL module.

Added functions are gluPickMatrix, gluProject, gluUnProject, gluOrtho2D,
gluLookAt and gluPerspective.

I had to add two new macros for wrapping the above functions.

Attached is the patch file for BGL.c, BGL.h and BGL.py


- Satish Goda
----------------------------------------------------
...imagine...create...express...share...enjoy...
http://www.cybersatish.tk
-------------- next part --------------
? user-def.mk
? dlltool/python23.dll.def
? obj/windows
Index: source/blender/python/api2_2x/BGL.c
===================================================================
RCS file: /cvsroot/bf-blender/blender/source/blender/python/api2_2x/BGL.c,v
retrieving revision 1.9
diff -u -r1.9 BGL.c
--- source/blender/python/api2_2x/BGL.c	5 Apr 2004 16:50:08 -0000	1.9
+++ source/blender/python/api2_2x/BGL.c	21 Jul 2004 17:54:38 -0000
@@ -665,12 +665,18 @@
 BGL_Wrap(4, Vertex4s,           void,     (GLshort, GLshort, GLshort, GLshort))
 BGL_Wrap(1, Vertex4sv,          void,     (GLshortP))
 BGL_Wrap(4, Viewport,           void,     (GLint, GLint, GLsizei, GLsizei))
+BGLU_Wrap(4, Perspective,       void,     	(GLdouble, GLdouble, GLdouble, GLdouble))
+BGLU_Wrap(9, LookAt,       		void,     	(GLdouble, GLdouble, GLdouble, GLdouble, GLdouble, GLdouble, GLdouble, GLdouble, GLdouble))
+BGLU_Wrap(4, Ortho2D,       	void,     	(GLdouble, GLdouble, GLdouble, GLdouble))
+BGLU_Wrap(5, PickMatrix,       	void,     	(GLdouble, GLdouble, GLdouble, GLdouble, GLintP))
+BGLU_Wrap(9, Project,			GLint,		(GLdouble, GLdouble, GLdouble, GLdoubleP, GLdoubleP, GLintP, GLdoubleP, GLdoubleP, GLdoubleP))
+BGLU_Wrap(9, UnProject,			GLint,		(GLdouble, GLdouble, GLdouble, GLdoubleP, GLdoubleP, GLintP, GLdoubleP, GLdoubleP, GLdoubleP))
 
 /* #endif */
 
 #undef MethodDef
 #define MethodDef(func) {"gl"#func, Method_##func, METH_VARARGS, "no string"}
-
+#define MethodDefu(func) {"glu"#func, Method_##func, METH_VARARGS, "no string"}
 /* So that MethodDef(Accum) becomes:
  * {"glAccum", Method_Accumfunc, METH_VARARGS} */
 
@@ -992,7 +998,12 @@
   MethodDef(Vertex4s),
   MethodDef(Vertex4sv),
   MethodDef(Viewport),
-
+  MethodDefu(Perspective),
+  MethodDefu(LookAt),
+  MethodDefu(Ortho2D),
+  MethodDefu(PickMatrix),
+  MethodDefu(Project),
+  MethodDefu(UnProject),
 /* #endif */
 
   {NULL, NULL, 0, NULL}
Index: source/blender/python/api2_2x/BGL.h
===================================================================
RCS file: /cvsroot/bf-blender/blender/source/blender/python/api2_2x/BGL.h,v
retrieving revision 1.6
diff -u -r1.6 BGL.h
--- source/blender/python/api2_2x/BGL.h	26 Jun 2003 02:03:46 -0000	1.6
+++ source/blender/python/api2_2x/BGL.h	21 Jul 2004 17:54:39 -0000
@@ -420,6 +420,15 @@
   ret_ret_##ret; \
 }
 
+#define BGLU_Wrap(nargs, funcname, ret, arg_list) \
+static PyObject *Method_##funcname (PyObject *self, PyObject *args) {\
+  arg_def##nargs arg_list; \
+  ret_def_##ret; \
+  if(!PyArg_ParseTuple(args, arg_str##nargs arg_list, arg_ref##nargs arg_list)) return NULL;\
+  ret_set_##ret glu##funcname (arg_var##nargs arg_list);\
+  ret_ret_##ret; \
+}
+
 /* #endif */
 
 PyObject *BGL_Init(void); 
Index: source/blender/python/api2_2x/doc/BGL.py
===================================================================
RCS file: /cvsroot/bf-blender/blender/source/blender/python/api2_2x/doc/BGL.py,v
retrieving revision 1.8
diff -u -r1.8 BGL.py
--- source/blender/python/api2_2x/doc/BGL.py	18 Jul 2004 15:54:17 -0000	1.8
+++ source/blender/python/api2_2x/doc/BGL.py	21 Jul 2004 17:54:40 -0000
@@ -1601,7 +1601,93 @@
   @type width,height: int
   @param width,height: Specify the width and height of the viewport. When a GL context 
   is first attached to a window, width and height are set to the dimensions of that window. 
+  """

+
+def gluPerspective(fovY, aspect, zNear, zFar):
   """
+  Set up a perspective projection matrix.
+  @see: U{http://www.parallab.uib.no/SGI_bookshelves/SGI_Developer/books/OpenGL_RM/sgi_html/ch06.html#id5557116}
+
+  @type fovY: double
+  @param fovY: Specifies the field of view angle, in degrees, in the y direction.
+  @type aspect: double
+  @param aspect: Specifies the aspect ratio that determines the field of view in the x direction. 
+   The aspect ratio is the ratio of x (width) to y (height).
+  @type zNear: double
+  @param zNear: Specifies the distance from the viewer to the near clipping plane (always positive).
+  @type zFar: double
+  @param zFar: Specifies the distance from the viewer to the far clipping plane (always positive).
+  """
+
+def gluLookAt(eyex, eyey, eyez, centerx, centery, centerz, upx, upy, upz):
+  """
+  Define a viewing transformation
+  @see: U{http://www.parallab.uib.no/SGI_bookshelves/SGI_Developer/books/OpenGL_RM/sgi_html/ch06.html#id5552781}
+
+  @type eyex, eyey, eyez: double
+  @param eyex, eyey, eyez: Specifies the position of the eye point.  
+  @type centerx, centery, centerz: double
+  @param centerx, centery, centerz: Specifies the position of the reference point.
+  @type upx, upy, upz: double
+  @param upx, upy, upz: Specifies the direction of the up vector.
+  """
+def gluOrtho2D(left, right, bottom, top):
+  """
+  Define a 2-D orthographic projection matrix
+  @see: U{http://www.parallab.uib.no/SGI_bookshelves/SGI_Developer/books/OpenGL_RM/sgi_html/ch06.html#id5556407}
+
+  @type left, right: double
+  @param left, right: Specify the coordinates for the left and right vertical clipping planes.
+  @type bottom, top: double
+  @param bottom, top: Specify the coordinates for the bottom and top horizontal clipping planes.
+  """
+
+def gluPickMatrix(x, y, width, height, viewport):
+  """
+  Define a picking region
+  @see: U{http://www.parallab.uib.no/SGI_bookshelves/SGI_Developer/books/OpenGL_RM/sgi_html/ch06.html#id5557442}
+
+  @type x, y: double
+  @param x, y: Specify the center of a picking region in window coordinates.
+  @type width, height: double
+  @param width, height: Specify the width and height, respectively, of the picking region in window coordinates.
+  @type viewport: Buffer object. [int]
+  @param viewport: Specifies the current viewport.
+  """
+
+def gluProject(objx, objy, objz, modelMatrix, projMatrix, viewport, winx, winy, winz):
+  """
+  Map object coordinates to window coordinates.
+  @see: U{http://www.parallab.uib.no/SGI_bookshelves/SGI_Developer/books/OpenGL_RM/sgi_html/ch06.html#id5557853}
+  
+  @type objx, objy, objz: double

+  @param objx, objy, objz: Specify the object coordinates.

+  @type modelMatrix: Buffer object. [double]

+  @param modelMatrix: Specifies the current modelview matrix (as from a glGetDoublev call).

+  @type projMatrix: Buffer object. [double]

+  @param projMatrix: Specifies the current projection matrix (as from a glGetDoublev call).

+  @type viewport: Buffer object. [int]

+  @param viewport: Specifies the current viewport (as from a glGetIntegerv call).

+  @type winx, winy, winz: Buffer object. [double]

+  @param winx, winy, winz: Return the computed window coordinates. 

+  """

+
+def gluUnProject(winx, winy, winz, modelMatrix, projMatrix, viewport, objx, objy, objz):

+  """

+  Map object coordinates to window

+  coordinates. @see:

+  U{http://www.parallab.uib.no/SGI_bookshelves/SGI_Developer/books/OpenGL_RM/sgi_html/ch06.html#id5557853}

+

+  @type winx, winy, winz: double

+  @param winx, winy, winz: Specify the window coordinates to be mapped.

+  @type modelMatrix: Buffer object. [double]

+  @param modelMatrix: Specifies the current modelview matrix (as from a glGetDoublev call).

+  @type projMatrix: Buffer object. [double]

+  @param projMatrix: Specifies the current projection matrix (as from a glGetDoublev call).

+  @type viewport: Buffer object. [int]

+  @param viewport: Specifies the current viewport (as from a glGetIntegerv call).

+  @type objx, objy, objz: Buffer object. [double]

+  @param objx, objy, objz: Return the computed object coordinates.

 
 class Buffer:
   """


More information about the Bf-python mailing list