Ejemplo n.º 1
0
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'
Ejemplo n.º 2
0
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
Ejemplo n.º 3
0
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)
Ejemplo n.º 4
0
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)
Ejemplo n.º 5
0
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)
Ejemplo n.º 6
0
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)
Ejemplo n.º 7
0
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)
Ejemplo n.º 8
0
    def initialize(self, windowWidth, windowHeight, windowName, antiAliasing, fullScreen, resizable):
        if self.initialized:
            return False

        self.running = True

        glfw.Init()


        if antiAliasing:
            glfw._glfwdll.glfwOpenWindowHint(glfw.FSAA_SAMPLES, 4)

        windowMode = glfw.WINDOW
        if fullScreen:
            windowMode = glfw.FULLSCREEN

        if resizable:
            #glfw.OpenWindowHint(glfw.WINDOW_NO_RESIZE, 0);
            pass

        print(glfw.GetGLVersion())

        glfw.OpenWindow(windowWidth, windowHeight, 0, 0, 0, 8, 0, 0, windowMode)
        glfw.SetWindowTitle(windowName)
        glfw.SetWindowPos(50,50)

        glfw.SwapInterval(1)
        glfw.SetWindowSizeCallback(camera.resize)

        glfw.Disable(glfw.KEY_REPEAT)

        #prevTime = glfw.GetT

        glClearDepth(1.0);
        glPolygonMode(GL_FRONT, GL_FILL)

        glShadeModel(GL_FLAT)

        glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST)
        glEnable(GL_CULL_FACE)
        glFrontFace(GL_CCW)
        glCullFace(GL_BACK)
        glDepthFunc(GL_LEQUAL)
        glEnable(GL_DEPTH_TEST)
        glEnable(GL_BLEND)
        glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)
        glClearStencil(0)
        glClearColor(1.0, 1.0, 1.0, 1.0)
Ejemplo n.º 9
0
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")
Ejemplo n.º 10
0
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)
Ejemplo n.º 11
0
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)
Ejemplo n.º 12
0
    def __init__(self, scene):
        """Sets up the core functionality we need
        to begin rendering.
        This includes the OpenGL configuration, the
        window, the viewport, the event handler
        and update loop registration.
        """
        super(Application, self).__init__(scene)

        glfw.Init()

        if self.scene.core_profile:
            glfw.OpenWindowHint(glfw.OPENGL_VERSION_MAJOR, 3)
            glfw.OpenWindowHint(glfw.OPENGL_VERSION_MINOR, 2)
            glfw.OpenWindowHint(glfw.OPENGL_FORWARD_COMPAT, GL.GL_TRUE)
            glfw.OpenWindowHint(glfw.OPENGL_PROFILE, glfw.OPENGL_CORE_PROFILE)

        # create our window
        glfw.OpenWindow(1024, 768, 8, 8, 8, 8, 24, 0, glfw.WINDOW)

        # set the window caption
        glfw.SetWindowTitle("PyGLy - PyGLFW - " + scene.name)

        # print some opengl information
        pygly.gl.print_gl_info()

        # create the scene now that we've got our window open
        self.scene.initialise()

        self.running = False

        # listen for resize events and close window events
        # do this AFTER initialising the scene
        # as the window size callback will trigger once set
        glfw.SetWindowSizeCallback(self.on_window_resized)
        glfw.SetWindowCloseCallback(self.on_window_closed)
        glfw.SetKeyCallback(self.on_key_event)
Ejemplo n.º 13
0
    # set up moving green light
    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)
Ejemplo n.º 14
0
glfw.OpenWindow(800, 600, 0, 0, 0, 8, 0, 0, glfw.WINDOW)

print("OpenGL version: %d.%d.%d\n" % glfw.GetGLVersion())

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)