Created
April 9, 2011 16:28
-
-
Save amiller/911526 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
This script is meant to be run several times, from IPython. | |
Modify whatever you like in it, but sure to think of your globals() as | |
being preserved in between | |
""" | |
from blockplayer.visuals.pointwindow import PointWindow | |
from OpenGL.GL import * | |
if not 'window' in globals(): | |
window = PointWindow() | |
color = None | |
xyz = np.array([]) | |
def scatter(): | |
global color, xyz | |
xyz = 2*np.random.rand(1000,3)-1.0 | |
xyz *= np.vstack(3*[np.sum(xyz*xyz,1)]).transpose() | |
color = np.random.rand(1000,3) | |
window.Refresh() | |
@window.event | |
def post_draw(): | |
global color, xyz | |
""" | |
# The name on_draw_axes should be deprecated. Really it's just a | |
# 'user settable' callback for drawing in the camera window (after the | |
# projection matrices are initialized, etc) | |
""" | |
# Draw the points | |
glFinish() | |
glPointSize(1) | |
glEnableClientState(GL_VERTEX_ARRAY) | |
glVertexPointerf(xyz) | |
if not color is None: | |
glEnableClientState(GL_COLOR_ARRAY) | |
glColorPointerf(color) | |
glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA) | |
glEnable(GL_BLEND) | |
glColor3f(1,1,1) | |
glDrawElementsui(GL_POINTS, np.arange(len(xyz))) | |
glDisableClientState(GL_COLOR_ARRAY) | |
glDisableClientState(GL_VERTEX_ARRAY) | |
glDisable(GL_BLEND) | |
@window.eventx | |
def EVT_IDLE(event): | |
return | |
scatter() | |
#window.Refresh() | |
scatter() | |
window.Refresh() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment