예제 #1
0
    def init(self):
        vertex_shader = glesutils.VertexShader(vertex_glsl)
        fragment_shader = glesutils.FragmentShader(fragment_glsl)
        program = glesutils.Program(vertex_shader, fragment_shader)
        self.program = program

        program.use()

        glClearDepthf(1.0)
        glDepthFunc(GL_LESS)
        glEnable(GL_DEPTH_TEST)
        glEnable(GL_CULL_FACE)
        glFrontFace(GL_CW)

        glClearColor(1, 0, 0, 1)

        program.uniform.mvp_mat.value = transforms.identity
        program.uniform.light_dir.value = normalize((0, 1, -1))
        program.uniform.texture.value = 0

        self.vbo = array_spec.create_buffer(vertex_attrib=vertices)
        self.elem_vbo = glesutils.ElementBuffer(indices)

        img = pygame.image.load("cubenormal.png")
        self.texture = glesutils.Texture.from_surface(glesutils.split_cube_map(img), cubemap=True)
        self.texture.bind(0)
 
        print(glGetString(GL_VENDOR))
        print(glGetString(GL_VERSION))
        print(glGetString(GL_EXTENSIONS))

        print("Total VBO size: %gKb" % ((self.vbo.byte_size + self.elem_vbo.byte_size)/1024.0))
예제 #2
0
    def init(self):
        vertex_shader = glesutils.VertexShader(vertex_glsl)
        fragment_shader = glesutils.FragmentShader(fragment_glsl)
        program = glesutils.Program(vertex_shader, fragment_shader)
        self.program = program

        program.use()

        glClearDepthf(1.0)
        glDepthFunc(GL_LESS)
        glEnable(GL_DEPTH_TEST)
        glEnable(GL_CULL_FACE)
        glFrontFace(GL_CW)

        glClearColor(1, 0, 0, 1)

        program.uniform.mvp_mat.value = transforms.identity
        program.uniform.light_dir.value = normalize((0, 1, -1))
        program.uniform.texture.value = 0

        self.vbo = array_spec.create_buffer(vertex_attrib=vertices)
        self.elem_vbo = glesutils.ElementBuffer(indices)

        img = pygame.image.load("cubenormal.png")
        self.texture = glesutils.Texture.from_surface(
            glesutils.split_cube_map(img), cubemap=True)
        self.texture.bind(0)

        print(glGetString(GL_VENDOR))
        print(glGetString(GL_VERSION))
        print(glGetString(GL_EXTENSIONS))

        print("Total VBO size: %gKb" %
              ((self.vbo.byte_size + self.elem_vbo.byte_size) / 1024.0))
예제 #3
0
    def init(self):
        vertices, indices = make_sphere(3)
        print(len(indices))
        self.drawing = array_spec.make_drawing(vertex_attrib=vertices, elements=indices)

        vertex_shader = glesutils.VertexShader(vertex_glsl)
        fragment_shader = glesutils.FragmentShader(fragment_glsl)
        program = glesutils.Program(vertex_shader, fragment_shader)
        self.program = program

        program.use()

        glClearDepthf(1.0)
        glDepthFunc(GL_LESS)
        glEnable(GL_DEPTH_TEST)
        glEnable(GL_CULL_FACE)
        glFrontFace(GL_CW)

        glClearColor(1, 0, 0, 1)

#        program.uniform.mvp_mat.load(transforms.rotation_degrees(45, "z"))
        program.uniform.mvp_mat.value = transforms.identity
        program.uniform.light_dir.value = (0, 1, -1)
        program.uniform.texture.value = 0

        img = pygame.image.load("world_cube_net.png")
        self.texture = glesutils.Texture.from_surface(glesutils.split_cube_map(img), cubemap=True)
        self.texture.bind(0)
 
        print(glGetString(GL_VENDOR))
        print(glGetString(GL_VERSION))
        print(glGetString(GL_EXTENSIONS))
예제 #4
0
파일: icosa.py 프로젝트: stephanh42/rpigl
    def init(self):
        vertices, indices = make_sphere(3)
        print(len(indices))
        self.drawing = array_spec.make_drawing(vertex_attrib=vertices, elements=indices)

        vertex_shader = glesutils.VertexShader(vertex_glsl)
        fragment_shader = glesutils.FragmentShader(fragment_glsl)
        program = glesutils.Program(vertex_shader, fragment_shader)
        self.program = program

        program.use()

        glClearDepthf(1.0)
        glDepthFunc(GL_LESS)
        glEnable(GL_DEPTH_TEST)
        glEnable(GL_CULL_FACE)
        glFrontFace(GL_CW)

        glClearColor(1, 0, 0, 1)

        #        program.uniform.mvp_mat.load(transforms.rotation_degrees(45, "z"))
        program.uniform.mvp_mat.value = transforms.identity
        program.uniform.light_dir.value = (0, 1, -1)
        program.uniform.texture.value = 0

        img = pygame.image.load("world_cube_net.png")
        self.texture = glesutils.Texture.from_surface(glesutils.split_cube_map(img), cubemap=True)
        self.texture.bind(0)

        print(glGetString(GL_VENDOR))
        print(glGetString(GL_VERSION))
        print(glGetString(GL_EXTENSIONS))