本文整理汇总了Golang中github.com/jteeuwen/glfw.SwapBuffers函数的典型用法代码示例。如果您正苦于以下问题:Golang SwapBuffers函数的具体用法?Golang SwapBuffers怎么用?Golang SwapBuffers使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了SwapBuffers函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: main
func main() {
if err := glfw.Init(); err != nil {
fmt.Fprintf(os.Stderr, "glfw: %s\n", err)
return
}
defer glfw.Terminate()
glfw.OpenWindowHint(glfw.WindowNoResize, 1)
if err := glfw.OpenWindow(Width, Height, 0, 0, 0, 0, 0, 0, glfw.Windowed); err != nil {
fmt.Fprintf(os.Stderr, "glfw: %s\n", err)
return
}
defer glfw.CloseWindow()
glfw.SetSwapInterval(1)
glfw.SetWindowTitle(Title)
if err := gl.Init(); err != nil {
fmt.Fprintf(os.Stderr, "gl: %s\n", err)
}
if err := initScene(); err != nil {
fmt.Fprintf(os.Stderr, "init: %s\n", err)
return
}
defer destroyScene()
for glfw.WindowParam(glfw.Opened) == 1 {
drawScene()
glfw.SwapBuffers()
}
}
示例2: main
func main() {
var running bool = true
if err := glfw.Init(); err != nil {
fmt.Fprintf(os.Stderr, "[e] %v\n", err)
return
}
defer glfw.Terminate()
if err := glfw.OpenWindow(appWidth, appHeight, 8, 8, 8, 8,
24, 8, glfw.Windowed); err != nil {
fmt.Fprintf(os.Stderr, "[e] %v\n", err)
return
}
defer glfw.CloseWindow()
glfw.SetSwapInterval(1)
glfw.SetWindowTitle(caption)
if !horde3d.Init() {
fmt.Println("Error starting Horde3D. Check Horde3d_log.html for details.")
horde3d.DumpMessages()
return
}
//horde3d.SetOption(horde3d.Options_DebugViewMode, 1)
// Add resources
//pipeline
pipeRes = horde3d.AddResource(horde3d.ResTypes_Pipeline, "pipelines/hdr.pipeline.xml", 0)
knightRes := horde3d.AddResource(horde3d.ResTypes_SceneGraph, "models/knight/knight.scene.xml", 0)
//load resources paths separated by |
horde3d.LoadResourcesFromDisk("../content")
model := horde3d.RootNode.AddNodes(knightRes)
model.SetTransform(0, 0, -30, 0, 0, 0, 0.1, 0.1, 0.1)
// Add light source
light := horde3d.RootNode.AddLightNode("Light1", 0, "LIGHTING", "SHADOWMAP")
light.SetTransform(0, 20, 0, 0, 0, 0, 1, 1, 1)
light.SetNodeParamF(horde3d.Light_RadiusF, 0, 50)
//add camera
cam = horde3d.RootNode.AddCameraNode("Camera", pipeRes)
glfw.SetWindowSizeCallback(onResize)
for running {
horde3d.Render(cam)
horde3d.FinalizeFrame()
horde3d.DumpMessages()
glfw.SwapBuffers()
running = glfw.Key(glfw.KeyEsc) == 0 &&
glfw.WindowParam(glfw.Opened) == 1
}
horde3d.Release()
}
示例3: display
func display() {
// Clear the background as white
gl.ClearColor(1.0, 1.0, 1.0, 1.0)
gl.Clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT)
// Use the GLSL program
program.Use()
uniformTexture.Uniform1i(0)
attributeCoord3d.EnableArray()
vboCubeVertices.Bind(gl.ARRAY_BUFFER)
attributeCoord3d.AttribPointerOffset(3, gl.FLOAT, false, 0, 0)
texture.Bind(gl.TEXTURE_2D)
attributeTexCoord.EnableArray()
vboCubeTexCoords.Bind(gl.ARRAY_BUFFER)
attributeTexCoord.AttribPointerOffset(2, gl.FLOAT, false, 0, 0)
iboCubeElements.Bind(gl.ELEMENT_ARRAY_BUFFER)
//size := []int32{0}
//gl.GetBufferParameteriv(gl.ELEMENT_ARRAY_BUFFER, gl.BUFFER_SIZE, size)
gl.DrawElementsOffset(gl.TRIANGLES, len(cubeElements), gl.UNSIGNED_SHORT, 0)
attributeCoord3d.DisableArray()
attributeTexCoord.DisableArray()
// Display the result
glfw.SwapBuffers()
}
示例4: main
func main() {
glfw.Init()
defer glfw.Terminate()
glfw.OpenWindow(640, 480, 8, 8, 8, 8, 0, 0, glfw.Windowed)
defer glfw.CloseWindow()
glfw.SetWindowTitle("Tile test")
glfw.Enable(glfw.StickyKeys)
glfw.SetSwapInterval(1)
glfw.SetKeyCallback(inputCallback)
gl.MatrixMode(gl.PROJECTION)
gl.LoadIdentity()
gl.Ortho(0, GridWidth, GridHeight, 0, -1, 1)
gl.MatrixMode(gl.MODELVIEW)
gl.Disable(gl.DEPTH_TEST)
gl.Enable(gl.TEXTURE_2D)
gl.Enable(gl.BLEND)
gl.BlendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA)
gl.ClearColor(0.0, 0.0, 0.0, 1.0)
initResources()
initWorld()
for Running {
if (time.Since(DT).Nanoseconds() / 1000000) > 15 { //don't loop faster than every 15ms
DT = time.Now()
gl.Clear(gl.COLOR_BUFFER_BIT)
player.update()
renderScene()
glfw.SwapBuffers()
}
}
}
示例5: drawScene
func drawScene() {
gl.Clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT)
gl.LoadIdentity()
gl.Translatef(-1.5, 0, -6)
gl.Rotatef(trisAngle, 0, 1, 0)
gl.Begin(gl.TRIANGLES)
gl.Color3f(1, 0, 0)
gl.Vertex3f(0, 1, 0)
gl.Color3f(0, 1, 0)
gl.Vertex3f(-1, -1, 0)
gl.Color3f(0, 0, 1)
gl.Vertex3f(1, -1, 0)
gl.End()
gl.LoadIdentity()
gl.Translatef(1.5, 0, -6)
gl.Rotatef(quadAngle, 1, 0, 0)
gl.Color3f(0.5, 0.5, 1.0)
gl.Begin(gl.QUADS)
gl.Vertex3f(-1, 1, 0)
gl.Vertex3f(1, 1, 0)
gl.Vertex3f(1, -1, 0)
gl.Vertex3f(-1, -1, 0)
gl.End()
trisAngle += 0.2
quadAngle -= 0.15
glfw.SwapBuffers()
}
示例6: GameLoop
func GameLoop() {
t := 0.0
dt := 0.1
CreateUniverse()
camera.PositionCamera(0, 0, 1000, 900)
for glfw.WindowParam(glfw.Opened) == 1 {
t += dt
gl.Clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT)
gl.Clear(gl.DEPTH_BUFFER_BIT | gl.LIGHTING_BIT)
for i := range universe.Systems {
for j := range universe.Systems[i].Planets {
BufferPlanet(universe.Systems[i].Planets[j])
ai.PlanetOrbit(universe.Systems[i].Planets[j], t)
}
for j := range universe.Systems[i].Stars {
BufferStar(universe.Systems[i].Stars[j])
ai.StarStationary(universe.Systems[i].Stars[j], t)
}
}
glfw.SwapBuffers()
}
}
示例7: Render
// Render draws the contents of the window, but no more than 30
// times per second.
func (w *Window) Render() {
// Don't render more than 30 times per second.
t := time.Now()
if time.Since(w.lastRender).Seconds() < 1.0/30.0 {
return
}
w.lastRender = t
// Retrieve the view width and height, in pixels.
params := make([]int32, 4)
gl.GetIntegerv(gl.VIEWPORT, params)
// Infer the rendering volume from the viewport size, so the
// the rendering code can assume that the width of a pixel is
// ~1.0. This is important when rendering text. This must
// match the gl.Frustum configuration.
width := float64(params[2])
height := float64(params[3])
depth := (width + height) / 2
// Redraw the window, but not too often.
gl.Clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT)
w.renderer.Render(width, height, depth)
glfw.SwapBuffers()
// Exit if the user presses escape or the window was closed.
if glfw.Key(glfw.KeyEsc) != 0 || glfw.WindowParam(glfw.Opened) == 0 {
os.Exit(0)
}
}
示例8: main
func main() {
var err error
if err = glfw.Init(); err != nil {
fmt.Fprintf(os.Stderr, "[e] %v\n", err)
return
}
defer glfw.Terminate()
if err = glfw.OpenWindow(640, 480, 8, 8, 8, 8, 0, 0, glfw.Windowed); err != nil {
fmt.Fprintf(os.Stderr, "[e] %v\n", err)
return
}
defer glfw.CloseWindow()
glfw.SetWindowTitle("Draw")
glfw.SetSwapInterval(1)
glfw.SetKeyCallback(onKey)
glfw.SetMouseButtonCallback(onMouseBtn)
glfw.SetWindowSizeCallback(onResize)
running = true
for running && glfw.WindowParam(glfw.Opened) == 1 {
if mouse[0] != 0 {
pen.lineTo(glfw.MousePos())
} else {
pen.moveTo(glfw.MousePos())
}
glfw.SwapBuffers()
}
}
示例9: main
func main() {
log.Println("Starting")
flag.Parse()
runtime.GOMAXPROCS(4)
initGLFW()
initGL()
initScene()
initInput()
glfw.SetWindowSizeCallback(resize)
initLua()
// Run the script file if we had one
// TODO: Do this before accepting input from user...
if fScript != "" {
runFile(fScript)
}
for glfw.WindowParam(glfw.Opened) == 1 {
display()
glfw.SwapBuffers()
time.Sleep(10 * time.Millisecond)
}
}
示例10: Render
func Render() {
UpdateViewpos()
ClearScene()
gl.Begin(gl.QUADS)
for i := range polys {
polys[i].Render()
}
gl.End()
glfw.SwapBuffers()
}
示例11: drawScene
func drawScene() {
gl.Clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT)
gl.MatrixMode(gl.MODELVIEW)
gl.LoadIdentity()
gl.Color3f(1, 1, 1)
drawShapes(space)
glfw.SwapBuffers()
}
示例12: PostFrame
func PostFrame() {
for _, l := range lines {
doDrawLine(l)
}
for _, ent := range ents {
doDrawEnt(ent)
}
lines = lines[0:0]
ents = ents[0:0]
glfw.SwapBuffers()
}
示例13: main
func main() {
var err error
if err = glfw.Init(); err != nil {
fmt.Fprintf(os.Stderr, "[e] %v\n", err)
return
}
// Ensure glfw is cleanly terminated on exit.
defer glfw.Terminate()
if err = glfw.OpenWindow(256, 256, 8, 8, 8, 0, 0, 0, glfw.Windowed); err != nil {
fmt.Fprintf(os.Stderr, "[e] %v\n", err)
return
}
// Ensure window is cleanly closed on exit.
defer glfw.CloseWindow()
// Enable vertical sync on cards that support it.
glfw.SetSwapInterval(1)
// Set window title
glfw.SetWindowTitle("Simple GLFW window")
// Hook some events to demonstrate use of callbacks.
// These are not necessary if you don't need them.
glfw.SetWindowSizeCallback(onResize)
glfw.SetWindowCloseCallback(onClose)
glfw.SetMouseButtonCallback(onMouseBtn)
glfw.SetMouseWheelCallback(onMouseWheel)
glfw.SetKeyCallback(onKey)
glfw.SetCharCallback(onChar)
// Start loop
running := true
for running {
// OpenGL rendering goes here.
// Swap front and back rendering buffers. This also implicitly calls
// glfw.PollEvents(), so we have valid key/mouse/joystick states after
// this. This behavior can be disabled by calling glfw.Disable with the
// argument glfw.AutoPollEvents. You must be sure to manually call
// PollEvents() or WaitEvents() in this case.
glfw.SwapBuffers()
// Break out of loop when Escape key is pressed, or window is closed.
running = glfw.Key(glfw.KeyEsc) == 0 && glfw.WindowParam(glfw.Opened) == 1
}
}
示例14: loop
func loop() {
e := initTriangleShaders()
if e != nil {
log.Fatalln(e.Error())
}
for esc {
gl.ClearColor(0.0, 0.0, 0.0, 0.0)
gl.Clear(gl.COLOR_BUFFER_BIT)
drawTriangle()
glfw.SwapBuffers()
timeSince()
}
}
示例15: Draw
// Render stuff
func Draw() {
gl.Clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT)
gl.LoadIdentity()
gl.Translatef(-1.5, 0, -6)
gl.Begin(gl.TRIANGLES)
gl.Color3f(1, 0, 0)
gl.Vertex3f(0, 1, 0)
gl.Color3f(0, 1, 0)
gl.Vertex3f(-1, -1, 0)
gl.Color3f(0, 0, 1)
gl.Vertex3f(1, -1, 0)
gl.End()
glfw.SwapBuffers()
}