glfw.window_hint(glfw.CONTEXT_VERSION_MINOR, 3)
    glfw.window_hint(glfw.OPENGL_PROFILE, glfw.OPENGL_CORE_PROFILE)
    glfw.window_hint(glfw.OPENGL_FORWARD_COMPAT, GL_TRUE)

window = glfw.create_window(width, height, "LearnOpenGL", None, None)
if not window:
        print("Failed to create GLFW window")
        glfw.terminate()

glfw.make_context_current(window)
glfw.set_framebuffer_size_callback(window, framebuffer_size_callback)


## Load, compile, link shaders
import myshader
shaders = myshader.shader( "shaders/hellotransform.vert", "shaders/hellotexture.frag")
shaders.linkShaders()

## Textures
import PIL.Image
im = PIL.Image.open('resources/wall.jpg')

imw, imh = im.size
imd = im.convert('RGB').transpose(PIL.Image.FLIP_TOP_BOTTOM).tobytes()
        # return Texture2D(
        #     img.size, precision,
        #     img.convert('RGBA').transpose(PIL.Image.FLIP_TOP_BOTTOM).tobytes(),
        #     GL_UNSIGNED_BYTE, 4
        # )

texture = glGenTextures(1)
示例#2
0
    print("Failed to create GLFW window")
    glfw.terminate()

glfw.make_context_current(window)
glfw.set_framebuffer_size_callback(window,
                                   inputMgr.get_framebuffer_size_callback())

glfw.set_input_mode(window, glfw.CURSOR, glfw.CURSOR_DISABLED)
glfw.set_cursor_pos_callback(window, inputMgr.get_mouse_callback())
glfw.set_scroll_callback(window, inputMgr.get_scroll_callback())
glfw.set_mouse_button_callback(window, inputMgr.get_mousebutton_callback())

glfw.set_error_callback(inputMgr.get_error_callback())

## Load, compile, link shaders
shaders = myshader.shader("shaders/basiclight-texture.vert",
                          "shaders/texturedobj.frag")
shaders.linkShaders()

lightshader = myshader.shader("shaders/hellolightingcol.vert",
                              "shaders/hellolight.frag")
lightshader.linkShaders()

# ## Textures
t1 = mytexture.texture('resources/equirectangular.jpg', GL_TEXTURE0)
t2 = mytexture.texture('resources/container2.png', GL_TEXTURE1)
t3 = mytexture.texture('resources/container2_specular.png', GL_TEXTURE2)

## Scene
import mycube
import mysphere
示例#3
0
    glfw.window_hint(glfw.CONTEXT_VERSION_MAJOR, 3)
    glfw.window_hint(glfw.CONTEXT_VERSION_MINOR, 3)
    glfw.window_hint(glfw.OPENGL_PROFILE, glfw.OPENGL_CORE_PROFILE)
    glfw.window_hint(glfw.OPENGL_FORWARD_COMPAT, GL_TRUE)

window = glfw.create_window(width, height, "LearnOpenGL", None, None)
if not window:
    print("Failed to create GLFW window")
    glfw.terminate()

glfw.make_context_current(window)
glfw.set_framebuffer_size_callback(window, framebuffer_size_callback)

## Load, compile, link shaders
import myshader
shaders = myshader.shader("shaders/hellocolor.vert", "shaders/hellocolor.frag")
shaders.linkShaders()

# set up vertex data (and buffer(s)) and configure vertex attributes
# ------------------------------------------------------------------

import numpy as np
vertices = np.array(
    [
        0.5,
        0.5,
        0.0,
        1.0,
        0.0,
        0.0,  # top right
        0.5,
示例#4
0
    print("Failed to create GLFW window")
    glfw.terminate()

glfw.make_context_current(window)
glfw.set_framebuffer_size_callback(window, framebuffer_size_callback)

glfw.set_input_mode(window, glfw.CURSOR, glfw.CURSOR_DISABLED)
glfw.set_cursor_pos_callback(window, mouse_callback)
glfw.set_scroll_callback(window, scroll_callback)
glfw.set_mouse_button_callback(window, mousebutton_callback)

glfw.set_error_callback(error_callback)

## Load, compile, link shaders
import myshader
shaders = myshader.shader("shaders/hellocoord.vert", "shaders/hellocoord.frag")
shaders.linkShaders()

# ## Textures
import mytexture
t1 = mytexture.texture('resources/wall.jpg', GL_TEXTURE0)
# t2 = mytexture.texture('awesomeface.png', GL_TEXTURE1)

## Scene
import mycube

import numpy as np
vertices = mycube.vertices

cubePositions = [
    glm.vec3(0.0, 0.0, 0.0),
示例#5
0
    print("Failed to create GLFW window")
    glfw.terminate()

glfw.make_context_current(window)
glfw.set_framebuffer_size_callback(window,
                                   inputMgr.get_framebuffer_size_callback())

glfw.set_input_mode(window, glfw.CURSOR, glfw.CURSOR_DISABLED)
glfw.set_cursor_pos_callback(window, inputMgr.get_mouse_callback())
glfw.set_scroll_callback(window, inputMgr.get_scroll_callback())
glfw.set_mouse_button_callback(window, inputMgr.get_mousebutton_callback())

glfw.set_error_callback(inputMgr.get_error_callback())

## Load, compile, link shaders
shaders = myshader.shader("shaders/basiclight.vert", "shaders/basiclight.frag")
shaders.linkShaders()

lightshader = myshader.shader("shaders/hellolightingcol.vert",
                              "shaders/hellolight.frag")
lightshader.linkShaders()

# ## Textures
# t1 = mytexture.texture('wall.jpg', GL_TEXTURE0)
# t2 = mytexture.texture('awesomeface.png', GL_TEXTURE1)

## Scene
import mycube

import numpy as np
myvertices = mycube.verticeswithnormals