def display(self):

        currentTime = time.time()

        orange = [0.6, 0.4, 0.1, 1.0]
        one = 1.0

        blend_func = [
            GL_ZERO, GL_ONE, GL_SRC_COLOR, GL_ONE_MINUS_SRC_COLOR,
            GL_DST_COLOR, GL_ONE_MINUS_DST_COLOR, GL_SRC_ALPHA,
            GL_ONE_MINUS_SRC_ALPHA, GL_DST_ALPHA, GL_ONE_MINUS_DST_ALPHA,
            GL_CONSTANT_COLOR, GL_ONE_MINUS_CONSTANT_COLOR, GL_CONSTANT_ALPHA,
            GL_ONE_MINUS_CONSTANT_ALPHA, GL_SRC_ALPHA_SATURATE, GL_SRC1_COLOR,
            GL_ONE_MINUS_SRC1_COLOR, GL_SRC1_ALPHA, GL_ONE_MINUS_SRC1_ALPHA
        ]

        num_blend_funcs = len(blend_func)

        x_scale = 20.0 / float(num_blend_funcs)
        y_scale = 16.0 / float(num_blend_funcs)
        t = currentTime

        glViewport(0, 0, self.width, self.height)
        glClearBufferfv(GL_COLOR, 0, orange)
        glClearBufferfv(GL_DEPTH, 0, one)

        glUseProgram(program)

        proj_matrix = (GLfloat * 16)(*identityMatrix)
        proj_matrix = m3dPerspective(m3dDegToRad(50.0),
                                     float(self.width) / float(self.height),
                                     0.1, 1000.0)

        glUniformMatrix4fv(proj_location, 1, GL_FALSE, proj_matrix)

        glEnable(GL_BLEND)
        glBlendColor(0.2, 0.5, 0.7, 0.5)

        for j in range(0, num_blend_funcs):

            for i in range(0, num_blend_funcs):

                T = (GLfloat * 16)(*identityMatrix)
                m3dTranslateMatrix44(T, 9.5 - x_scale * float(i),
                                     7.5 - y_scale * float(j), -18.0)

                RY = (GLfloat * 16)(*identityMatrix)
                m3dRotationMatrix44(RY, t * m3dDegToRad(-45.0), 0.0, 1.0, 0.0)

                RX = (GLfloat * 16)(*identityMatrix)
                m3dRotationMatrix44(RX, t * m3dDegToRad(-21.0), 1.0, 0.0, 0.0)

                mv_matrix = (GLfloat * 16)(*identityMatrix)
                mv_matrix = m3dMultiply(T, m3dMultiply(RY, RX))

                glUniformMatrix4fv(mv_location, 1, GL_FALSE, mv_matrix)
                glBlendFunc(blend_func[i], blend_func[j])
                glDrawElements(GL_TRIANGLES, 36, GL_UNSIGNED_SHORT, None)

        glutSwapBuffers()
示例#2
0
    def display(self):
        global tt

        currentTime = time.time()

        last_time = 0.0
        total_time = 0.0

        f = total_time

        T = (GLfloat * 16)(*identityMatrix)
        m3dTranslateMatrix44(T, 0.0, 0.0, -2.0)

        RY = (GLfloat * 16)(*identityMatrix)
        m3dRotationMatrix44(RY, f * m3dDegToRad(40.0), 0.0, 1.0, 0.0)

        mv_matrix = m3dMultiply(T, RY)

        vp_matrix = (GLfloat * 16)(*identityMatrix)
        vp_matrix = m3dPerspective(m3dDegToRad(50.0),
                                   float(self.width) / float(self.height), 0.1,
                                   1000.0)

        glViewport(0, 0, self.width, self.height)
        glClearBufferfv(GL_COLOR, 0, [0.0, 0.0, 0.0])

        glBindVertexArray(vao)
        glUseProgram(program)

        glBindTexture(GL_TEXTURE_2D, texture)

        r = (tt & 0x100)

        tile = bit_reversal_table[(tt & 0xFF)]

        x = (tile >> 0) & 0xF
        y = (tile >> 4) & 0xF

        if (r == 0):

            glTexPageCommitmentARB(GL_TEXTURE_2D, 0, x * PAGE_SIZE,
                                   y * PAGE_SIZE, 0, PAGE_SIZE, PAGE_SIZE, 1,
                                   GL_TRUE)
            glTexSubImage2D(GL_TEXTURE_2D, 0, x * PAGE_SIZE, y * PAGE_SIZE,
                            PAGE_SIZE, PAGE_SIZE, GL_RGBA, GL_UNSIGNED_BYTE,
                            texture_data)

        else:

            glTexPageCommitmentARB(GL_TEXTURE_2D, 0, x * PAGE_SIZE,
                                   y * PAGE_SIZE, 0, PAGE_SIZE, PAGE_SIZE, 1,
                                   GL_FALSE)

        tt += 17

        glDrawArrays(GL_TRIANGLE_STRIP, 0, 4)

        glutSwapBuffers()
    def display(self):

        currentTime = time.time()

        gray = [ 0.2, 0.2, 0.2, 1.0 ]
        ones = [ 1.0 ]
        t = currentTime * 0.1

        proj_matrix = (GLfloat * 16)(*identityMatrix)
        proj_matrix = m3dPerspective(m3dDegToRad(60.0), float(self.width) / float(self.height), 0.1, 1000.0);    

        view_matrix = (GLfloat * 16)(*identityMatrix)
        view_matrix = m3dLookAt([15.0 * sin(t), 0.0, 15.0 * cos(t)],
                                (0.0, 0.0, 0.0),
                                (0.0, 1.0, 0.0))
               
        RX = (GLfloat * 16)(*identityMatrix)
        m3dRotationMatrix44(RX, t * m3dDegToRad(0.0), 1.0, 0.0, 0.0)
                                                  
        RY = (GLfloat * 16)(*identityMatrix)
        m3dRotationMatrix44(RY, t * m3dDegToRad(130.1), 0.0, 1.0, 0.0)
                    
        T = (GLfloat * 16)(*identityMatrix)
        m3dTranslateMatrix44(T, 0.0, -4.0, 0.0)

        mv_matrix = (GLfloat * 16)(*identityMatrix)
        mv_matrix = m3dMultiply(RX, m3dMultiply(RY, T))
        
        mv_matrix = m3dMultiply(view_matrix , mv_matrix)

        glClearBufferfv(GL_COLOR, 0, gray)
        glClearBufferfv(GL_DEPTH, 0, ones)
        glBindTexture(GL_TEXTURE_CUBE_MAP, tex_envmap)

        glViewport(0, 0, self.width, self.height)

        glUseProgram(skybox_prog)
        glBindVertexArray(skybox_vao)

        glUniformMatrix4fv(uniforms.skybox.view_matrix, 1, GL_FALSE, view_matrix)

        glDisable(GL_DEPTH_TEST)

        glDrawArrays(GL_TRIANGLE_STRIP, 0, 4)

        glUseProgram(render_prog)

        glUniformMatrix4fv(uniforms.render.mv_matrix, 1, GL_FALSE, mv_matrix)
        glUniformMatrix4fv(uniforms.render.proj_matrix, 1, GL_FALSE, proj_matrix)

        glEnable(GL_DEPTH_TEST)

        myobject.render()

        glutSwapBuffers()
示例#4
0
    def display(self):

        currentTime = time.time()

        black = [0.0, 0.0, 0.0, 1.0]
        one = 1.0
        f = currentTime

        glViewport(0, 0, self.width, self.height)
        glClearBufferfv(GL_COLOR, 0, black)
        glClearBufferfv(GL_DEPTH, 0, one)

        glUseProgram(program)

        proj_matrix = (GLfloat * 16)(*identityMatrix)
        proj_matrix = m3dPerspective(m3dDegToRad(50.0),
                                     float(self.width) / float(self.height),
                                     1.0, 1000.0)

        # vmath::mat4 proj_matrix = vmath::perspective(50.0f,
        # (float)info.windowWidth / (float)info.windowHeight,
        # 0.1f,
        # 1000.0f)

        glUniformMatrix4fv(proj_location, 1, GL_FALSE, proj_matrix)

        T = (GLfloat * 16)(*identityMatrix)
        m3dTranslateMatrix44(T, 0.0, 0.0, -3.0)

        RY = (GLfloat * 16)(*identityMatrix)
        m3dRotationMatrix44(RY, currentTime * m3dDegToRad(81.0), 0.0, 1.0, 0.0)

        RX = (GLfloat * 16)(*identityMatrix)
        m3dRotationMatrix44(RX, currentTime * m3dDegToRad(45.0), 1.0, 0.0, 0.0)

        mv_matrix = (GLfloat * 16)(*identityMatrix)
        mv_matrix = m3dMultiply(T, m3dMultiply(RY, RX))

        # vmath::mat4 mv_matrix = vmath::translate(0.0f, 0.0f, -3.0f) *
        # vmath::rotate((float)currentTime * 45.0f, 0.0f, 1.0f, 0.0f) *
        # vmath::rotate((float)currentTime * 81.0f, 1.0f, 0.0f, 0.0f)

        glUniformMatrix4fv(mv_location, 1, GL_FALSE, mv_matrix)

        glUniform1f(
            explode_factor_location,
            sin(currentTime * 8.0) * cos(currentTime * 6.0) * 0.7 + 0.1)

        myobject.render()

        glutSwapBuffers()
示例#5
0
    def display(self):

        currentTime = time.time()

        green = [0.0, 0.25, 0.0, 1.0]
        black = [0.0, 0.0, 0.0, 0.0]
        one = 1.0
        last_time = 0.0
        total_time = 0.0

        if (not paused):
            total_time += (currentTime - last_time)
        last_time = currentTime

        f = total_time

        glViewport(0, 0, self.width, self.height)
        glClearBufferfv(GL_COLOR, 0, black)
        glClearBufferfv(GL_DEPTH, 0, one)

        glUseProgram(program)

        proj_matrix = (GLfloat * 16)(*identityMatrix)
        proj_matrix = m3dPerspective(m3dDegToRad(50.0),
                                     float(self.width) / float(self.height),
                                     0.1, 1000.0)

        glUniformMatrix4fv(uniforms.proj_matrix, 1, GL_FALSE, proj_matrix)

        mv_matrix = (GLfloat * 16)(*identityMatrix)

        T = (GLfloat * 16)(*identityMatrix)
        m3dTranslateMatrix44(T, 0.0, -5.0, -20.0)

        RY = (GLfloat * 16)(*identityMatrix)
        m3dRotationMatrix44(RY, f * m3dDegToRad(5.0), 0.0, 1.0, 0.0)

        mv_matrix = m3dMultiply(T, RY)

        glUniformMatrix4fv(uniforms.mv_matrix, 1, GL_FALSE, mv_matrix)

        glUniform3fv(uniforms.rim_color, 1, rim_color if rim_enable else
                     (0.0, 0.0, 0.0))
        glUniform1f(uniforms.rim_power, rim_power)

        myobject.render()

        glutSwapBuffers()
示例#6
0
    def display(self):

        currentTime = time.time()
        t = currentTime * 0.02

        r = 550.0

        black = [0.0, 0.0, 0.0, 1.0]
        one = 1.0
        glClearBufferfv(GL_COLOR, 0, black)
        glClearBufferfv(GL_DEPTH, 0, one)

        mv_matrix = (GLfloat * 16)(*identityMatrix)
        mv_matrix = m3dLookAt([sin(t) * r, 25.0, cos(t) * r],
                              [0.0, -50.0, 0.0], [0.0, 1.0, 0.0])

        prj_matrix = (GLfloat * 16)(*identityMatrix)
        prj_matrix = m3dPerspective(m3dDegToRad(45.0),
                                    float(self.width) / float(self.height),
                                    0.1, 1000.0)

        glUseProgram(grass_program)
        glUniformMatrix4fv(uniform.mvpMatrix, 1, GL_FALSE,
                           m3dMultiply(prj_matrix, mv_matrix))

        glEnable(GL_DEPTH_TEST)
        glDepthFunc(GL_LEQUAL)

        glViewport(0, 0, self.width, self.height)

        glBindVertexArray(grass_vao)
        glDrawArraysInstanced(GL_TRIANGLE_STRIP, 0, 6, 1024 * 1024)

        glutSwapBuffers()
示例#7
0
    def display(self):

        currentTime = time.time()

        gray = [0.1, 0.1, 0.1, 1.0]
        ones = [1.0]

        glClearBufferfv(GL_COLOR, 0, gray)
        glClearBufferfv(GL_DEPTH, 0, ones)

        glActiveTexture(GL_TEXTURE0)
        glBindTexture(GL_TEXTURE_3D, tex_envmap)

        glActiveTexture(GL_TEXTURE1)
        glBindTexture(GL_TEXTURE_2D, tex_glossmap)

        glViewport(0, 0, self.width, self.height)

        glUseProgram(render_prog)

        proj_matrix = (GLfloat * 16)(*identityMatrix)
        proj_matrix = m3dPerspective(m3dDegToRad(60.0),
                                     float(self.width) / float(self.height),
                                     0.1, 1000.0)

        T = (GLfloat * 16)(*identityMatrix)
        m3dTranslateMatrix44(T, 0.0, 0.0, -3.0)

        RY = (GLfloat * 16)(*identityMatrix)
        m3dRotationMatrix44(RY, currentTime * m3dDegToRad(13.75), 0.0, 1.0,
                            0.0)

        RZ = (GLfloat * 16)(*identityMatrix)
        m3dRotationMatrix44(RZ, currentTime * m3dDegToRad(7.75), 0.0, 0.0, 1.0)

        RX = (GLfloat * 16)(*identityMatrix)
        m3dRotationMatrix44(RX, currentTime * m3dDegToRad(15.3), 1.0, 0.0, 0.0)

        mv_matrix = (GLfloat * 16)(*identityMatrix)
        mv_matrix = m3dMultiply(T, m3dMultiply(RY, m3dMultiply(RZ, RX)))

        glUniformMatrix4fv(uniforms.mv_matrix, 1, GL_FALSE, mv_matrix)
        glUniformMatrix4fv(uniforms.proj_matrix, 1, GL_FALSE, proj_matrix)

        myobject.render()

        glutSwapBuffers()
示例#8
0
    def display(self):

        global myobject

        currentTime = time.time()

        j = 0
        one = 1.0
        black = [0.0, 0.0, 0.0, 0.0]

        last_time = 0.0
        total_time = 0.0

        if (paused == False):
            total_time += (currentTime - last_time)
        last_time = currentTime

        t = float(total_time)
        i = int(total_time * 3.0)

        glViewport(0, 0, self.width, self.height)
        glClearBufferfv(GL_COLOR, 0, black)
        glClearBufferfv(GL_DEPTH, 0, one)

        view_matrix = (GLfloat * 16)(*identityMatrix)
        view_matrix = m3dLookAt([
            100.0 * cos(t * 0.023), 100.0 * cos(t * 0.023),
            300.0 * sin(t * 0.037) - 600.0
        ], [0.0, 0.0, 260.0], normalize([0.1 - cos(t * 0.1) * 0.3, 1.0, 0.0]))

        proj_matrix = (GLfloat * 16)(*identityMatrix)
        proj_matrix = m3dPerspective(m3dDegToRad(50.0),
                                     float(self.width) / float(self.height),
                                     1.0, 2000.0)

        glUseProgram(render_program)

        glUniform1f(uniform.time, t)
        glUniformMatrix4fv(uniform.view_matrix, 1, GL_FALSE, view_matrix)
        glUniformMatrix4fv(uniform.proj_matrix, 1, GL_FALSE, proj_matrix)
        glUniformMatrix4fv(uniform.viewproj_matrix, 1, GL_FALSE,
                           m3dMultiply(proj_matrix, view_matrix))

        glBindVertexArray(myobject.get_vao())

        if (mode == MODE_MULTIDRAW):

            glMultiDrawArraysIndirect(GL_TRIANGLES, None, NUM_DRAWS, 0)

        elif (mode == MODE_SEPARATE_DRAWS):

            for j in range(0, NUM_DRAWS):

                first, count = myobject.get_sub_object_info(
                    j % myobject.get_sub_object_count())
                glDrawArraysInstancedBaseInstance(GL_TRIANGLES, first, count,
                                                  1, j)

        glutSwapBuffers()
    def display(self):

        green = [0.0, 0.1, 0.0, 0.0]
        currentTime = time.time()

        glViewport(0, 0, self.width, self.height)
        glClearBufferfv(GL_COLOR, 0, green)

        glUseProgram(render_prog)

        proj_matrix = (GLfloat * 16)(*identityMatrix)
        proj_matrix = m3dPerspective(m3dDegToRad(60.0),
                                     float(self.width) / float(self.height),
                                     0.1, 100.0)

        glUniform1f(uniform.offset, -(currentTime * 0.03) %
                    1)  # negative sign to postive changes direction

        textures = [tex_wall, tex_ceiling, tex_wall, tex_floor]

        for i in range(0, 4):

            RZ = (GLfloat * 16)(*identityMatrix)
            m3dRotationMatrix44(RZ, i * m3dDegToRad(90.0), 0.0, 0.0, 1.0)

            T = (GLfloat * 16)(*identityMatrix)
            m3dTranslateMatrix44(T, -5, 0, -10)

            RY = (GLfloat * 16)(*identityMatrix)
            m3dRotationMatrix44(RY, m3dDegToRad(90.0), 0.0, 1.0, 0.0)

            S = (GLfloat * 16)(*identityMatrix)
            m3dScaleMatrix44(S, 300.0, 10.0, 1.0)

            mv_matrix = (GLfloat * 16)(*identityMatrix)
            mv_matrix = m3dMultiply(RZ, m3dMultiply(T, m3dMultiply(RY, S)))

            mvp = (GLfloat * 16)(*identityMatrix)
            mvp = m3dMultiply(proj_matrix, mv_matrix)

            glUniformMatrix4fv(uniform.mvp, 1, GL_FALSE, mvp)

            glBindTexture(GL_TEXTURE_2D, textures[i])
            glDrawArrays(GL_TRIANGLE_STRIP, 0, 4)

        glutSwapBuffers()
示例#10
0
    def display(self):

        global uniforms_mv_matrix
        global uniforms_proj_matrix

        currentTime = time.time()

        gray = [0.2, 0.2, 0.2, 1.0]
        ones = [1.0]

        glClearBufferfv(GL_COLOR, 0, gray)
        glClearBufferfv(GL_DEPTH, 0, ones)

        glViewport(0, 0, self.width, self.height)

        glBindTexture(GL_TEXTURE_2D, tex_object[tex_index])

        glUseProgram(render_prog)

        T = (GLfloat * 16)(*identityMatrix)
        RX = (GLfloat * 16)(*identityMatrix)
        RY = (GLfloat * 16)(*identityMatrix)
        R = (GLfloat * 16)(*identityMatrix)

        # other ways to matrix multiply can be found at https://stackoverflow.com/questions/56711138/how-to-read-parse-the-sbm-file-format-from-superbible-opengl
        # Matrix multiplication is not commutative, order matters when multiplying matrices
        T = np.matrix(translate(0.0, 0.0, -4.0)).reshape(4, 4)
        RX = np.matrix(
            rotation_matrix([1.0, 0.0, 0.0], currentTime * m3dDegToRad(17.0)))
        RY = np.matrix(
            rotation_matrix([0.0, 1.0, 0.0], currentTime * m3dDegToRad(13.0)))
        mv_matrix = RX * RY * T

        proj_matrix = (GLfloat * 16)(*identityMatrix)
        proj_matrix = m3dPerspective(m3dDegToRad(60.0),
                                     float(self.width) / float(self.height),
                                     0.1, 100.0)

        glUniformMatrix4fv(uniforms_mv_matrix, 1, GL_FALSE, mv_matrix)
        glUniformMatrix4fv(uniforms_proj_matrix, 1, GL_FALSE, proj_matrix)

        myobject.render()  # renders the torus

        glutSwapBuffers()
    def display(self):

        currentTime = time.time()

        black = [0.0, 0.0, 0.0, 0.0]
        one = 1.0
        last_time = 0.0
        total_time = 0.0

        if (not paused):
            total_time += (currentTime - last_time)
        last_time = currentTime

        t = total_time * 14.3

        glViewport(0, 0, self.width, self.height)
        glClearBufferfv(GL_COLOR, 0, black)
        glClearBufferfv(GL_DEPTH, 0, one)

        T = (GLfloat * 16)(*identityMatrix)
        m3dTranslateMatrix44(T, 0.0, 0.0, -1.5)

        RY = (GLfloat * 16)(*identityMatrix)
        m3dRotationMatrix44(RY, m3dDegToRad(t), 0.0, 1.0, 0.0)

        mv_matrix = (GLfloat * 16)(*identityMatrix)
        mv_matrix = m3dMultiply(T, RY)

        proj_matrix = (GLfloat * 16)(*identityMatrix)
        proj_matrix = m3dPerspective(m3dDegToRad(60.0),
                                     float(self.width) / float(self.height),
                                     0.1, 1000.0)

        glUseProgram(program)

        glUniformMatrix4fv(uniforms.mvp, 1, GL_FALSE,
                           m3dMultiply(proj_matrix, mv_matrix))
        glUniform1i(uniforms.use_perspective, use_perspective)

        glDrawArrays(GL_TRIANGLE_STRIP, 0, 4)

        glutSwapBuffers()
    def display(self):

        currentTime = time.time()

        black = [0.0, 0.0, 0.0, 1.0]
        one = 1.0
        f = currentTime

        glViewport(0, 0, self.width, self.height)
        glClearBufferfv(GL_COLOR, 0, black)
        glClearBufferfv(GL_DEPTH, 0, one)

        glUseProgram(program)

        proj_matrix = (GLfloat * 16)(*identityMatrix)
        proj_matrix = m3dPerspective(m3dDegToRad(50.0),
                                     float(self.width) / float(self.height),
                                     .1, 1000.0)

        T = (GLfloat * 16)(*identityMatrix)
        m3dTranslateMatrix44(T, 0.0, 0.0, -8.0)

        RY = (GLfloat * 16)(*identityMatrix)
        m3dRotationMatrix44(RY, currentTime * m3dDegToRad(17.0), 0.0, 1.0, 0.0)

        RX = (GLfloat * 16)(*identityMatrix)
        m3dRotationMatrix44(RX, currentTime * m3dDegToRad(10.0), 1.0, 0.0, 0.0)

        mv_matrix = (GLfloat * 16)(*identityMatrix)
        mv_matrix = m3dMultiply(T, m3dMultiply(RY, RX))

        glUniformMatrix4fv(mvp_location, 1, GL_FALSE,
                           m3dMultiply(proj_matrix, mv_matrix))

        glUniformMatrix4fv(mv_location, 1, GL_FALSE, mv_matrix)

        glUniform1f(stretch_location, sin(f * 4.0) * 0.75 + 1.0)

        glBindVertexArray(vao)
        glDrawElements(GL_TRIANGLES, 12, GL_UNSIGNED_SHORT, None)

        glutSwapBuffers()
    def display(self):

        currentTime = time.time()

        black = [0.0, 0.0, 0.0, 1.0]
        one = 1.0
        f = currentTime

        glViewport(0, 0, self.width, self.height)
        glClearBufferfv(GL_COLOR, 0, black)
        glClearBufferfv(GL_DEPTH, 0, one)

        glUseProgram(program)

        proj_matrix = (GLfloat * 16)(*identityMatrix)
        proj_matrix = m3dPerspective(m3dDegToRad(50.0),
                                     float(self.width) / float(self.height),
                                     1.0, 1000.0)

        glUniformMatrix4fv(proj_location, 1, GL_FALSE, proj_matrix)

        T = (GLfloat * 16)(*identityMatrix)
        m3dTranslateMatrix44(T, 0.0, 0.0, -3.0)

        RY = (GLfloat * 16)(*identityMatrix)
        m3dRotationMatrix44(RY, currentTime * m3dDegToRad(15.0), 0.0, 1.0, 0.0)

        RX = (GLfloat * 16)(*identityMatrix)
        m3dRotationMatrix44(RX, currentTime * m3dDegToRad(21.0), 1.0, 0.0, 0.0)

        mv_matrix = (GLfloat * 16)(*identityMatrix)
        mv_matrix = m3dMultiply(T, m3dMultiply(RY, RX))

        glUniformMatrix4fv(mv_location, 1, GL_FALSE, mv_matrix)

        glUniform1f(
            normal_length_location,
            sin(currentTime * 8.0) * cos(currentTime * 6.0) * 0.03 + 0.05)

        myobject.render()

        glutSwapBuffers()
示例#14
0
    def display(self):
        global render_prog
        global star_vao
        global uniforms

        currentTime = time.time()

        black = [ 0.0, 0.0, 0.0, 0.0 ]
        one = [ 1.0 ]
        t = currentTime

        proj_matrix = (GLfloat * 16)(*identityMatrix)
        proj_matrix = m3dPerspective(m3dDegToRad(50.0), float(self.width) / float(self.height), 0.1, 1000.0)

        t *= 0.1
        t -= floor(t)

        glViewport(0, 0, self.width, self.height)
        glClearBufferfv(GL_COLOR, 0, black)
        glClearBufferfv(GL_DEPTH, 0, one)

        glUseProgram(render_prog)

        glUniform1f(uniforms.time, t)
        glUniformMatrix4fv(uniforms.proj_matrix, 1, GL_FALSE, proj_matrix)


        glEnable(GL_BLEND)

        glBlendFunc(GL_ONE, GL_ONE)


        glBindVertexArray(star_vao)

        glEnable(GL_PROGRAM_POINT_SIZE)
        glDrawArrays(GL_POINTS, 0, NUM_STARS)



        glutSwapBuffers()
    def display(self):

        currentTime = time.time()

        blue = [0.0, 0.0, 0.3, 1.0]
        one = 1.0

        proj_matrix = (GLfloat * 16)(*identityMatrix)
        proj_matrix = m3dPerspective(m3dDegToRad(50.0),
                                     float(self.width) / float(self.height),
                                     0.1, 1000.0)

        f = currentTime * 0.3

        T1 = (GLfloat * 16)(*identityMatrix)
        m3dTranslateMatrix44(T1, 0.0, 0.0, -4.0)

        T2 = (GLfloat * 16)(*identityMatrix)
        m3dTranslateMatrix44(T2,
                             sin(2.1 * f) * 0.5,
                             cos(1.7 * f) * 0.5,
                             sin(1.3 * f) * cos(1.5 * f) * 2.0)

        RY = (GLfloat * 16)(*identityMatrix)
        m3dRotationMatrix44(RY, currentTime * m3dDegToRad(45.0), 0.0, 1.0, 0.0)

        RX = (GLfloat * 16)(*identityMatrix)
        m3dRotationMatrix44(RX, currentTime * m3dDegToRad(81.0), 1.0, 0.0, 0.0)

        mv_matrix = (GLfloat * 16)(*identityMatrix)
        mv_matrix = m3dMultiply(T1, m3dMultiply(T2, m3dMultiply(RY, RX)))

        glBindFramebuffer(GL_FRAMEBUFFER, fbo)

        glViewport(0, 0, 512, 512)
        glClearBufferfv(GL_COLOR, 0, [0.0, 1.0, 0.0])
        glClearBufferfi(GL_DEPTH_STENCIL, 0, 1.0, 0)

        glUseProgram(program1)

        glUniformMatrix4fv(proj_location, 1, GL_FALSE, proj_matrix)
        glUniformMatrix4fv(mv_location, 1, GL_FALSE, mv_matrix)
        glDrawArrays(GL_TRIANGLES, 0, 36)

        glBindFramebuffer(GL_FRAMEBUFFER, 0)

        glViewport(0, 0, self.width, self.height)
        glClearBufferfv(GL_COLOR, 0, blue)
        glClearBufferfv(GL_DEPTH, 0, one)

        glBindTexture(GL_TEXTURE_2D, color_texture)

        glUseProgram(program2)

        glUniformMatrix4fv(proj_location2, 1, GL_FALSE, proj_matrix)
        glUniformMatrix4fv(mv_location2, 1, GL_FALSE, mv_matrix)

        glDrawArrays(GL_TRIANGLES, 0, 36)

        glBindTexture(GL_TEXTURE_2D, 0)

        glutSwapBuffers()
示例#16
0
    def display(self):
        global last_time
        global total_time

        currentTime = time.time()

        uint_zeros = [0, 0, 0, 0]
        float_zeros = [0.0, 0.0, 0.0, 0.0]
        float_ones = [1.0, 1.0, 1.0, 1.0]
        draw_buffers = [GL_COLOR_ATTACHMENT0, GL_COLOR_ATTACHMENT1]

        if (not paused):

            total_time += (currentTime - last_time)

        last_time = currentTime

        t = total_time

        glBindFramebuffer(GL_FRAMEBUFFER, gbuffer)
        glViewport(0, 0, self.width, self.height)
        glDrawBuffers(2, draw_buffers)
        glClearBufferuiv(GL_COLOR, 0, uint_zeros)
        glClearBufferuiv(GL_COLOR, 1, uint_zeros)
        glClearBufferfv(GL_DEPTH, 0, float_ones)

        glBindBufferBase(GL_UNIFORM_BUFFER, 0, render_transform_ubo)

        matrices = glMapBufferRange(
            GL_UNIFORM_BUFFER, 0, (2 + NUM_INSTANCES) * glm.sizeof(glm.mat4),
            GL_MAP_WRITE_BIT | GL_MAP_INVALIDATE_BUFFER_BIT)

        matricesp = (GLfloat * 16 * (2 + NUM_INSTANCES)).from_address(matrices)

        proj_matrix = (GLfloat * 16)(*identityMatrix)
        proj_matrix = m3dPerspective(m3dDegToRad(50.0),
                                     float(self.width) / float(self.height),
                                     0.1, 1000.0)

        matricesp[0] = proj_matrix

        d = (sin(t * 0.131) + 2.0) * 0.15
        eye_pos = (d * 120.0 * sin(t * 0.11), 5.5, d * 120.0 * cos(t * 0.01))

        view_matrix = (GLfloat * 16)(*identityMatrix)
        view_matrix = m3dLookAt(eye_pos, (0.0, -20.0, 0.0), (0.0, 1.0, 0.0))

        matricesp[1] = (GLfloat * 16)(*view_matrix)

        for j in range(0, 15):

            j_f = float(j)

            for i in range(0, 15):

                i_f = float(i)

                T = (GLfloat * 16)(*identityMatrix)
                m3dTranslateMatrix44(T, (i - 7.5) * 7.0, 0.0, (j - 7.5) * 11.0)

                matricesp[j * 15 + i + 2] = T

        glUnmapBuffer(GL_UNIFORM_BUFFER)

        glUseProgram(render_program_nm if use_nm else render_program)

        glActiveTexture(GL_TEXTURE0)
        glBindTexture(GL_TEXTURE_2D, tex_diffuse)
        glActiveTexture(GL_TEXTURE1)
        glBindTexture(GL_TEXTURE_2D, tex_nm)

        glEnable(GL_DEPTH_TEST)
        glDepthFunc(GL_LEQUAL)

        myobject.render(NUM_INSTANCES)

        glBindFramebuffer(GL_FRAMEBUFFER, 0)
        glViewport(0, 0, self.width, self.height)
        glDrawBuffer(GL_BACK)

        glActiveTexture(GL_TEXTURE0)
        glBindTexture(GL_TEXTURE_2D, gbuffer_tex[0])

        glActiveTexture(GL_TEXTURE1)
        glBindTexture(GL_TEXTURE_2D, gbuffer_tex[1])

        if (vis_mode == VIS_OFF):

            glUseProgram(light_program)

        else:

            glUseProgram(vis_program)
            glUniform1i(loc_vis_mode, vis_mode)

        glDisable(GL_DEPTH_TEST)

        glBindBufferBase(GL_UNIFORM_BUFFER, 0, light_ubo)

        size_light_t = ctypes.sizeof(ctypes.c_float) * 6

        lights = glMapBufferRange(
            GL_UNIFORM_BUFFER, 0, NUM_LIGHTS * size_light_t,
            GL_MAP_WRITE_BIT | GL_MAP_INVALIDATE_BUFFER_BIT)

        lightsp = (GLfloat * 6 * NUM_LIGHTS).from_address(lights)

        for i in range(0, NUM_LIGHTS):

            i_f = (i - 7.5) * 0.1 + 0.3

            lightsp[i][0:3] = glm.vec3(
                100.0 * sin(t * 1.1 + (5.0 * i_f)) *
                cos(t * 2.3 + (9.0 * i_f)), 15.0, 100.0 *
                sin(t * 1.5 + (6.0 * i_f)) * cos(t * 1.9 + (11.0 * i_f)))

            lightsp[i][3:6] = glm.vec3(
                cos(i_f * 14.0) * 0.5 + 0.8,
                sin(i_f * 17.0) * 0.5 + 0.8,
                sin(i_f * 13.0) * cos(i_f * 19.0) * 0.5 + 0.8)

        glUnmapBuffer(GL_UNIFORM_BUFFER)

        glBindVertexArray(fs_quad_vao)
        glDrawArrays(GL_TRIANGLE_STRIP, 0, 4)

        glBindTexture(GL_TEXTURE_2D, 0)
        glActiveTexture(GL_TEXTURE0)
        glBindTexture(GL_TEXTURE_2D, 0)

        glutSwapBuffers()
示例#17
0
    def display(self):
        global uniforms
        global per_fragment_program

        currentTime = time.time()

        zeros = [0.0, 0.0, 0.0, 0.0]
        gray = [0.1, 0.1, 0.1, 0.0]
        ones = [1.0]
        f = currentTime

        glUseProgram(per_fragment_program)
        glViewport(0, 0, self.width, self.height)

        glClearBufferfv(GL_COLOR, 0, gray)
        glClearBufferfv(GL_DEPTH, 0, ones)

        # /*
        # vmath::mat4 model_matrix = vmath::rotate((float)currentTime * 14.5f, 0.0f, 1.0f, 0.0f) *
        # vmath::rotate(180.0f, 0.0f, 0.0f, 1.0f) *
        # vmath::rotate(20.0f, 1.0f, 0.0f, 0.0f)
        # */

        view_position = [0.0, 0.0, 50.0]

        view_matrix = (GLfloat * 16)(*identityMatrix)
        view_matrix = m3dLookAt(view_position, (0.0, 0.0, 0.0),
                                (0.0, 1.0, 0.0))

        light_position = [-20.0, -20.0, 0.0]

        light_proj_matrix = glm.frustum(-1.0, 1.0, -1.0, 1.0, 1.0, 200.0)

        light_view_matrix = (GLfloat * 16)(*identityMatrix)
        light_view_matrix = m3dLookAt(light_position, (0.0, 0.0, 0.0),
                                      (0.0, 1.0, 0.0))

        if (MANY_OBJECTS):

            size_uniforms_block = ctypes.sizeof(GLfloat) * 16 * 3

            for j in range(0, 7):

                for i in range(0, 7):

                    glBindBufferBase(GL_UNIFORM_BUFFER, 0, uniforms_buffer)
                    block = glMapBufferRange(
                        GL_UNIFORM_BUFFER, 0, size_uniforms_block,
                        GL_MAP_WRITE_BIT | GL_MAP_INVALIDATE_BUFFER_BIT)

                    blockp = (GLfloat * 16 * 3).from_address(block)

                    model_matrix = (GLfloat * 16)(*identityMatrix)
                    m3dTranslateMatrix44(model_matrix, i * 2.75 - 8.25,
                                         6.75 - j * 2.25, 0.0)

                    blockp[0] = m3dMultiply(view_matrix, model_matrix)
                    blockp[1] = (GLfloat * 16)(*view_matrix)

                    proj_matrix = (GLfloat * 16)(*identityMatrix)
                    blockp[2] = m3dPerspective(
                        m3dDegToRad(50.0),
                        float(self.width) / float(self.height), 0.1, 1000.0)

                    glUnmapBuffer(GL_UNIFORM_BUFFER)

                    per_vertex = 1
                    glUniform1f(
                        uniforms[1 if per_vertex == 0 else 0].specular_power,
                        pow(2.0, j + 2.0))
                    glUniform3fv(
                        uniforms[1 if per_vertex == 0 else 0].specular_albedo,
                        1, (i / 9.0 + 1.0 / 9.0))

                    myobject.render()
        else:

            size_uniforms_block = ctypes.sizeof(GLfloat) * 16 * 3

            glBindBufferBase(GL_UNIFORM_BUFFER, 0, uniforms_buffer)
            block = glMapBufferRange(
                GL_UNIFORM_BUFFER, 0, size_uniforms_block,
                GL_MAP_WRITE_BIT | GL_MAP_INVALIDATE_BUFFER_BIT)

            blockp = (GLfloat * 16 * 3).from_address(block)

            model_matrix = (GLfloat * 16)(*identityMatrix)
            model_matrix = scale(7.0)

            blockp[0] = m3dMultiply(view_matrix, model_matrix)

            blockp[1] = (GLfloat * 16)(*view_matrix)

            proj_matrix = (GLfloat * 16)(*identityMatrix)
            proj_matrix = m3dPerspective(
                m3dDegToRad(50.0),
                float(self.width) / float(self.height), 0.1, 1000.0)

            blockp[2] = proj_matrix

            glUnmapBuffer(GL_UNIFORM_BUFFER)

            glUniform1f(uniforms[0].specular_power, 30.0)
            glUniform3fv(uniforms[0].specular_albedo, 1, (1.0, 0.0, 0.0))

            myobject.render()

        glutSwapBuffers()
示例#18
0
    def display(self):
        global program_filter
        global program_resolve
        global program_render
        global tex_filter
        global exposure
        global vao
        global filter_fbo
        global ubo_transform
        global ubo_material
        global bloom_thresh_min
        global bloom_thresh_max
        global uniforms
        global tex_brightpass
        global myobject
        global render_fbo

        currentTime = time.time()

        black = [0.0, 0.0, 0.0, 1.0]
        one = 1.0
        last_time = 0.0
        total_time = 0.0

        if (not paused):
            total_time += (currentTime - last_time)

        last_time = currentTime
        t = total_time

        glViewport(0, 0, self.width, self.height)

        glBindFramebuffer(GL_FRAMEBUFFER, render_fbo)
        glClearBufferfv(GL_COLOR, 0, black)
        glClearBufferfv(GL_COLOR, 1, black)
        glClearBufferfv(GL_DEPTH, 0, one)

        glEnable(GL_DEPTH_TEST)
        glDepthFunc(GL_LESS)

        glUseProgram(program_render)

        glBindBufferBase(GL_UNIFORM_BUFFER, 0, ubo_transform)

        class transforms_t:
            mat_proj = glm.mat4
            mat_view = glm.mat4
            mat_model = [glm.mat4 for _ in range(SPHERE_COUNT)]

        size_transforms_t = glm.sizeof(glm.mat4) * (SPHERE_COUNT + 2)

        mbuffer = glMapBufferRange(
            GL_UNIFORM_BUFFER, 0, size_transforms_t,
            GL_MAP_WRITE_BIT | GL_MAP_INVALIDATE_BUFFER_BIT)
        bufferp = (GLfloat * 16 * (SPHERE_COUNT + 2)).from_address(mbuffer)

        mat_proj = (GLfloat * 16)(*identityMatrix)
        mat_proj = m3dPerspective(m3dDegToRad(50.0),
                                  float(self.width) / float(self.height), 1.0,
                                  1000.0)

        T = (GLfloat * 16)(*identityMatrix)
        m3dTranslateMatrix44(T, 0.0, 0.0, -20.0)

        bufferp[0] = mat_proj

        bufferp[1] = T

        for i in range(2, SPHERE_COUNT + 2):

            fi = 3.141592 * i / 16.0
            # // float r = cosf(fi * 0.25f) * 0.4f + 1.0f
            r = 0.6 if (i & 2) else 1.5

            T1 = (GLfloat * 16)(*identityMatrix)
            m3dTranslateMatrix44(T1,
                                 cos(t + fi) * 5.0 * r,
                                 sin(t + fi * 4.0) * 4.0,
                                 sin(t + fi) * 5.0 * r)

            RY = (GLfloat * 16)(*identityMatrix)
            m3dRotationMatrix44(RY,
                                currentTime * m3dDegToRad(30.0) * fi,
                                sin(t + fi * 2.13) * 75.0,
                                cos(t + fi * 1.37) * 92.0, 0.0)

            m_model = (GLfloat * 16)(*identityMatrix)
            m_model = m3dMultiply(T1, RY)

            bufferp[i] = m_model

        glUnmapBuffer(GL_UNIFORM_BUFFER)
        glBindBufferBase(GL_UNIFORM_BUFFER, 1, ubo_material)

        glUniform1f(uniforms.scene.bloom_thresh_min, bloom_thresh_min)
        glUniform1f(uniforms.scene.bloom_thresh_max, bloom_thresh_max)

        myobject.render(SPHERE_COUNT)

        glDisable(GL_DEPTH_TEST)

        glUseProgram(program_filter)

        glBindVertexArray(vao)

        glBindFramebuffer(GL_FRAMEBUFFER, filter_fbo[0])
        glBindTexture(GL_TEXTURE_2D, tex_brightpass)
        glViewport(0, 0, self.height, self.width)

        glDrawArrays(GL_TRIANGLE_STRIP, 0, 4)

        glBindFramebuffer(GL_FRAMEBUFFER, filter_fbo[1])
        glBindTexture(GL_TEXTURE_2D, tex_filter[0])
        glViewport(0, 0, self.width, self.height)

        glDrawArrays(GL_TRIANGLE_STRIP, 0, 4)

        glUseProgram(program_resolve)

        glUniform1f(uniforms.resolve.exposure, exposure)

        if (show_prefilter):
            glUniform1f(uniforms.resolve.bloom_factor, 0.0)
            glUniform1f(uniforms.resolve.scene_factor, 1.0)

        else:
            glUniform1f(uniforms.resolve.bloom_factor,
                        bloom_factor if show_bloom else 0.0)
            glUniform1f(uniforms.resolve.scene_factor,
                        1.0 if show_scene else 0.0)

        glBindFramebuffer(GL_FRAMEBUFFER, 0)
        glActiveTexture(GL_TEXTURE1)
        glBindTexture(GL_TEXTURE_2D, tex_filter[1])
        glActiveTexture(GL_TEXTURE0)
        glBindTexture(GL_TEXTURE_2D,
                      tex_brightpass if show_prefilter else tex_scene)

        glDrawArrays(GL_TRIANGLE_STRIP, 0, 4)

        glutSwapBuffers()
示例#19
0
    def display(self):

        currentTime = time.time()

        last_time = 0.0
        total_time = 0.0

        f = currentTime

        proj_matrix = (GLfloat * 16)(*identityMatrix)
        proj_matrix = m3dPerspective(m3dDegToRad(70.0),
                                     float(self.width) / float(self.height),
                                     0.1, 500.0)

        glViewport(0, 0, self.width, self.height)
        glClearBufferfv(GL_COLOR, 0, [0.0, 0.0, 0.0])
        glClearBufferfi(GL_DEPTH_STENCIL, 0, 1.0, 0)

        glFinish()

        glBindBufferBase(GL_UNIFORM_BUFFER, 0, buffers.transformBuffer)

        pMatrices = glMapBufferRange(
            GL_UNIFORM_BUFFER, 0,
            ctypes.sizeof(GLfloat) * 16 * (NUM_TEXTURES + 2),
            GL_MAP_WRITE_BIT | GL_MAP_INVALIDATE_BUFFER_BIT)

        pMatricesp = (GLfloat * 16 *
                      (NUM_TEXTURES + 2)).from_address(pMatrices)

        T = (GLfloat * 16)(*identityMatrix)
        m3dTranslateMatrix44(T, 0.0, 0.0, -80.0)

        pMatricesp[0] = T
        pMatricesp[1] = proj_matrix

        angle = f
        angle2 = 0.7 * f
        angle3 = 0.1 * f

        for i in range(2, NUM_TEXTURES + 2):

            T1 = (GLfloat * 16)(*identityMatrix)
            m3dTranslateMatrix44(
                T1, (i % 32) * 4.0 - 62.0, (i >> 5) * 6.0 - 33.0,
                15.0 * sin(angle * 0.19) + 3.0 * cos(angle2 * 6.26) +
                40.0 * sin(angle3))

            RX = (GLfloat * 16)(*identityMatrix)
            m3dRotationMatrix44(RX, angle * m3dDegToRad(130.0), 1.0, 0.0, 0.0)

            RZ = (GLfloat * 16)(*identityMatrix)
            m3dRotationMatrix44(RZ, angle * m3dDegToRad(140.0), 0.0, 0.0, 1.0)

            pMatricesp[i] = m3dMultiply(T1, m3dMultiply(RX, RZ))

            angle += 1.0
            angle2 += 4.1
            angle3 += 0.01

        glUnmapBuffer(GL_UNIFORM_BUFFER)

        glFinish()

        glBindBufferBase(GL_UNIFORM_BUFFER, 1, buffers.textureHandleBuffer)

        glEnable(GL_DEPTH_TEST)

        glUseProgram(program)

        myobject.render(NUM_TEXTURES)

        glutSwapBuffers()
    def display(self):

        currentTime = time.time()


        black = [ 0.0, 0.0, 0.0, 1.0 ]
        one = 1.0

        glViewport(0, 0, self.width, self.height)
        glClearBufferfv(GL_COLOR, 0, black)

        glUseProgram(program)

        proj_matrix = (GLfloat * 16)(*identityMatrix)
        proj_matrix = m3dPerspective(m3dDegToRad(50.0), float(self.width) / float(self.height), 0.1, 1000.0)
                                                     
                                                     
        glUniformMatrix4fv(proj_location, 1, GL_FALSE, proj_matrix)

        glPolygonMode(GL_FRONT_AND_BACK, GL_LINE)
        glEnable(GL_BLEND)
        glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)
        glEnable(GL_LINE_SMOOTH)

        
        if (MANY_CUBES):
            for i in range(0, 24):

                f = i + currentTime * 0.3
                
                T1 = (GLfloat * 16)(*identityMatrix)
                m3dTranslateMatrix44(T1, 0.0, 0.0, -20.0)

                RY = (GLfloat * 16)(*identityMatrix)
                m3dRotationMatrix44(RY, currentTime * m3dDegToRad(45.0), 0.0, 1.0, 0.0)

                RX = (GLfloat * 16)(*identityMatrix)
                m3dRotationMatrix44(RX, currentTime * m3dDegToRad(21.0), 1.0, 0.0, 0.0)

                T2 = (GLfloat * 16)(*identityMatrix)
                m3dTranslateMatrix44(T2, sin(2.1 * f) * 2.0,cos(1.7 * f) * 2.0,sin(1.3 * f) * cos(1.5 * f) * 2.0)

                mv_matrix = (GLfloat * 16)(*identityMatrix)
                mv_matrix = m3dMultiply(T1, m3dMultiply(RY, m3dMultiply(RX, T2)) )
                                                                                         
                glUniformMatrix4fv(mv_location, 1, GL_FALSE, mv_matrix)
                glDrawElements(GL_TRIANGLES, 36, GL_UNSIGNED_SHORT, None)
                
        else:
            f = currentTime * 0.3
            currentTime = 3.15
           
            T = (GLfloat * 16)(*identityMatrix)
            m3dTranslateMatrix44(T, 0.0, 0.0, -4.0)

            RY = (GLfloat * 16)(*identityMatrix)
            m3dRotationMatrix44(RY, currentTime * m3dDegToRad(45.0), 0.0, 1.0, 0.0)

            RX = (GLfloat * 16)(*identityMatrix)
            m3dRotationMatrix44(RX, currentTime * m3dDegToRad(81.0), 1.0, 0.0, 0.0)

            mv_matrix = (GLfloat * 16)(*identityMatrix)
            mv_matrix = m3dMultiply(T, m3dMultiply(RY, RX))    
                                    
            glUniformMatrix4fv(mv_location, 1, GL_FALSE, mv_matrix)
            glDrawElements(GL_TRIANGLES, 36, GL_UNSIGNED_SHORT, None)


        glutSwapBuffers()
    def display(self):
        global paused

        currentTime = time.time()

        black = [0.0, 0.0, 0.0, 0.0]
        one = 1.0

        last_time = 0.0
        total_time = 0.0

        if (not paused):
            total_time += (currentTime - last_time)
        last_time = currentTime

        f = total_time

        glClearBufferfv(GL_COLOR, 0, black)
        glClearBufferfv(GL_DEPTH, 0, one)

        glUseProgram(render_program)

        proj_matrix = (GLfloat * 16)(*identityMatrix)
        proj_matrix = m3dPerspective(m3dDegToRad(50.0),
                                     float(self.width) / float(self.height),
                                     0.1, 1000.0)

        T1 = (GLfloat * 16)(*identityMatrix)
        m3dTranslateMatrix44(T1, 0.0, 0.0, -15.0)

        RY = (GLfloat * 16)(*identityMatrix)
        m3dRotationMatrix44(RY, f * 0.34, 0.0, 1.0, 0.0)

        T2 = (GLfloat * 16)(*identityMatrix)
        m3dTranslateMatrix44(T2, 0.0, -4.0, 0.0)

        mv_matrix = (GLfloat * 16)(*identityMatrix)
        mv_matrix = m3dMultiply(T1, m3dMultiply(RY, T2))

        RX = (GLfloat * 16)(*identityMatrix)
        m3dRotationMatrix44(RX, f * 6.0, 1.0, 0.0, 0.0)

        RY = (GLfloat * 16)(*identityMatrix)
        m3dRotationMatrix44(RY, f * 7.3, 0.0, 1.0, 0.0)

        plane_matrix = (GLfloat * 16)(*identityMatrix)
        plane_matrix = m3dMultiply(RX, RY)

        plane = plane_matrix[0:4]
        plane[3] = 0
        plane = normalize(plane)

        clip_sphere = [
            sin(f * 0.7) * 3.0,
            cos(f * 1.9) * 3.0,
            sin(f * 0.1) * 3.0,
            cos(f * 1.7) + 2.5
        ]

        glUniformMatrix4fv(uniform.proj_matrix, 1, GL_FALSE, proj_matrix)
        glUniformMatrix4fv(uniform.mv_matrix, 1, GL_FALSE, mv_matrix)
        glUniform4fv(uniform.clip_plane, 1, plane)
        glUniform4fv(uniform.clip_sphere, 1, clip_sphere)

        glEnable(GL_DEPTH_TEST)
        glEnable(GL_CLIP_DISTANCE0)
        glEnable(GL_CLIP_DISTANCE1)

        glActiveTexture(GL_TEXTURE0)
        glBindTexture(GL_TEXTURE_2D, tex_dragon)
        myobject.render()

        glutSwapBuffers()
示例#22
0
    def display(self):
        
        currentTime = time.time()

        gray = [ 0.1, 0.1, 0.1, 0.0 ]
        one = 1.0

        last_time = 0.0
        total_time = 0.0

        if (not paused):
            total_time += (currentTime - last_time)
        last_time = currentTime

        t = total_time

        patch_initializer = [
            -1.0,  -1.0,  0.0,
            -0.33, -1.0,  0.0,
             0.33, -1.0,  0.0,
             1.0,  -1.0,  0.0,

            -1.0,  -0.33, 0.0,
            -0.33, -0.33, 0.0,
             0.33, -0.33, 0.0,
             1.0,  -0.33, 0.0,

            -1.0,   0.33, 0.0,
            -0.33,  0.33, 0.0,
             0.33,  0.33, 0.0,
             1.0,   0.33, 0.0,

            -1.0,   1.0,  0.0,
            -0.33,  1.0,  0.0,
             0.33,  1.0,  0.0,
             1.0,   1.0,  0.0,
        ]

        glViewport(0, 0, self.width, self.height)
        glClearBufferfv(GL_COLOR, 0, gray)
        glClearBufferfv(GL_DEPTH, 0, one)

        glEnable(GL_DEPTH_TEST)

        p = glMapBufferRange(GL_ARRAY_BUFFER, 0, ctypes.sizeof(ctypes.c_float)*3*16, GL_MAP_WRITE_BIT | GL_MAP_INVALIDATE_BUFFER_BIT)

        ppp = ((ctypes.c_float * 3) * 16).from_address(p) 

        for i in range(0, 16):

            fi = float(i) / 16.0
            
            ppp[i][0] = patch_initializer[i*3]
            ppp[i][1] = patch_initializer[(i*3)+1]
            
            ppp[i][2] = sin(t * (0.2 + fi * 0.3))
        
        glUnmapBuffer(GL_ARRAY_BUFFER)

        glBindVertexArray(patch_vao)

        glUseProgram(tess_program)

        proj_matrix = (GLfloat * 16)(*identityMatrix)
        proj_matrix = m3dPerspective(m3dDegToRad(50.0), float(self.width) / float(self.height), 1.0, 1000.0)

        T = (GLfloat * 16)(*identityMatrix)
        m3dTranslateMatrix44(T, 0.0, 0.0, -4.0)
    
        RX = (GLfloat * 16)(*identityMatrix)
        m3dRotationMatrix44(RX, t * m3dDegToRad(10.0), 1.0, 0.0, 0.0)

        RY = (GLfloat * 16)(*identityMatrix)
        m3dRotationMatrix44(RY, t * m3dDegToRad(17.0), 0.0, 1.0, 0.0)
        
        mv_matrix = (GLfloat * 16)(*identityMatrix)
        mv_matrix = m3dMultiply(T, m3dMultiply(RX, RY))
        
        glUniformMatrix4fv(uniform.patch.mv_matrix, 1, GL_FALSE, mv_matrix)
        glUniformMatrix4fv(uniform.patch.proj_matrix, 1, GL_FALSE, proj_matrix)
        glUniformMatrix4fv(uniform.patch.mvp, 1, GL_FALSE, m3dMultiply(proj_matrix , mv_matrix))

        if (wireframe):
            glPolygonMode(GL_FRONT_AND_BACK, GL_LINE)
        else:
            glPolygonMode(GL_FRONT_AND_BACK, GL_FILL)
       
        glPatchParameteri(GL_PATCH_VERTICES, 16)
        glDrawArrays(GL_PATCHES, 0, 16)

        glUseProgram(draw_cp_program)
        glUniformMatrix4fv(uniform.control_point.mvp, 1, GL_FALSE, m3dMultiply(proj_matrix , mv_matrix))

        if (show_points):
            glPointSize(9.0)
            glUniform4fv(uniform.control_point.draw_color, 1, [0.2, 0.7, 0.9, 1.0])
            glDrawArrays(GL_POINTS, 0, 16)
        
        if (show_cage):
            glUniform4fv(uniform.control_point.draw_color, 1, [0.7, 0.9, 0.2, 1.0])
            glDrawElements(GL_LINES, 48, GL_UNSIGNED_SHORT, None)
        
        glPolygonMode(GL_FRONT_AND_BACK, GL_FILL)
        overlay.draw()

        glutSwapBuffers()
示例#23
0
    def display(self):

        global camera_view_matrix
        global camera_proj_matrix
        global objects

        currentTime = time.time()

        zeros = [0.0, 0.0, 0.0, 0.0]

        last_time = 0.0
        total_time = 0.0

        if (not paused):
            total_time += (currentTime - last_time)
        last_time = currentTime

        f = total_time + 30.0

        view_position = [0.0, 0.0, 40.0]

        camera_proj_matrix = (GLfloat * 16)(*identityMatrix)
        camera_proj_matrix = m3dPerspective(
            m3dDegToRad(50.0),
            float(self.width) / float(self.height), 2.0, 300.0)

        camera_view_matrix = (GLfloat * 16)(*identityMatrix)
        camera_view_matrix = m3dLookAt(view_position, [0.0, 0.0, 0.0],
                                       [0.0, 1.0, 0.0])

        T1 = (GLfloat * 16)(*identityMatrix)
        m3dTranslateMatrix44(T1, 5.0, 0.0, 20.0)

        RY = (GLfloat * 16)(*identityMatrix)
        m3dRotationMatrix44(RY, f * m3dDegToRad(14.5), 0.0, 1.0, 0.0)

        RX = (GLfloat * 16)(*identityMatrix)
        m3dRotationMatrix44(RX, m3dDegToRad(20.0), 1.0, 0.0, 0.0)

        T2 = (GLfloat * 16)(*identityMatrix)
        m3dTranslateMatrix44(T2, 0.0, -4.0, 0.0)

        model_matrix = (GLfloat * 16)(*identityMatrix)
        model_matrix = m3dMultiply(T1, m3dMultiply(RY, m3dMultiply(RX, T2)))

        objects[0].model_matrix = model_matrix

        T1 = (GLfloat * 16)(*identityMatrix)
        m3dTranslateMatrix44(T1, -5.0, 0.0, 0.0)

        RY = (GLfloat * 16)(*identityMatrix)
        m3dRotationMatrix44(RY, f * m3dDegToRad(14.5), 0.0, 1.0, 0.0)

        RX = (GLfloat * 16)(*identityMatrix)
        m3dRotationMatrix44(RX, m3dDegToRad(20.0), 1.0, 0.0, 0.0)

        T2 = (GLfloat * 16)(*identityMatrix)
        m3dTranslateMatrix44(T2, 0.0, -4.0, 0.0)

        model_matrix = (GLfloat * 16)(*identityMatrix)
        model_matrix = m3dMultiply(T1, m3dMultiply(RY, m3dMultiply(RX, T2)))

        objects[1].model_matrix = model_matrix

        T1 = (GLfloat * 16)(*identityMatrix)
        m3dTranslateMatrix44(T1, -15.0, 0.0, 0.0)

        RY = (GLfloat * 16)(*identityMatrix)
        m3dRotationMatrix44(RY, f * m3dDegToRad(14.5), 0.0, 1.0, 0.0)

        RX = (GLfloat * 16)(*identityMatrix)
        m3dRotationMatrix44(RX, m3dDegToRad(20.0), 1.0, 0.0, 0.0)

        T2 = (GLfloat * 16)(*identityMatrix)
        m3dTranslateMatrix44(T2, 0.0, -4.0, 0.0)

        model_matrix = (GLfloat * 16)(*identityMatrix)
        model_matrix = m3dMultiply(T1, m3dMultiply(RY, m3dMultiply(RX, T2)))

        objects[2].model_matrix = model_matrix

        T1 = (GLfloat * 16)(*identityMatrix)
        m3dTranslateMatrix44(T1, -25.0, 0.0, -40.0)

        RY = (GLfloat * 16)(*identityMatrix)
        m3dRotationMatrix44(RY, f * m3dDegToRad(14.5), 0.0, 1.0, 0.0)

        RX = (GLfloat * 16)(*identityMatrix)
        m3dRotationMatrix44(RX, m3dDegToRad(20.0), 1.0, 0.0, 0.0)

        T2 = (GLfloat * 16)(*identityMatrix)
        m3dTranslateMatrix44(T2, 0.0, -4.0, 0.0)

        model_matrix = (GLfloat * 16)(*identityMatrix)
        model_matrix = m3dMultiply(T1, m3dMultiply(RY, m3dMultiply(RX, T2)))

        objects[3].model_matrix = model_matrix

        T1 = (GLfloat * 16)(*identityMatrix)
        m3dTranslateMatrix44(T1, -35.0, 0.0, -60.0)

        RY = (GLfloat * 16)(*identityMatrix)
        m3dRotationMatrix44(RY, f * m3dDegToRad(14.5), 0.0, 1.0, 0.0)

        RX = (GLfloat * 16)(*identityMatrix)
        m3dRotationMatrix44(RX, f * m3dDegToRad(20.0), 1.0, 0.0, 0.0)

        T2 = (GLfloat * 16)(*identityMatrix)
        m3dTranslateMatrix44(T2, 0.0, -4.0, 0.0)

        model_matrix = (GLfloat * 16)(*identityMatrix)
        model_matrix = m3dMultiply(T1, m3dMultiply(RY, m3dMultiply(RX, T2)))

        objects[4].model_matrix = model_matrix

        glEnable(GL_DEPTH_TEST)
        self.render_scene(total_time)

        glUseProgram(filter_program)

        glBindImageTexture(0, color_tex, 0, GL_FALSE, 0, GL_READ_ONLY,
                           GL_RGBA32F)
        glBindImageTexture(1, temp_tex, 0, GL_FALSE, 0, GL_WRITE_ONLY,
                           GL_RGBA32F)

        glDispatchCompute(self.height, 1, 1)

        glMemoryBarrier(GL_SHADER_IMAGE_ACCESS_BARRIER_BIT)

        glBindImageTexture(0, temp_tex, 0, GL_FALSE, 0, GL_READ_ONLY,
                           GL_RGBA32F)
        glBindImageTexture(1, color_tex, 0, GL_FALSE, 0, GL_WRITE_ONLY,
                           GL_RGBA32F)

        glDispatchCompute(self.width, 1, 1)

        glMemoryBarrier(GL_SHADER_IMAGE_ACCESS_BARRIER_BIT)

        glActiveTexture(GL_TEXTURE0)
        glBindTexture(GL_TEXTURE_2D, color_tex)
        glDisable(GL_DEPTH_TEST)
        glUseProgram(display_program)
        glUniform1f(uniforms.dof.focal_distance, focal_distance)
        glUniform1f(uniforms.dof.focal_depth, focal_depth)
        glBindVertexArray(quad_vao)
        glDrawArrays(GL_TRIANGLE_STRIP, 0, 4)

        overlay.draw()

        glutSwapBuffers()
示例#24
0
    def display(self):

        currentTime = time.time()


        i=0
        black = [ 0.0, 0.0, 0.0, 1.0 ]
        one = 1.0

        glViewport(0, 0, self.width, self.height)
        glClearBufferfv(GL_COLOR, 0, black)
        glClearBufferfv(GL_DEPTH, 0, one)

        # // Each rectangle will be 7/16 of the screen
        viewport_width = (7 * self.width) / 16.0
        viewport_height = (7 * self.height) / 16.0

        # // Four rectangles - lower left first...
        glViewportIndexedf(0, 0, 0, viewport_width, viewport_height);

        # // Lower right...
        glViewportIndexedf(1,
                           self.width - viewport_width, 0,
                           viewport_width, viewport_height);

        # // Upper left...
        glViewportIndexedf(2,
                           0, self.height - viewport_height,
                           viewport_width, viewport_height);

        # // Upper right...
        glViewportIndexedf(3,
                           self.width - viewport_width,
                           self.height - viewport_height,
                           viewport_width, viewport_height);


        proj_matrix = (GLfloat * 16)(*identityMatrix)
        proj_matrix = m3dPerspective(m3dDegToRad(50.0), float(self.width) / float(self.height), .1, 1000.0)


        f = currentTime * 0.3;

        glBindBufferBase(GL_UNIFORM_BUFFER, 0, uniform_buffer)
        
        mv_matrix_array = glMapBufferRange(GL_UNIFORM_BUFFER,
                                           0,
                                           4 * glm.sizeof(glm.mat4()),
                                           GL_MAP_WRITE_BIT | GL_MAP_INVALIDATE_BUFFER_BIT)

        mv_matrix_array_p = (GLfloat * 16 * 4).from_address(mv_matrix_array) 
        
        for i in range(0, 4):

            T = (GLfloat * 16)(*identityMatrix)
            m3dTranslateMatrix44(T, 0.0, 0.0, -2.0)
        
            RY = (GLfloat * 16)(*identityMatrix)
            m3dRotationMatrix44(RY, currentTime * m3dDegToRad(17.0)*(i+1), 0.0, 1.0, 0.0)
            
            RX = (GLfloat * 16)(*identityMatrix)
            m3dRotationMatrix44(RX, currentTime * m3dDegToRad(10.0)*(i+1), 1.0, 0.0, 0.0)
            
            mv_matrix = (GLfloat * 16)(*identityMatrix)
            mv_matrix = m3dMultiply(T, m3dMultiply(RY, RX))
            
            mvp_matrix = m3dMultiply(proj_matrix , mv_matrix)
            
            mv_matrix_array_p[i][:] = mvp_matrix


        glUnmapBuffer(GL_UNIFORM_BUFFER)
        glUseProgram(program)
        glDrawElements(GL_TRIANGLES, 36, GL_UNSIGNED_SHORT, 0)

        glutSwapBuffers()
    def display(self):
        global light_proj_matrix
        global light_view_matrix
        global camera_view_matrix
        global camera_proj_matrix
        global objects

        currentTime = time.time()

        zeros = [0.0, 0.0, 0.0, 0.0]

        last_time = 0.0
        total_time = 0.0

        if (not paused):
            total_time += (currentTime - last_time)
        last_time = currentTime

        f = total_time + 30.0

        light_position = (20.0, 20.0, 20.0)
        view_position = (0.0, 0.0, 40.0)

        light_proj_matrix = glm_mat4x4_to_list(
            glm.frustum(-1.0, 1.0, -1.0, 1.0, 1.0, 200.0))

        light_view_matrix = (GLfloat * 16)(*identityMatrix)
        light_view_matrix = m3dLookAt(light_position, (0.0, 0.0, 0.0),
                                      (0.0, 1.0, 0.0))

        camera_proj_matrix = (GLfloat * 16)(*identityMatrix)
        camera_proj_matrix = m3dPerspective(
            m3dDegToRad(50.0),
            float(self.width) / float(self.height), 1.0, 200.0)

        camera_view_matrix = (GLfloat * 16)(*identityMatrix)
        camera_view_matrix = m3dLookAt(view_position, (0.0, 0.0, 0.0),
                                       (0.0, 1.0, 0.0))

        RY = (GLfloat * 16)(*identityMatrix)
        m3dRotationMatrix44(RY, f * m3dDegToRad(14.5), 0.0, 1.0, 0.0)

        RX = (GLfloat * 16)(*identityMatrix)
        m3dRotationMatrix44(RX, m3dDegToRad(20.0), 1.0, 0.0, 0.0)

        T = (GLfloat * 16)(*identityMatrix)
        m3dTranslateMatrix44(T, 0.0, -4.0, 0.0)

        objects[0].model_matrix = m3dMultiply(RY, m3dMultiply(RX, T))

        RY = (GLfloat * 16)(*identityMatrix)
        m3dRotationMatrix44(RY, f * m3dDegToRad(3.7), 0.0, 1.0, 0.0)

        T = (GLfloat * 16)(*identityMatrix)
        m3dTranslateMatrix44(T,
                             sin(f * 0.37) * 12.0,
                             cos(f * 0.37) * 12.0, 0.0)

        S = (GLfloat * 16)(*identityMatrix)
        S = scale(2.0)

        objects[1].model_matrix = m3dMultiply(RY, m3dMultiply(T, S))

        RY = (GLfloat * 16)(*identityMatrix)
        m3dRotationMatrix44(RY, f * m3dDegToRad(6.45), 0.0, 1.0, 0.0)

        T = (GLfloat * 16)(*identityMatrix)
        m3dTranslateMatrix44(T,
                             sin(f * 0.25) * 10.0,
                             cos(f * 0.25) * 10.0, 0.0)

        RZ = (GLfloat * 16)(*identityMatrix)
        m3dRotationMatrix44(RZ, f * m3dDegToRad(99.0), 0.0, 0.0, 1.0)

        S = (GLfloat * 16)(*identityMatrix)
        S = scale(2.0)

        objects[2].model_matrix = m3dMultiply(
            RY, m3dMultiply(T, m3dMultiply(RZ, S)))

        RY = (GLfloat * 16)(*identityMatrix)
        m3dRotationMatrix44(RY, f * m3dDegToRad(5.25), 0.0, 1.0, 0.0)

        T = (GLfloat * 16)(*identityMatrix)
        m3dTranslateMatrix44(T,
                             sin(f * 0.51) * 14.0,
                             cos(f * 0.51) * 14.0, 0.0)

        RZ = (GLfloat * 16)(*identityMatrix)
        m3dRotationMatrix44(RZ, f * m3dDegToRad(120.3), 0.707106, 0.0,
                            0.707106)

        S = (GLfloat * 16)(*identityMatrix)
        S = scale(2.0)

        objects[3].model_matrix = m3dMultiply(
            RY, m3dMultiply(T, m3dMultiply(RZ, S)))

        glEnable(GL_DEPTH_TEST)
        self.render_scene(total_time, True)

        if (mode == RENDER_DEPTH):

            glDisable(GL_DEPTH_TEST)
            glBindVertexArray(quad_vao)
            glUseProgram(show_light_depth_program)
            glBindTexture(GL_TEXTURE_2D, depth_debug_tex)
            glDrawArrays(GL_TRIANGLE_STRIP, 0, 4)

        else:
            self.render_scene(total_time, False)

        glutSwapBuffers()
    def display(self):

        green = [0.0, 0.1, 0.0, 0.0]
        currentTime = time.time()
        f = currentTime

        zeros = [0.0, 0.0, 0.0, 0.0]
        gray = [0.1, 0.1, 0.1, 0.0]
        ones = [1.0]

        glViewport(0, 0, self.width, self.height)

        glMemoryBarrier(GL_SHADER_IMAGE_ACCESS_BARRIER_BIT
                        | GL_ATOMIC_COUNTER_BARRIER_BIT
                        | GL_SHADER_STORAGE_BARRIER_BIT)

        glUseProgram(clear_program)
        glBindVertexArray(dummy_vao)
        glDrawArrays(GL_TRIANGLE_STRIP, 0, 4)

        glUseProgram(append_program)

        model_matrix = (GLfloat * 16)(*identityMatrix)
        model_matrix = scale(6.0)

        view_matrix = (GLfloat * 16)(*identityMatrix)
        view_matrix = m3dLookAt([
            math.cos(f * 0.35) * 120.0,
            math.cos(f * 0.4) * 30.0,
            math.sin(f * 0.35) * 120.0
        ], [0.0, -20.0, 0.0], [0.0, 1, 0.0])

        mv_matrix = (GLfloat * 16)(*identityMatrix)
        mv_matrix = m3dMultiply(view_matrix, model_matrix)

        proj_matrix = (GLfloat * 16)(*identityMatrix)
        proj_matrix = m3dPerspective(m3dDegToRad(50.0),
                                     float(self.width) / float(self.height),
                                     0.1, 1000.0)

        glUniformMatrix4fv(uniform.mvp, 1, GL_FALSE,
                           m3dMultiply(proj_matrix, mv_matrix))

        zero = 0
        glBindBufferBase(GL_ATOMIC_COUNTER_BUFFER, 0, atomic_counter_buffer)

        # next line not working ????
        #glBufferSubData(GL_ATOMIC_COUNTER_BUFFER, 0, sys.getsizeof(zero), zero);

        glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 0, fragment_buffer)

        glBindImageTexture(0, head_pointer_image, 0, GL_FALSE, 0,
                           GL_READ_WRITE, GL_R32UI)

        glMemoryBarrier(GL_SHADER_IMAGE_ACCESS_BARRIER_BIT
                        | GL_ATOMIC_COUNTER_BARRIER_BIT
                        | GL_SHADER_STORAGE_BARRIER_BIT)

        myobject.render()

        glMemoryBarrier(GL_SHADER_IMAGE_ACCESS_BARRIER_BIT
                        | GL_ATOMIC_COUNTER_BARRIER_BIT
                        | GL_SHADER_STORAGE_BARRIER_BIT)

        glUseProgram(resolve_program)

        glBindVertexArray(dummy_vao)

        glMemoryBarrier(GL_SHADER_IMAGE_ACCESS_BARRIER_BIT
                        | GL_ATOMIC_COUNTER_BARRIER_BIT
                        | GL_SHADER_STORAGE_BARRIER_BIT)

        glDrawArrays(GL_TRIANGLE_STRIP, 0, 4)

        glutSwapBuffers()
示例#27
0
    def display(self):
        global light_proj_matrix
        global light_view_matrix
        global camera_proj_matrix
        global camera_view_matrix

        currentTime = time.time()

        zeros = [0.0, 0.0, 0.0, 0.0]

        last_time = 0.0
        total_time = 0.0

        if (not paused):
            total_time += (currentTime - last_time)
        last_time = currentTime

        f = float(total_time + 30.0)

        light_position = [20.0, 20.0, 20.0]
        view_position = [0.0, 0.0, 40.0]

        light_proj_matrix = glm.frustum(-1.0, 1.0, -1.0, 1.0, 1.0, 200.0)

        light_view_matrix = (GLfloat * 16)(*identityMatrix)
        light_view_matrix = m3dLookAt(light_position, (0.0, 0.0, 0.0),
                                      (0.0, 1.0, 0.0))

        camera_proj_matrix = (GLfloat * 16)(*identityMatrix)
        camera_proj_matrix = m3dPerspective(
            m3dDegToRad(50.0),
            float(self.width) / float(self.height), 1.0, 200.0)

        camera_view_matrix[0] = (GLfloat * 16)(*identityMatrix)
        camera_view_matrix[0] = m3dLookAt(
            view_position - glm.vec3(separation, 0.0, 0.0), (0.0, 0.0, -50.0),
            (0.0, 1.0, 0.0))

        camera_view_matrix[1] = (GLfloat * 16)(*identityMatrix)
        camera_view_matrix[1] = m3dLookAt(
            view_position - glm.vec3(separation, 0.0, 0.0), (0.0, 0.0, -50.0),
            (0.0, 1.0, 0.0))

        objects[0].model_matrix = (GLfloat * 16)(*identityMatrix)

        RY = (GLfloat * 16)(*identityMatrix)
        m3dRotationMatrix44(RY, f * 14.5, 0.0, 1.0, 0.0)

        RX = (GLfloat * 16)(*identityMatrix)
        m3dRotationMatrix44(RX, 20.0, 1.0, 0.0, 0.0)

        T = (GLfloat * 16)(*identityMatrix)
        m3dTranslateMatrix44(T, 0.0, -4.0, 0.0)

        mv_matrix = (GLfloat * 16)(*identityMatrix)
        mv_matrix = m3dMultiply(RY, m3dMultiply(RX, T))

        objects[0].model_matrix = mv_matrix

        objects[1].model_matrix = (GLfloat * 16)(*identityMatrix)

        RY = (GLfloat * 16)(*identityMatrix)
        m3dRotationMatrix44(RY, f * 3.7, 0.0, 1.0, 0.0)

        T = (GLfloat * 16)(*identityMatrix)
        m3dTranslateMatrix44(T,
                             sin(f * 0.37) * 12.0,
                             cos(f * 0.37) * 12.0, 0.0)

        S = (GLfloat * 16)(*identityMatrix)
        S = scale(2.0)

        mv_matrix = (GLfloat * 16)(*identityMatrix)
        mv_matrix = m3dMultiply(RY, m3dMultiply(T, S))

        objects[1].model_matrix = mv_matrix

        objects[2].model_matrix = (GLfloat * 16)(*identityMatrix)

        RY = (GLfloat * 16)(*identityMatrix)
        m3dRotationMatrix44(RY, f * 6.45, 0.0, 1.0, 0.0)

        T = (GLfloat * 16)(*identityMatrix)
        m3dTranslateMatrix44(T,
                             sin(f * 0.25) * 10.0,
                             cos(f * 0.25) * 10.0, 0.0)

        RZ = (GLfloat * 16)(*identityMatrix)
        m3dRotationMatrix44(RZ, f * 99.0, 0.0, 0.0, 1.0)

        S = (GLfloat * 16)(*identityMatrix)
        S = scale(2.0)

        mv_matrix = (GLfloat * 16)(*identityMatrix)
        mv_matrix = m3dMultiply(RY, m3dMultiply(T, m3dMultiply(RZ, S)))

        objects[2].model_matrix = mv_matrix

        objects[3].model_matrix = (GLfloat * 16)(*identityMatrix)

        RY = (GLfloat * 16)(*identityMatrix)
        m3dRotationMatrix44(RY, f * 5.25, 0.0, 1.0, 0.0)

        T = (GLfloat * 16)(*identityMatrix)
        m3dTranslateMatrix44(T,
                             sin(f * 0.51) * 14.0,
                             cos(f * 0.51) * 14.0, 0.0)

        RDOUBLE = (GLfloat * 16)(*identityMatrix)
        m3dRotationMatrix44(RDOUBLE, f * 120.3, 0.707106, 0.0, 0.707106)

        S = (GLfloat * 16)(*identityMatrix)
        S = scale(2.0)

        mv_matrix = (GLfloat * 16)(*identityMatrix)
        mv_matrix = m3dMultiply(RY, m3dMultiply(T, m3dMultiply(RDOUBLE, S)))

        objects[3].model_matrix = mv_matrix

        glEnable(GL_DEPTH_TEST)

        self.render_scene(total_time)

        glutSwapBuffers()