本文整理汇总了Golang中github.com/jteeuwen/glfw.SwapBuffers函数的典型用法代码示例。如果您正苦于以下问题:Golang SwapBuffers函数的具体用法?Golang SwapBuffers怎么用?Golang SwapBuffers使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了SwapBuffers函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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()
}
}
开发者ID:sserafimescu,项目名称:gogl,代码行数:33,代码来源:gopher.go
示例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()
}
开发者ID:floffel03,项目名称:gohorde,代码行数:60,代码来源:glfw.go
示例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()
}
开发者ID:pdelbarba,项目名称:gl3-examples,代码行数:31,代码来源:main.go
示例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()
}
}
}
开发者ID:remirisque,项目名称:miniworld,代码行数:35,代码来源:main.go
示例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()
}
开发者ID:sycoso,项目名称:glfw,代码行数:33,代码来源:main.go
示例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()
}
}
开发者ID:kelly-ry4n,项目名称:glGalaxy,代码行数:30,代码来源:gameloop.go
示例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)
}
}
开发者ID:glenn-brown,项目名称:vu,代码行数:32,代码来源:window.go
示例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()
}
}
开发者ID:sycoso,项目名称:glfw,代码行数:33,代码来源:main.go
示例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)
}
}
开发者ID:vron,项目名称:fm,代码行数:30,代码来源:main.go
示例10: Render
func Render() {
UpdateViewpos()
ClearScene()
gl.Begin(gl.QUADS)
for i := range polys {
polys[i].Render()
}
gl.End()
glfw.SwapBuffers()
}
开发者ID:shenyp09,项目名称:mx3,代码行数:10,代码来源:magnetization.go
示例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()
}
开发者ID:ftrvxmtrx,项目名称:gochipmunk,代码行数:10,代码来源:main.go
示例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()
}
开发者ID:dane-unltd,项目名称:gina,代码行数:12,代码来源:glGraphics.go
示例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
}
}
开发者ID:andrebq,项目名称:glfw,代码行数:49,代码来源:main.go
示例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()
}
}
开发者ID:simonz05,项目名称:draw,代码行数:15,代码来源:draw.go
示例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()
}
开发者ID:andrebq,项目名称:tinygl,代码行数:17,代码来源:triangle.go
示例16: main
func main() {
flag.Parse()
if *cpuprofile != "" {
f, err := os.Create(*cpuprofile)
if err != nil {
log.Fatal(err)
}
pprof.StartCPUProfile(f)
defer pprof.StopCPUProfile()
}
if err := readModel(); err != nil {
log.Fatal(err)
}
if err := glfw.Init(); err != nil {
log.Fatal(err)
}
defer glfw.Terminate()
glfw.OpenWindowHint(glfw.WindowNoResize, 1)
if err := glfw.OpenWindow(Width, Height, 0, 0, 0, 0, 16, 0, glfw.Windowed); err != nil {
log.Fatal(err)
return
}
defer glfw.CloseWindow()
glfw.SetSwapInterval(1)
glfw.SetWindowTitle(Title)
glfw.SetKeyCallback(onKey)
if err := gl.Init(); err != nil {
log.Fatal(err)
}
initScene()
defer destroyScene()
for glfw.WindowParam(glfw.Opened) == 1 {
applyMove()
drawScene()
glfw.SwapBuffers()
}
}
开发者ID:jayschwa,项目名称:groke,代码行数:47,代码来源:bspview.go
示例17: Init
func (o *OpenGl) Init() {
if err := glfw.Init(); err != nil {
fmt.Fprintf(os.Stderr, "glfw: %s\n", err)
return
}
defer glfw.Terminate()
if err := glfw.OpenWindow(o.width, o.height, 0, 0, 0, 0, 16, 0, glfw.Windowed); err != nil {
fmt.Fprintf(os.Stderr, "glfw: %s\n", err)
return
}
defer glfw.CloseWindow()
glfw.SetSwapInterval(1)
glfw.SetWindowTitle(o.title)
if err := gl.Init(); err != nil {
fmt.Fprintf(os.Stderr, "gl: %s\n", err)
}
glfw.SetKeyCallback(glfw.KeyHandler(o.keyboard))
glfw.SetMouseButtonCallback(glfw.MouseButtonHandler(o.mouseClick))
glfw.SetMousePosCallback(glfw.MousePosHandler(o.mouseMove))
glfw.SetMouseWheelCallback(glfw.MouseWheelHandler(o.mouseWheel))
if err := o.initScene(); err != nil {
fmt.Fprintf(os.Stderr, "init: %s\n", err)
return
}
for glfw.WindowParam(glfw.Opened) == 1 {
gl.Clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT)
if o.display3d != nil {
o.set3dView()
o.display3d()
}
if o.display2d != nil {
o.set2dView()
o.display2d()
}
glfw.SwapBuffers()
time.Sleep(20 * time.Millisecond)
//<-o.redisplay
}
}
开发者ID:knickers,项目名称:GOpenGL,代码行数:47,代码来源:GOpenGL.go
示例18: main
func main() {
// Setup the window
if err := glfw.Init(); err != nil {
fmt.Fprintf(os.Stderr, "glfw: %s\n", err)
return
}
// Close glfw at the end of main()
defer glfw.Terminate()
// Set window properties
glfw.OpenWindowHint(glfw.WindowNoResize, 0)
//glfw.OpenWindowHint(glfw.OpenGLForwardCompat, gl.TRUE)
glfw.OpenWindowHint(glfw.OpenGLDebugContext, gl.TRUE)
// Actually open the window
if err := glfw.OpenWindow(initial_width, initial_height, 0, 0, 0, 0, 16, 0, glfw.Windowed); err != nil {
fmt.Fprintf(os.Stderr, "glfw: %s\n", err)
return
}
// Close the window at the end of main()
defer glfw.CloseWindow()
// Only swap buffer once/ draw cycle (30 or 60 fps)
glfw.SetSwapInterval(1)
glfw.SetWindowTitle(Title)
// Apply those settings
if err := gl.Init(); err != nil {
fmt.Fprintf(os.Stderr, "gl: %s\n", err)
}
// While glfw.Opened is 1 (the window is open), keep swapping buffers
for glfw.WindowParam(glfw.Opened) == 1 {
glfw.SwapBuffers()
}
setCallbacks()
// Initialize the openGL settings
Initialize()
}
开发者ID:kelly-ry4n,项目名称:go-particles,代码行数:45,代码来源:render.go
示例19: draw
func draw() {
gl.Clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT)
gl.PushMatrix()
gl.Rotated(view_rotx, 1.0, 0.0, 0.0)
gl.Rotated(view_roty, 0.0, 1.0, 0.0)
gl.Rotated(view_rotz, 0.0, 0.0, 1.0)
gl.PushMatrix()
gl.Translated(-3.0, -2.0, 0.0)
gl.Rotated(angle, 0.0, 0.0, 1.0)
gl.CallList(gear1)
gl.PopMatrix()
gl.PushMatrix()
gl.Translated(3.1, -2.0, 0.0)
gl.Rotated(-2.0*angle-9.0, 0.0, 0.0, 1.0)
gl.CallList(gear2)
gl.PopMatrix()
gl.PushMatrix()
gl.Translated(-3.1, 4.2, 0.0)
gl.Rotated(-2.0*angle-25.0, 0.0, 0.0, 1.0)
gl.CallList(gear3)
gl.PopMatrix()
gl.PopMatrix()
glfw.SwapBuffers()
Frames++
{
t := glfw.Time()
if t-T0 >= 5 {
seconds := (t - T0)
fps := float64(Frames) / seconds
print(Frames, " frames in ", int(seconds), " seconds = ", int(fps), " FPS\n")
T0 = t
Frames = 0
}
}
}
开发者ID:nkostelnik,项目名称:gl,代码行数:43,代码来源:glfwgears.go
示例20: drawScene
func drawScene() {
gl.Clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT)
gl.LoadIdentity()
gl.Translatef(0, 0, -20+globalState.MousePos.Z*globalState.speed)
gl.Rotatef(globalState.Rot.X, 1, 0, 0)
gl.Rotatef(globalState.Rot.Y, 0, 1, 0)
gl.Rotatef(globalState.Rot.Z, 0, 0, 1)
if globalState.speed != 1 {
gl.Scalef(globalState.speed, globalState.speed, globalState.speed)
}
gl.Begin(gl.QUADS)
for i, _ := range mesh.Faces {
if colors, ok := faceColor[i]; ok {
gl.Color3f(colors[0], colors[1], colors[2])
} else {
faceColor[i] = make([]float32, 3)
faceColor[i][0] = rand.Float32()
faceColor[i][1] = rand.Float32()
faceColor[i][2] = rand.Float32()
gl.Color3f(faceColor[i][0], faceColor[i][1], faceColor[i][2])
}
face := &mesh.Faces[i]
for j, _ := range face.Vertices {
var v *wfobj.Vertex
if len(face.Normals) > 0 {
v = &face.Normals[j]
gl.Normal3f(v.X, v.Y, v.Z)
}
v = &face.Vertices[j]
gl.Vertex3f(v.X, v.Y, v.Z)
}
}
gl.End()
glfw.SwapBuffers()
}
开发者ID:andrebq,项目名称:wfobj,代码行数:42,代码来源:main.go
注:本文中的github.com/jteeuwen/glfw.SwapBuffers函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论