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()
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()
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()
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()
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()
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()
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, 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() gray = [0.2, 0.2, 0.2, 1.0] ones = [1.0] glClearBufferfv(GL_COLOR, 0, gray) glClearBufferfv(GL_DEPTH, 0, ones) glBindTexture(GL_TEXTURE_2D, tex_envmap) 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) T1 = (GLfloat * 16)(*identityMatrix) m3dTranslateMatrix44(T1, 0.0, 0.0, -15.0) RX = (GLfloat * 16)(*identityMatrix) m3dRotationMatrix44(RX, currentTime * m3dDegToRad(1.0), 1.0, 0.0, 0.0) RY = (GLfloat * 16)(*identityMatrix) m3dRotationMatrix44(RY, currentTime * m3dDegToRad(1.1), 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(RX, m3dMultiply(RY, T2))) glUniformMatrix4fv(uniforms.mv_matrix, 1, GL_FALSE, mv_matrix) glUniformMatrix4fv(uniforms.proj_matrix, 1, GL_FALSE, proj_matrix) myobject.render() 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): 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()
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()
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()
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()
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()
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_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()