示例#1
0
def background(*color):
    """Clears the screen with color. 
    Color may be an (r,g,b) tuple or a single gray value. If depth testing is
    turned on, also clears the depth buffer."""
    if len(color) == 1 and isinstance(color[0],PImage):
        image(color[0],0,0)
    else:
        color = _getColor(*color)
        glClearColor (*color)
        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
示例#2
0
def updatePixels():
    """Updates the display window with the data in the pixels array."""
    new = createImage(width,height,'RGBA')
    color = _getColor((200))
    glClearColor (*color)
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
    if npy:
        new.pixels = numpy.array(screen.pixels)
        new.updatePixels()
    else: 
        for i in range(width*height): new.pixels[i] = screen.pixels[i]
    image(new,0,0)
示例#3
0
文件: pimage.py 项目: msarch/py
def updatePixels():
    """Updates the display window with the data in the pixels array."""
    new = createImage(width, height, 'RGBA')
    color = _getColor((200))
    glClearColor(*color)
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
    if npy:
        new.pixels = numpy.array(screen.pixels)
        new.updatePixels()
    else:
        for i in range(width * height):
            new.pixels[i] = screen.pixels[i]
    image(new, 0, 0)
示例#4
0
def ambientLight(v1,v2,v3,x=0,y=0,z=0):
    """Adds an ambient light."""
    _lightsOn()
    color = _getColor(v1,v2,v3)
    n = GL_LIGHT0 + attrib.lightCount
    attrib.lightCount += 1
    glLightfv(n, GL_DIFFUSE, (ctypes.c_float * 3)(0,0,0))
    glLightfv(n, GL_AMBIENT, (ctypes.c_float * 4)(*color))
    glLightfv(n, GL_SPECULAR, (ctypes.c_float * 3)(0,0,0))
    glLightfv(n, GL_POSITION, (ctypes.c_float * 4)(x,y,z,0))
    constant, linear, quadratic = attrib.lightFalloff
    glLightf(n, GL_LINEAR_ATTENUATION, linear)
    glLightf(n, GL_QUADRATIC_ATTENUATION, quadratic)
    glLightf(n, GL_CONSTANT_ATTENUATION, constant)
    glEnable(n)
示例#5
0
文件: lights.py 项目: msarch/py
def ambientLight(v1, v2, v3, x=0, y=0, z=0):
    """Adds an ambient light."""
    _lightsOn()
    color = _getColor(v1, v2, v3)
    n = GL_LIGHT0 + attrib.lightCount
    attrib.lightCount += 1
    glLightfv(n, GL_DIFFUSE, (ctypes.c_float * 3)(0, 0, 0))
    glLightfv(n, GL_AMBIENT, (ctypes.c_float * 4)(*color))
    glLightfv(n, GL_SPECULAR, (ctypes.c_float * 3)(0, 0, 0))
    glLightfv(n, GL_POSITION, (ctypes.c_float * 4)(x, y, z, 0))
    constant, linear, quadratic = attrib.lightFalloff
    glLightf(n, GL_LINEAR_ATTENUATION, linear)
    glLightf(n, GL_QUADRATIC_ATTENUATION, quadratic)
    glLightf(n, GL_CONSTANT_ATTENUATION, constant)
    glEnable(n)
示例#6
0
def pointLight(v1,v2,v3,x,y,z):
    """Adds a point light (diffuse/specular) with the given color and position."""
    _lightsOn()
    color = _getColor(v1,v2,v3)
    n = GL_LIGHT0 + attrib.lightCount
    attrib.lightCount += 1
    glLightfv(n, GL_DIFFUSE, (ctypes.c_float * 4)(*color))
    glLightfv(n, GL_AMBIENT, (ctypes.c_float * 3)(0,0,0))
    glLightfv(n, GL_SPECULAR, (ctypes.c_float * 4)(*attrib.lightSpecular))
    glLightfv(n, GL_POSITION, (ctypes.c_float * 4)(x,y,z,1))
    glLightfv(n, GL_SPOT_DIRECTION, (ctypes.c_float * 3)(0,0,-1))
    glLightf(n, GL_SPOT_EXPONENT, 0)
    glLightf(n, GL_SPOT_CUTOFF, 180)
    constant, linear, quadratic = attrib.lightFalloff
    glLightf(n, GL_LINEAR_ATTENUATION, linear)
    glLightf(n, GL_QUADRATIC_ATTENUATION, quadratic)
    glLightf(n, GL_CONSTANT_ATTENUATION, constant)
    glEnable(n)
示例#7
0
def spotLight(v1, v2, v3, x, y, z, nx, ny, nz, angle, concentration):
    """Adds a spot light source."""
    _lightsOn()
    color = _getColor(v1,v2,v3)
    n = GL_LIGHT0 + attrib.lightCount
    attrib.lightCount += 1
    glLightfv(n, GL_DIFFUSE, (ctypes.c_float * 4)(*color))
    glLightfv(n, GL_AMBIENT, (ctypes.c_float * 3)(0,0,0))  
    glLightfv(n, GL_SPECULAR, (ctypes.c_float * 3)(0,0,0))
    glLightfv(n, GL_POSITION, (ctypes.c_float * 4)(x,y,z,1))
    glLightfv(n, GL_SPOT_DIRECTION, (ctypes.c_float * 3)(nx,ny,nz))
    glLightf(n, GL_SPOT_EXPONENT, concentration)
    glLightf(n, GL_SPOT_CUTOFF, math.degrees(angle))
    constant, linear, quadratic = attrib.lightFalloff
    glLightf(n, GL_LINEAR_ATTENUATION, linear)
    glLightf(n, GL_QUADRATIC_ATTENUATION, quadratic)
    glLightf(n, GL_CONSTANT_ATTENUATION, constant)
    glEnable(n)
示例#8
0
文件: lights.py 项目: msarch/py
def pointLight(v1, v2, v3, x, y, z):
    """Adds a point light (diffuse/specular) with the given color and position."""
    _lightsOn()
    color = _getColor(v1, v2, v3)
    n = GL_LIGHT0 + attrib.lightCount
    attrib.lightCount += 1
    glLightfv(n, GL_DIFFUSE, (ctypes.c_float * 4)(*color))
    glLightfv(n, GL_AMBIENT, (ctypes.c_float * 3)(0, 0, 0))
    glLightfv(n, GL_SPECULAR, (ctypes.c_float * 4)(*attrib.lightSpecular))
    glLightfv(n, GL_POSITION, (ctypes.c_float * 4)(x, y, z, 1))
    glLightfv(n, GL_SPOT_DIRECTION, (ctypes.c_float * 3)(0, 0, -1))
    glLightf(n, GL_SPOT_EXPONENT, 0)
    glLightf(n, GL_SPOT_CUTOFF, 180)
    constant, linear, quadratic = attrib.lightFalloff
    glLightf(n, GL_LINEAR_ATTENUATION, linear)
    glLightf(n, GL_QUADRATIC_ATTENUATION, quadratic)
    glLightf(n, GL_CONSTANT_ATTENUATION, constant)
    glEnable(n)
示例#9
0
文件: lights.py 项目: msarch/py
def spotLight(v1, v2, v3, x, y, z, nx, ny, nz, angle, concentration):
    """Adds a spot light source."""
    _lightsOn()
    color = _getColor(v1, v2, v3)
    n = GL_LIGHT0 + attrib.lightCount
    attrib.lightCount += 1
    glLightfv(n, GL_DIFFUSE, (ctypes.c_float * 4)(*color))
    glLightfv(n, GL_AMBIENT, (ctypes.c_float * 3)(0, 0, 0))
    glLightfv(n, GL_SPECULAR, (ctypes.c_float * 3)(0, 0, 0))
    glLightfv(n, GL_POSITION, (ctypes.c_float * 4)(x, y, z, 1))
    glLightfv(n, GL_SPOT_DIRECTION, (ctypes.c_float * 3)(nx, ny, nz))
    glLightf(n, GL_SPOT_EXPONENT, concentration)
    glLightf(n, GL_SPOT_CUTOFF, math.degrees(angle))
    constant, linear, quadratic = attrib.lightFalloff
    glLightf(n, GL_LINEAR_ATTENUATION, linear)
    glLightf(n, GL_QUADRATIC_ATTENUATION, quadratic)
    glLightf(n, GL_CONSTANT_ATTENUATION, constant)
    glEnable(n)
示例#10
0
def ambient(*args):
    """Ambient reflection material properties."""
    color = _getColor(*args)
    glMaterialfv (GL_FRONT_AND_BACK, GL_AMBIENT, (ctypes.c_float * 4)(*color))    
示例#11
0
def specular(*args):
    """Specular reflection material properties."""
    color = _getColor(*args)
    glMaterialfv (GL_FRONT_AND_BACK, GL_SPECULAR, (ctypes.c_float * 4)(*color))
示例#12
0
def emissive(*args):
    """Emission material Properties"""
    color = _getColor(*args)
    glMaterialfv (GL_FRONT_AND_BACK, GL_EMISSION, (ctypes.c_float * 4)(*color)) 
示例#13
0
def tint(*color):
    """Sets color as a tint for drawing images."""
    attrib.tintColor = _getColor(*color)
示例#14
0
def fill(*color):
    """Sets color as color for drawing filled shapes."""
    attrib.fillColor = _getColor(*color)
示例#15
0
def stroke(*color):
    """Sets color as color for drawing lines and shape borders."""
    attrib.strokeColor = _getColor(*color)
示例#16
0
def tint(*color):
    """Sets color as a tint for drawing images."""
    attrib.tintColor = _getColor(*color)
示例#17
0
def fill(*color):
    """Sets color as color for drawing filled shapes."""
    attrib.fillColor = _getColor(*color)
示例#18
0
def stroke(*color):
    """Sets color as color for drawing lines and shape borders."""
    attrib.strokeColor = _getColor(*color)
示例#19
0
文件: materials.py 项目: msarch/py
def emissive(*args):
    """Emission material Properties"""
    color = _getColor(*args)
    glMaterialfv(GL_FRONT_AND_BACK, GL_EMISSION, (ctypes.c_float * 4)(*color))
示例#20
0
文件: materials.py 项目: msarch/py
def specular(*args):
    """Specular reflection material properties."""
    color = _getColor(*args)
    glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, (ctypes.c_float * 4)(*color))
示例#21
0
文件: lights.py 项目: msarch/py
def lightSpecular(v1, v2, v3):
    """Sets the specular coefficients for light sources defined afterwards."""
    attrib.lightSpecular = _getColor(v1, v2, v3)
示例#22
0
文件: materials.py 项目: msarch/py
def ambient(*args):
    """Ambient reflection material properties."""
    color = _getColor(*args)
    glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, (ctypes.c_float * 4)(*color))
示例#23
0
def lightSpecular (v1,v2,v3):
    """Sets the specular coefficients for light sources defined afterwards."""
    attrib.lightSpecular = _getColor(v1,v2,v3)