def init(): width = 640 height = 640 glfw.Init() glfw.OpenWindow(width, height, 8, 8, 8, 0, 24, 0, glfw.WINDOW) glfw.SetWindowTitle("glfw line") glfw.SetWindowSizeCallback(Reshape) glClearColor(0.0, 0.0, 0.0, 0.0); glEnable(GL_DEPTH_TEST) glDepthFunc(GL_LEQUAL); glfw.SetMouseButtonCallback(MouseHandler) glfw.SetKeyCallback(KeyboardHandler) glfw.SetWindowCloseCallback(WindowCLose) global heightmap, terrain_size tmpheightmap = open("heightmap.raw", 'rb').read() for c in tmpheightmap: heightmap.append(ord(c)) print heightmap terrain_size = int(sqrt(len(heightmap))) print terrain_size if(glFogCoordfEXT): # test print 'ok'
def init(textureImg): width = 640 height = 640 glfw.Init() glfw.OpenWindow(width, height, 8, 8, 8, 0, 24, 0, glfw.WINDOW) glfw.SetWindowTitle("glfw mesh") glfw.SetWindowSizeCallback(Reshape) glfw.SetMouseButtonCallback(MouseHandler) glfw.SetKeyCallback(KeyboardHandler) glfw.SetWindowCloseCallback(WindowCLose) glClearColor(1.0, 1.0, 1.0, 1.0) glEnable(GL_DEPTH_TEST) glDepthFunc(GL_LEQUAL) glEnable(GL_TEXTURE_2D) # texture one textureHandle = glGenTextures(1) glBindTexture(GL_TEXTURE_2D, textureHandle) # filter for min and mag texture glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR) glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR) # specify the texture glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, textureImg.size[0], textureImg.size[1], 0, GL_RGB, GL_UNSIGNED_BYTE, PIL2array(textureImg)) return textureHandle
def GlfwInit(): width = 640 height = 640 glfw.Init() glfw.OpenWindow(width, height, 8, 8, 8, 0, 24, 0, glfw.WINDOW) glfw.SetWindowTitle("glfw line") glfw.SetWindowSizeCallback(Reshape) glfw.SetMouseButtonCallback(MouseHandler) glfw.SetKeyCallback(KeyboardHandler)
def init(): width = 640 height = 480 glfw.Init() glfw.OpenWindow(width, height, 8, 8, 8, 0, 24, 0, glfw.WINDOW) glfw.SetWindowTitle("glfw circle") glfw.SetWindowSizeCallback(Reshape) glEnable(GL_DEPTH_TEST) # set eht projection # mouse glfw.SetMouseButtonCallback(MouseHandler) glfw.SetKeyCallback(KeyboardHandler)
def init(): width = 640 height = 480 glfw.Init() glfw.OpenWindow(1440, 900, 8, 8, 8, 0, 24, 0, glfw.FULLSCREEN) glfw.SetWindowTitle("full glfw") glfw.SetWindowSizeCallback(Reshape) glEnable(GL_DEPTH_TEST) # set eht projection # mouse glfw.SetMouseButtonCallback(MouseHandler) glfw.SetKeyCallback(KeyboardHandler)
def init(): width = 640 height = 640 glfw.Init() glfw.OpenWindow(width, height, 8, 8, 8, 0, 24, 0, glfw.WINDOW) glfw.SetWindowTitle("glfw line") glfw.SetWindowSizeCallback(Reshape) glfw.SetMouseButtonCallback(MouseHandler) glfw.SetKeyCallback(KeyboardHandler) glfw.SetWindowCloseCallback(WindowCLose) glClearColor(0.0, 0.0, 0.0, 0.0) glEnable(GL_DEPTH_TEST) glDepthFunc(GL_LEQUAL)
def init(): width = 640 height = 480 glfw.Init() glfw.OpenWindow(width, height, 8, 8, 8, 0, 24, 0, glfw.WINDOW) glfw.SetWindowTitle("glfw cube change projection") glfw.SetWindowSizeCallback(Reshape) glEnable(GL_DEPTH_TEST) glDepthFunc(GL_LEQUAL) # ��ʲô���� glPolygonMode(GL_FRONT_AND_BACK, GL_LINE) glfw.SetMouseButtonCallback(MouseHandler) glfw.SetKeyCallback(KeyboardHandler) glfw.SetMousePosCallback(MouseMoveHandler)
def init(): width = 1024 height = 768 glfw.Init() glfw.OpenWindow(width, height, 8, 8, 8, 0, 24, 0, glfw.WINDOW) glfw.SetWindowTitle("glfw line") glfw.SetWindowSizeCallback(Reshape) glClearColor(0.0, 0.0, 0.0, 0.0) glEnable(GL_DEPTH_TEST) glDepthFunc(GL_LEQUAL) glfw.SetMouseButtonCallback(MouseHandler) glfw.SetKeyCallback(KeyboardHandler) glfw.SetWindowCloseCallback(WindowCLose) global m_tga m_tga.load("rock.tga") m_tga_un.load("opengl_logo_un.tga")
def init(): width = 640 height = 640 glfw.Init() glfw.OpenWindow(width, height, 8, 8, 8, 0, 24, 0, glfw.WINDOW) glfw.SetWindowTitle("glfw line") glfw.SetWindowSizeCallback(Reshape) glClearColor(0.0, 0.0, 0.0, 0.0) glEnable(GL_DEPTH_TEST) glDepthFunc(GL_LEQUAL) # set eht projection global m_pDisk glfw.SetMouseButtonCallback(MouseHandler) glfw.SetKeyCallback(KeyboardHandler) m_pDisk = gluNewQuadric() if (glBlendColorEXT): print "found" glBlendColorEXT(0.5, 0.5, 0.5, 0.5)
def init(): width = 1024 height = 768 glfw.Init() glfw.OpenWindow(width, height, 8, 8, 8, 0, 24, 0, glfw.WINDOW) glfw.SetWindowTitle("glfw line") glfw.SetWindowSizeCallback(Reshape) glfw.SetMouseButtonCallback(MouseHandler) glfw.SetKeyCallback(KeyboardHandler) glfw.SetWindowCloseCallback(WindowCLose) glClearColor(0.0, 0.0, 0.0, 0.0) glEnable(GL_TEXTURE_2D) global texture1, texture2, textureOne, textureTwo if (not texture1.load("opengl_logo.tga")): exit(0) if (not texture2.load("checkerboard.tga")): exit(0) print texture1.m_width, texture1.m_height # texture one textureOne = glGenTextures(1) glBindTexture(GL_TEXTURE_2D, textureOne) # filter for min and mag texture glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR) glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR) # specify the texture glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, texture1.m_width, texture1.m_height, 0, GL_RGB, GL_UNSIGNED_BYTE, texture1.m_imageData) # texure two textureTwo = glGenTextures(1) glBindTexture(GL_TEXTURE_2D, textureTwo) glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST) glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR) glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, texture2.m_width, texture2.m_height, 0, GL_RGB, GL_UNSIGNED_BYTE, texture2.m_imageData)
glEnable(GL_LIGHT2); glLightfv(GL_LIGHT2, GL_AMBIENT, greenLightColor); glLightfv(GL_LIGHT2, GL_DIFFUSE, greenLightColor); glLightfv(GL_LIGHT2, GL_SPECULAR, greenLightColor); # get a quadric object for the light sphere m_pSphere = gluNewQuadric() def GlfwInit() width = 640 height = 640 glfw.Init() glfw.OpenWindow(width, height, 8, 8, 8, 0, 24, 0, glfw.WINDOW) glfw.SetWindowTitle(glfw line) glfw.SetWindowSizeCallback(Reshape) glfw.SetMouseButtonCallback(MouseHandler) glfw.SetKeyCallback(KeyboardHandler) def ChangeAngle(dt) global CUBE_DEG_PER_S, LIGHT_DEG_PER_S, m_cubeAngle, m_lightAngle m_cubeAngle += CUBE_DEG_PER_S dt; if (m_cubeAngle 360.0) m_cubeAngle = 0.0; m_lightAngle += LIGHT_DEG_PER_S dt; if (m_lightAngle 360.0) m_lightAngle = 0.0; GlfwInit() OpenglInit() while(True) Display()
glfw.ext.set_icons([(icon_data, icon_width, icon_height)]) glfw.SetWindowTitle("pyglfw test") glfw.Disable(glfw.AUTO_POLL_EVENTS) glfw.Enable(glfw.KEY_REPEAT) center_x = glfw.GetDesktopMode().Width / 2 - glfw.GetWindowSize()[0] / 2 center_y = glfw.GetDesktopMode().Height / 2 - glfw.GetWindowSize()[1] / 2 glfw.SetWindowPos(center_x, center_y) glfw.SetWindowSizeCallback(on_resize) glfw.SetWindowCloseCallback(on_close) glfw.SetWindowRefreshCallback(on_refresh) glfw.SetKeyCallback(on_key) glfw.SetCharCallback(on_char) glfw.SetMouseButtonCallback(on_button) glfw.SetMousePosCallback(on_pos) glfw.SetMouseWheelCallback(on_scroll) while glfw.GetWindowParam(glfw.OPENED): glfw.PollEvents() if glfw.GetKey(glfw.KEY_ESC): break glClear(GL_COLOR_BUFFER_BIT) glfw.SwapBuffers() glfw.CloseWindow() glfw.Terminate()