Home | Trees | Indices | Help |
|
---|
|
The Blender.BGL submodule (the OpenGL wrapper).
New: some GLU functions: gluLookAt, etc.This module wraps OpenGL constants and functions, making them available from within Blender Python.
The complete list can be retrieved from the module itself, by listing its contents: dir(Blender.BGL). A simple search on the net can point to more than enough material to teach OpenGL programming, from books to many collections of tutorials.
The "red book": "OpenGL Programming Guide: The Official Guide to Learning OpenGL" and the online NeHe tutorials are two of the best resources.
Example:import Blender from Blender.BGL import * from Blender import Draw R = G = B = 0 A = 1 title = "Testing BGL + Draw" instructions = "Use mouse buttons or wheel to change the background color." quitting = " Press ESC or q to quit." len1 = Draw.GetStringWidth(title) len2 = Draw.GetStringWidth(instructions + quitting) # def show_win(): glClearColor(R,G,B,A) # define color used to clear buffers glClear(GL_COLOR_BUFFER_BIT) # use it to clear the color buffer glColor3f(0.35,0.18,0.92) # define default color glBegin(GL_POLYGON) # begin a vertex data list glVertex2i(165, 158) glVertex2i(252, 55) glVertex2i(104, 128) glEnd() glColor3f(0.4,0.4,0.4) # change default color glRecti(40, 96, 60+len1, 113) glColor3f(1,1,1) glRasterPos2i(50,100) # move cursor to x = 50, y = 100 Draw.Text(title) # draw this text there glRasterPos2i(350,40) # move cursor again Draw.Text(instructions + quitting) # draw another msg glBegin(GL_LINE_LOOP) # begin a vertex-data list glVertex2i(46,92) glVertex2i(120,92) glVertex2i(120,115) glVertex2i(46,115) glEnd() # close this list # def ev(evt, val): # event callback for Draw.Register() global R,G,B,A # ... it handles input events if evt == Draw.ESCKEY or evt == Draw.QKEY: Draw.Exit() # this quits the script elif not val: return elif evt == Draw.LEFTMOUSE: R = 1 - R elif evt == Draw.MIDDLEMOUSE: G = 1 - G elif evt == Draw.RIGHTMOUSE: B = 1 - B elif evt == Draw.WHEELUPMOUSE: R += 0.1 if R > 1: R = 1 elif evt == Draw.WHEELDOWNMOUSE: R -= 0.1 if R < 0: R = 0 else: return # don't redraw if nothing changed Draw.Redraw(1) # make changes visible. # Draw.Register(show_win, ev, None) # start the main loop
Note: you can use the Image module and Image.Image BPy object to load and set textures. See Image.Image.glLoad and Image.Image.glFree, for example.
Classes | |
Buffer The Buffer object is simply a block of memory that is delineated and initialized by the user. |
Functions | |||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
Function Details |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
glColor3b, glColor3d, glColor3f, glColor3i, glColor3s, glColor3ub, glColor3ui, glColor3us, glColor4b, glColor4d, glColor4f, glColor4i, glColor4s, glColor4ub, glColor4ui, glColor4us, glColor3bv, glColor3dv, glColor3fv, glColor3iv, glColor3sv, glColor3ubv, glColor3uiv, glColor3usv, glColor4bv, glColor4dv, glColor4fv, glColor4iv, glColor4sv, glColor4ubv, glColor4uiv, glColor4usv Set a new color.
|
|
|
|
|
|
|
|
|
|
|
|
|
glEdgeFlag, glEdgeFlagv Flag edges as either boundary or non-boundary
|
|
|
|
glEvalCoord1d, glEvalCoord1f, glEvalCoord2d, glEvalCoord2f, glEvalCoord1dv, glEvalCoord1fv, glEvalCoord2dv, glEvalCoord2fv Evaluate enabled one- and two-dimensional maps
|
glEvalMesh1 or glEvalMesh2 Compute a one- or two-dimensional grid of points or lines
|
glEvalPoint1 and glEvalPoint2 Generate and evaluate a single point in a mesh
|
|
|
|
glFogf, glFogi, glFogfv, glFogiv Specify fog parameters
|
|
|
|
|
glGetBooleanv, glGetfloatv, glGetFloatv, glGetIntegerv Return the value or values of a selected parameter
|
|
|
glGetLightfv and glGetLightiv Return light source parameter values
|
glGetMapdv, glGetMapfv, glGetMapiv Return evaluator parameters
|
glGetMaterialfv, glGetMaterialiv Return material parameters
|
glGetPixelMapfv, glGetPixelMapuiv, glGetPixelMapusv Return the specified pixel map
|
|
|
glGetTexEnvfv, glGetTexEnviv Return texture environment parameters
|
glGetTexGendv, glGetTexGenfv, glGetTexGeniv Return texture coordinate generation parameters
|
|
glGetTexLevelParameterfv, glGetTexLevelParameteriv return texture parameter values for a specific level of detail
|
glGetTexParameterfv, glGetTexParameteriv Return texture parameter values
|
|
glIndexd, glIndexf, glIndexi, glIndexs, glIndexdv, glIndexfv, glIndexiv, glIndexsv Set the current color index
|
|
|
|
|
glLightf,glLighti, glLightfv, glLightiv Set the light source parameters
|
glLightModelf, glLightModeli, glLightModelfv, glLightModeliv Set the lighting model parameters
|
|
|
|
|
glLoadMatrixd, glLoadMatixf Replace the current matrix with the specified matrix
|
|
|
glMap1d, glMap1f Define a one-dimensional evaluator
|
glMap2d, glMap2f Define a two-dimensional evaluator
|
glMapGrid1d, glMapGrid1f, glMapGrid2d, glMapGrid2f Define a one- or two-dimensional mesh
|
|
|
glMultMatrixd, glMultMatrixf Multiply the current matrix with the specified matrix
|
|
Normal3b, Normal3bv, Normal3d, Normal3dv, Normal3f, Normal3fv, Normal3i, Normal3iv, Normal3s, Normal3sv Set the current normal vector
|
|
|
glPixelMapfv, glPixelMapuiv, glPixelMapusv Set up pixel transfer maps
|
glPixelStoref, glPixelStorei Set pixel storage modes
|
glPixelTransferf, glPixelTransferi Set pixel transfer modes
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
glRasterPos2d, glRasterPos2f, glRasterPos2i, glRasterPos2s, glRasterPos3d, glRasterPos3f, glRasterPos3i, glRasterPos3s, glRasterPos4d, glRasterPos4f, glRasterPos4i, glRasterPos4s, glRasterPos2dv, glRasterPos2fv, glRasterPos2iv, glRasterPos2sv, glRasterPos3dv, glRasterPos3fv, glRasterPos3iv, glRasterPos3sv, glRasterPos4dv, glRasterPos4fv, glRasterPos4iv, glRasterPos4sv Specify the raster position for pixel operations
See Also: www.opengl.org/documentation/specs/man_pages/hardcopy/GL/html/gl/rasterpos.html Note: If you are drawing to the 3d view with a Scriptlink of a space handler the zoom level of the panels will scale the glRasterPos by the view matrix. so a X of 10 will not always offset 10 pixels as you would expect. To work around this get the scale value of the view matrix and use it to scale your pixel values. Workaround:import Blender from Blender.BGL import * xval, yval= 100, 40 # Get the scale of the view matrix viewMatrix = Buffer(GL_FLOAT, 16) glGetFloatv(GL_MODELVIEW_MATRIX, viewMatrix) f = 1/viewMatrix[0] glRasterPos2f(xval*f, yval*f) # Instead of the usual glRasterPos2i(xval, yval) |
|
|
glRectd, glRectf, glRecti, glRects, glRectdv, glRectfv, glRectiv, glRectsv Draw a rectangle
|
|
glRotated, glRotatef Multiply the current matrix by a rotation matrix
|
glScaled, glScalef Multiply the current matrix by a general scaling matrix
|
|
|
|
|
|
|
glTexCoord1d, glTexCoord1f, glTexCoord1i, glTexCoord1s, glTexCoord2d, glTexCoord2f, glTexCoord2i, glTexCoord2s, glTexCoord3d, glTexCoord3f, glTexCoord3i, glTexCoord3s, glTexCoord4d, glTexCoord4f, glTexCoord4i, glTexCoord4s, glTexCoord1dv, glTexCoord1fv, glTexCoord1iv, glTexCoord1sv, glTexCoord2dv, glTexCoord2fv, glTexCoord2iv, glTexCoord2sv, glTexCoord3dv, glTexCoord3fv, glTexCoord3iv, glTexCoord3sv, glTexCoord4dv, glTexCoord4fv, glTexCoord4iv, glTexCoord4sv Set the current texture coordinates
|
glTextEnvf, glTextEnvi, glTextEnvfv, glTextEnviv Set texture environment parameters
|
glTexGend, glTexGenf, glTexGeni, glTexGendv, glTexGenfv, glTexGeniv Control the generation of texture coordinates
|
|
|
glTexParameterf, glTexParameteri, glTexParameterfv, glTexParameteriv Set texture parameters
|
glTranslatef, glTranslated Multiply the current matrix by a translation matrix
|
glVertex2d, glVertex2f, glVertex2i, glVertex2s, glVertex3d, glVertex3f, glVertex3i, glVertex3s, glVertex4d, glVertex4f, glVertex4i, glVertex4s, glVertex2dv, glVertex2fv, glVertex2iv, glVertex2sv, glVertex3dv, glVertex3fv, glVertex3iv, glVertex3sv, glVertex4dv, glVertex4fv, glVertex4iv, glVertex4sv Specify a vertex
|
|
|
|
|
|
|
|
Home | Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0beta1 on Mon May 19 15:32:19 2008 | http://epydoc.sourceforge.net |