Пример #1
0
class SkySphere():
    """
    A SkyBox that maps the texture to a sphere
    """

    def __init__(self, filename, radius):
        """
        Creates a new SkyShpere

        :param filename: Filename of the texture
        :type filename: str
        :param radius: Radius of the skysphere
        :type radius: float
        """

        self.radius = radius
        self.texture = Texture(filename)
        self.sphere = gluNewQuadric()
        gluQuadricNormals(self.sphere, GLU_SMOOTH)
        gluQuadricTexture(self.sphere, GL_TRUE)

    def draw(self):
        """
        Draws the SkySphere
        """

        glDisable(GL_DEPTH_TEST)
        glDisable(GL_BLEND)
        glDisable(GL_CULL_FACE)
        self.texture.draw()
        gluSphere(self.sphere, self.radius, 50, 50)
Пример #2
0
    def __init__(self, filename, radius):
        """
        Creates a new SkyShpere

        :param filename: Filename of the texture
        :type filename: str
        :param radius: Radius of the skysphere
        :type radius: float
        """

        self.radius = radius
        self.texture = Texture(filename)
        self.sphere = gluNewQuadric()
        gluQuadricNormals(self.sphere, GLU_SMOOTH)
        gluQuadricTexture(self.sphere, GL_TRUE)
Пример #3
0
def main():
    global WIN
    global TEXTURE
    global LASTTIME

    set_cubelist()

    glutInit(sys.argv)
    glutInitWindowPosition(200, 300)
    glutInitWindowSize(640, 480)
    glutInitDisplayMode(GLUT_RGB | GLUT_SINGLE | GLUT_DEPTH)
    WIN = glutCreateWindow("Camera Analogy")
    glutDisplayFunc(display)
    glutReshapeFunc(reshape)
    glutSetKeyRepeat(GLUT_KEY_REPEAT_OFF);
    glutKeyboardFunc(keypress)
    glutKeyboardUpFunc(keyup)
    glutPassiveMotionFunc(mouse)
    glutMouseFunc(clicker)
    LASTTIME = datetime.now()
    glutTimerFunc(50, timer, 0)
    # glutIdleFunc(idle)

    grass_top = Texture()
    grass_top.load("grass-top-16x16.jpg")

    dirt = Texture()
    dirt.load("grass-bot-16x16.jpg")

    grass_side = Texture()
    grass_side.load("grass-side-16x16.jpg")

    stone = Texture()
    stone.load("stone-16x16.jpg")

    TEXTURE.append([dirt, dirt, dirt])
    TEXTURE.append([grass_top, grass_side, dirt])
    TEXTURE.append([stone, stone, stone])

    glClearColor(0.3, 0.4, 1.0, 1.0)

    glutMainLoop()