def init(self):

        self.angle = 10
        self.framerate = 20

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

        self.program1 = glesutils.Program(self.vertex_shader, self.fragment_shader)
        self.program1.use()

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

        glClearColor(0.5, 0.5, 0.5, 1)

        self.program1.uniform.light_dir.value = ((0, 1, -1))

        self.verteces_buffer = array_spec.create_buffer(vertex_attrib=vertices)
        for face in faces:
            face["element_buffer"] = glesutils.ElementBuffer(face["vertex_index"])

        self.outer_matrix = transforms.compose(transforms.rotation_degrees(20, "z"), 
                transforms.rotation_degrees(20, "y"), 
                transforms.rotation_degrees(20, "x"),
                transforms.scaling(1.2))

        self.points_matrix = transforms.compose(transforms.stretching(0.1, 1, 1.5),
                             transforms.translation(-0.5, -0.5, -0.5))
Esempio n. 2
0
    def init(self):

        self.angle_x = 5
        self.angle_y = 10
        self.angle_z = 5
        self.framerate = 20
        self.counter = 0

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

        self.program1 = glesutils.Program(self.vertex_shader, self.fragment_shader)
        self.program1.use()

        glClearDepthf(1.0)
        glDepthFunc(GL_LESS)
        glEnable(GL_DEPTH_TEST)


        glClearColor(0.0, 0.0, 0.0, 1)

        self.program1.uniform.light_dir.value = ((0, 1, -1))

        self.verteces_buffer = array_spec.create_buffer(vertex_attrib=vertices)
        self.points_buffer = array_spec.create_buffer(vertex_attrib=vertices_points)

        self.elements_outer = glesutils.ElementBuffer(indices_outer)
        self.elements_points = glesutils.ElementBuffer(indices_points)

        self.blank_matrix = transforms.translation(0.0, 0.0, 0.0)

        self.position_matrix = []
        for i in range(0,20):
            self.position_matrix.append(transforms.translation((i/10)-0.95, 0.0, 0.0))

        self.sound_matrix = []
        for i in range(0,20):
            self.sound_matrix.append(transforms.translation(0.0, 0.0, 0.0))

        self.program1.uniform.scaling_matrix.value = transforms.scaling(0.1)

        self.program1.uniform.eye_matrix.value = transforms.compose(transforms.rotation_degrees(self.angle_z, "z"), 
                transforms.rotation_degrees(self.angle_x, "y"), 
                transforms.rotation_degrees(self.angle_x, "x"),
                transforms.translation(0.0, -0.9, 0.0))
        self.counter = 0
Esempio n. 3
0
    def init(self):
        """All setup which requires the OpenGL context to be active."""

        self.currentScenario = 0
        self.animation = []
        self.okpressed = 0
        self.kopressed = 0
        self.preload = False

        # compile vertex and fragment shaders
        vertex_shader = glesutils.VertexShader(vertex_glsl)
        fragment_shader = glesutils.FragmentShader(fragment_glsl)
        # link them together into a program
        program = glesutils.Program(vertex_shader, fragment_shader)
        # set the background to RGBA = (1, 0, 0, 1) (solid red)
        glClearColor(1, 0, 0, 0)

        # set up pre-multiplied alpha
        glEnable(GL_BLEND)
        glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA)

        #glDisable(GL_DEPTH_TEST)

        # load uniforms
        self.mvp_mat = program.uniform.mvp_mat
        self.mvp_mat.value = transforms.rotation_degrees(0, "z")

        # bind uniform named "texture" to texture unit 1
        # normally, when using only one texture, 0 would be more logical,
        # but this is just for demo purposes
        program.uniform.texture.value = 0  # bind texture to texture unit 1
        program.uniform.alpha.value = 1.0

        self.actual_w_to_h_ratio = float(self.width) / float(self.height)
        print("WtoH ratio", self.actual_w_to_h_ratio)
        # data for the three vertices
        y_min = 0.70
        positions = ((0.0, 0.0), (1.0, 0.0), (1.0, 1.0), (0.0, 1.0))
        elements = (0, 1, 2, 0, 2, 3)
        # create an array buffer from the spec
        # note: all buffer objects are automatically bound on creation
        self.drawing = array_spec.make_drawing(vertex_attrib=positions,
                                               elements=elements)

        # use the program, bind the texture
        program.use()
        self.program = program

        # print some OpenGL implementation information
        version = glesutils.get_version()
        for k in version.__dict__:
            print("%s: %s" % (k, getattr(version, k)))

        self.base_matrix = transforms.scaling(2)
        self.base_matrix = transforms.compose(
            transforms.translation([-1, -1, 0]), self.base_matrix)
        self.base_matrix = transforms.compose(
            transforms.rotation_degrees(180, "z"), self.base_matrix)
        self.translation = transforms.translation([0, 0, 0])
        self.mvp = transforms.compose(self.translation, self.base_matrix)

        #for s in Scenarios:
        #    s.loadTexture()

        print "Before Preloading"
        Scenarios.preload()
        print "Pre-loaded"

        self.fact = Stamp("fact", self)
        self.fiction = Stamp("fiction", self)
        self.currentStamp = None