本文整理汇总了Python中OpenGL.GL.glColor3f方法的典型用法代码示例。如果您正苦于以下问题:Python GL.glColor3f方法的具体用法?Python GL.glColor3f怎么用?Python GL.glColor3f使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OpenGL.GL
的用法示例。
在下文中一共展示了GL.glColor3f方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: draw_box
# 需要导入模块: from OpenGL import GL [as 别名]
# 或者: from OpenGL.GL import glColor3f [as 别名]
def draw_box(self, x0, y0, x1, y1):
'''Draws a selection box in the 3-D window.
Coordinates are with respect to the lower left corner of the window.
'''
import OpenGL.GL as gl
gl.glMatrixMode(gl.GL_PROJECTION)
gl.glLoadIdentity()
gl.glOrtho(0.0, self.size[0],
0.0, self.size[1],
-0.01, 10.0)
gl.glLineStipple(1, 0xF00F)
gl.glEnable(gl.GL_LINE_STIPPLE)
gl.glLineWidth(1.0)
gl.glColor3f(1.0, 1.0, 1.0)
gl.glBegin(gl.GL_LINE_LOOP)
gl.glVertex3f(x0, y0, 0.0)
gl.glVertex3f(x1, y0, 0.0)
gl.glVertex3f(x1, y1, 0.0)
gl.glVertex3f(x0, y1, 0.0)
gl.glEnd()
gl.glDisable(gl.GL_LINE_STIPPLE)
gl.glFlush()
self.resize(*self.size)
示例2: drawSelf
# 需要导入模块: from OpenGL import GL [as 别名]
# 或者: from OpenGL.GL import glColor3f [as 别名]
def drawSelf(self):
if self._tex is None:
filename = os.path.join("toolicons", "compass.png")
self._tex = loadPNGTexture(filename)
self._tex.bind()
size = 0.001 * config.settings.compassSize.get()
with gl.glPushMatrix(GL.GL_MODELVIEW):
GL.glLoadIdentity()
yaw, pitch = self.yawPitch
if config.settings.viewMode.get() == "Chunk":
yaw = -180
GL.glTranslatef(1. - (size + self.x), size + self.y, 0.0) # position on upper right corner
GL.glRotatef(180 - yaw, 0., 0., 1.) # adjust to north
GL.glColor3f(1., 1., 1.)
with gl.glEnableClientState(GL.GL_TEXTURE_COORD_ARRAY):
GL.glVertexPointer(2, GL.GL_FLOAT, 0, makeQuad(-size, -size, 2 * size, 2 * size))
GL.glTexCoordPointer(2, GL.GL_FLOAT, 0, makeQuad(0, 0, 256, 256))
with gl.glEnable(GL.GL_BLEND, GL.GL_TEXTURE_2D):
GL.glDrawArrays(GL.GL_QUADS, 0, 4)
示例3: drawPlane
# 需要导入模块: from OpenGL import GL [as 别名]
# 或者: from OpenGL.GL import glColor3f [as 别名]
def drawPlane(num_divs=200, div_size=10):
# Plane parallel to x-z at origin with normal -y
minx = -num_divs*div_size
minz = -num_divs*div_size
maxx = num_divs*div_size
maxz = num_divs*div_size
#gl.glLineWidth(2)
#gl.glColor3f(0.7,0.7,1.0)
gl.glColor3f(0.7,0.7,0.7)
gl.glBegin(gl.GL_LINES)
for n in range(2*num_divs):
gl.glVertex3f(minx+div_size*n,0,minz)
gl.glVertex3f(minx+div_size*n,0,maxz)
gl.glVertex3f(minx,0,minz+div_size*n)
gl.glVertex3f(maxx,0,minz+div_size*n)
gl.glEnd()
示例4: __init__
# 需要导入模块: from OpenGL import GL [as 别名]
# 或者: from OpenGL.GL import glColor3f [as 别名]
def __init__(self, obj_info, rotation_matrix, swapyz=False, layout_type=None):
"""Loads a Wavefront OBJ file. """
self.vertices = obj_info.vertices
self.normals = obj_info.normals
self.texcoords = obj_info.texcoords
self.faces = obj_info.faces
self.rotation_matrix = rotation_matrix
# load the mesh to OPENGL
self.gl_list = GL.glGenLists(1)
GL.glNewList(self.gl_list, GL.GL_COMPILE)
for face in self.faces:
vertices, normals, _, _ = face
GL.glBegin(GL.GL_POLYGON)
for i in range(len(vertices)):
normal_color = self.rotation_matrix.dot(self.normals[normals[i] - 1])
GL.glColor3f((normal_color[0] + 1) / 2, (-normal_color[2] + 1) / 2, (normal_color[1] + 1) / 2)
GL.glVertex3fv(self.vertices[vertices[i] - 1])
GL.glEnd()
GL.glEndList()
示例5: qglColor
# 需要导入模块: from OpenGL import GL [as 别名]
# 或者: from OpenGL.GL import glColor3f [as 别名]
def qglColor(self, c):
GL.glColor3f(c.redF(), c.greenF(), c.blueF())
示例6: qglColor
# 需要导入模块: from OpenGL import GL [as 别名]
# 或者: from OpenGL.GL import glColor3f [as 别名]
def qglColor(self, c):
GL.glColor3f(c.redF(), c.greenF(), c.blueF())
#Draws an "indicator" showing the clicked position
示例7: drawEEGPositions
# 需要导入模块: from OpenGL import GL [as 别名]
# 或者: from OpenGL.GL import glColor3f [as 别名]
def drawEEGPositions(self, points, names):
genList = GL.glGenLists(1)
GL.glNewList(genList, GL.GL_COMPILE)
for point, name in zip(points, names):
normal = self.skin_surf.projectPoint(point, smooth=False)[1]
if normal is None or normal == []or point is None or point == []:
print('Invalid Point!')
else:
u, v = self.skin_surf.getTangentCoordinates(normal)
pos_el = point + 2*normal
GL.glEnable(GL.GL_LIGHTING)
self.qglColor(GREEN)
self.ellipse(pos_el, normal, u, v, [6, 6])
if bool(GLUT.glutBitmapString):
pos_text = point + 5*normal
GL.glDisable(GL.GL_LIGHTING)
GL.glColor3f(0.0, 0.0, 0.0)
GL.glRasterPos3f(*pos_text)
GLUT.glutBitmapString(
GLUT.GLUT_BITMAP_HELVETICA_12,
name.encode())
GL.glEnable(GL.GL_LIGHTING)
GL.glEndList()
self.eegPositions = genList
self.update()
示例8: viewer_refresh
# 需要导入模块: from OpenGL import GL [as 别名]
# 或者: from OpenGL.GL import glColor3f [as 别名]
def viewer_refresh(self, q):
while not q.empty():
self.state = q.get()
gl.glClear(gl.GL_COLOR_BUFFER_BIT | gl.GL_DEPTH_BUFFER_BIT)
gl.glClearColor(0.0, 0.0, 0.0, 1.0)
self.dcam.Activate(self.scam)
if self.state is not None:
if self.state[0].shape[0] >= 2:
# draw poses
gl.glColor3f(0.0, 1.0, 0.0)
pangolin.DrawCameras(self.state[0][:-1])
if self.state[0].shape[0] >= 1:
# draw current pose as yellow
gl.glColor3f(1.0, 1.0, 0.0)
pangolin.DrawCameras(self.state[0][-1:])
if self.state[1].shape[0] != 0:
# draw keypoints
gl.glPointSize(5)
gl.glColor3f(1.0, 0.0, 0.0)
pangolin.DrawPoints(self.state[1], self.state[2])
pangolin.FinishFrame()
示例9: main
# 需要导入模块: from OpenGL import GL [as 别名]
# 或者: from OpenGL.GL import glColor3f [as 别名]
def main():
pangolin.CreateWindowAndBind('Main', 640, 480)
gl.glEnable(gl.GL_DEPTH_TEST)
# Define Projection and initial ModelView matrix
scam = pangolin.OpenGlRenderState(
pangolin.ProjectionMatrix(640, 480, 420, 420, 320, 240, 0.2, 100),
pangolin.ModelViewLookAt(-2, 2, -2, 0, 0, 0, pangolin.AxisDirection.AxisY))
handler = pangolin.Handler3D(scam)
# Create Interactive View in window
dcam = pangolin.CreateDisplay()
dcam.SetBounds(0.0, 1.0, 0.0, 1.0, -640.0/480.0)
dcam.SetHandler(handler)
dcam.Resize(pangolin.Viewport(0,0,640*2,480*2))
while not pangolin.ShouldQuit():
gl.glClear(gl.GL_COLOR_BUFFER_BIT | gl.GL_DEPTH_BUFFER_BIT)
gl.glClearColor(1.0, 1.0, 1.0, 1.0)
dcam.Activate(scam)
# Render OpenGL Cube
pangolin.glDrawColouredCube()
# Draw Point Cloud
points = np.random.random((100000, 3)) * 10
colors = np.zeros((len(points), 3))
colors[:, 1] = 1 -points[:, 0] / 10.
colors[:, 2] = 1 - points[:, 1] / 10.
colors[:, 0] = 1 - points[:, 2] / 10.
gl.glPointSize(2)
gl.glColor3f(1.0, 0.0, 0.0)
# access numpy array directly(without copying data), array should be contiguous.
pangolin.DrawPoints(points, colors)
pangolin.FinishFrame()
示例10: drawPlane
# 需要导入模块: from OpenGL import GL [as 别名]
# 或者: from OpenGL.GL import glColor3f [as 别名]
def drawPlane(ndivs=100, ndivsize=1):
# Plane parallel to x-z at origin with normal -y
minx = -ndivs*ndivsize
minz = -ndivs*ndivsize
maxx = ndivs*ndivsize
maxz = ndivs*ndivsize
gl.glLineWidth(1)
gl.glColor3f(0.7,0.7,1.0)
gl.glBegin(gl.GL_LINES)
for n in range(2*ndivs):
gl.glVertex3f(minx+ndivsize*n,0,minz)
gl.glVertex3f(minx+ndivsize*n,0,maxz)
gl.glVertex3f(minx,0,minz+ndivsize*n)
gl.glVertex3f(maxx,0,minz+ndivsize*n)
gl.glEnd()
示例11: main
# 需要导入模块: from OpenGL import GL [as 别名]
# 或者: from OpenGL.GL import glColor3f [as 别名]
def main():
pangolin.CreateWindowAndBind('Main', 640, 480)
gl.glEnable(gl.GL_DEPTH_TEST)
# Define Projection and initial ModelView matrix
scam = pangolin.OpenGlRenderState(
pangolin.ProjectionMatrix(640, 480, 420, 420, 320, 240, 0.2, 100),
pangolin.ModelViewLookAt(-2, 2, -2, 0, 0, 0, pangolin.AxisDirection.AxisY))
handler = pangolin.Handler3D(scam)
# Create Interactive View in window
dcam = pangolin.CreateDisplay()
dcam.SetBounds(0.0, 1.0, 0.0, 1.0, -640.0/480.0)
dcam.SetHandler(handler)
while not pangolin.ShouldQuit():
gl.glClear(gl.GL_COLOR_BUFFER_BIT | gl.GL_DEPTH_BUFFER_BIT)
gl.glClearColor(1.0, 1.0, 1.0, 1.0)
dcam.Activate(scam)
# Render OpenGL Cube
pangolin.glDrawColouredCube()
# Draw Point Cloud
points = np.random.random((100000, 3)) * 10
colors = np.zeros((len(points), 3))
colors[:, 1] = 1 -points[:, 0] / 10.
colors[:, 2] = 1 - points[:, 1] / 10.
colors[:, 0] = 1 - points[:, 2] / 10.
gl.glPointSize(2)
gl.glColor3f(1.0, 0.0, 0.0)
# access numpy array directly(without copying data), array should be contiguous.
pangolin.DrawPoints(points, colors)
pangolin.FinishFrame()
示例12: create_axes_list
# 需要导入模块: from OpenGL import GL [as 别名]
# 或者: from OpenGL.GL import glColor3f [as 别名]
def create_axes_list(self):
'''Creates display lists to render unit length x,y,z axes.'''
import OpenGL.GL as gl
gl.glNewList(self.gllist_id, gl.GL_COMPILE)
gl.glBegin(gl.GL_LINES)
gl.glColor3f(1.0, 0.0, 0.0)
gl.glVertex3f(0.0, 0.0, 0.0)
gl.glVertex3f(1.0, 0.0, 0.0)
gl.glColor3f(0.0, 1.0, 0.0)
gl.glVertex3f(0.0, 0.0, 0.0)
gl.glVertex3f(0.0, 1.0, 0.0)
gl.glColor3f(-.0, 0.0, 1.0)
gl.glVertex3f(0.0, 0.0, 0.0)
gl.glVertex3f(0.0, 0.0, 1.0)
gl.glColor3f(1.0, 1.0, 1.0)
gl.glVertex3f(0.0, 0.0, 0.0)
gl.glVertex3f(-1.0, 0.0, 0.0)
gl.glVertex3f(0.0, 0.0, 0.0)
gl.glVertex3f(0.0, -1.0, 0.0)
gl.glVertex3f(0.0, 0.0, 0.0)
gl.glVertex3f(0.0, 0.0, -1.0)
gl.glEnd()
def label_axis(x, y, z, label):
gl.glRasterPos3f(x, y, z)
glut.glutBitmapString(glut.GLUT_BITMAP_HELVETICA_18,
str(label))
def label_axis_for_feature(x, y, z, feature_ind):
feature = self.octant_features[feature_ind[0]][feature_ind[1]]
label_axis(x, y, z, self.labels[feature])
if self._have_glut:
try:
import OpenGL.GLUT as glut
if bool(glut.glutBitmapString):
if self.quadrant_mode == 'independent':
label_axis(1.05, 0.0, 0.0, 'x')
label_axis(0.0, 1.05, 0.0, 'y')
label_axis(0.0, 0.0, 1.05, 'z')
elif self.quadrant_mode == 'mirrored':
label_axis_for_feature(1.05, 0.0, 0.0, (0, 0))
label_axis_for_feature(0.0, 1.05, 0.0, (0, 1))
label_axis_for_feature(0.0, 0.0, 1.05, (0, 2))
label_axis_for_feature(-1.05, 0.0, 0.0, (6, 0))
label_axis_for_feature(0.0, -1.05, 0.0, (6, 1))
label_axis_for_feature(0.0, 0.0, -1.05, (6, 2))
else:
label_axis_for_feature(1.05, 0.0, 0.0, (0, 0))
label_axis_for_feature(0.0, 1.05, 0.0, (0, 1))
label_axis_for_feature(0.0, 0.0, 1.05, (0, 2))
except:
pass
gl.glEndList()
示例13: main
# 需要导入模块: from OpenGL import GL [as 别名]
# 或者: from OpenGL.GL import glColor3f [as 别名]
def main():
# Create OpenGL window in single line
pangolin.CreateWindowAndBind('Main', 640, 480)
# 3D Mouse handler requires depth testing to be enabled
gl.glEnable(gl.GL_DEPTH_TEST)
scam = pangolin.OpenGlRenderState(
pangolin.ProjectionMatrix(640, 480, 420, 420, 320, 240, 0.1, 1000),
pangolin.ModelViewLookAt(-1, 1, -1, 0, 0, 0, pangolin.AxisDirection.AxisY))
# Aspect ratio allows us to constrain width and height whilst fitting within specified
# bounds. A positive aspect ratio makes a view 'shrink to fit' (introducing empty bars),
# whilst a negative ratio makes the view 'grow to fit' (cropping the view).
dcam = pangolin.CreateDisplay()
dcam.SetBounds(0.0, 1.0, 0.0, 1.0, -640.0/480.0)
dcam.SetHandler(pangolin.Handler3D(scam))
# This view will take up no more than a third of the windows width or height, and it
# will have a fixed aspect ratio to match the image that it will display. When fitting
# within the specified bounds, push to the top-left (as specified by SetLock).
dimg = pangolin.Display('image')
dimg.SetBounds(2./3, 1.0, 0.0, 1./3, 640./480)
dimg.SetLock(pangolin.Lock.LockLeft, pangolin.Lock.LockTop)
w, h = 64, 48
texture = pangolin.GlTexture(w, h, gl.GL_RGB, False, 0, gl.GL_RGB, gl.GL_UNSIGNED_BYTE)
# Default hooks for exiting (Esc) and fullscreen (tab).
while not pangolin.ShouldQuit():
gl.glClear(gl.GL_COLOR_BUFFER_BIT | gl.GL_DEPTH_BUFFER_BIT)
gl.glClearColor(0.95, 0.95, 0.95, 1.0)
dcam.Activate(scam)
gl.glColor3f(1.0, 1.0, 1.0)
pangolin.glDrawColouredCube()
# Set some random image data and upload to GPU
image = random_image(w, h)
texture.Upload(image, gl.GL_RGB, gl.GL_UNSIGNED_BYTE)
# display the image
dimg.Activate()
gl.glColor3f(1.0, 1.0, 1.0)
texture.RenderToViewport()
pangolin.FinishFrame()