• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Golang gl.MatrixMode函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中github.com/go-gl/gl/v2/1/gl.MatrixMode函数的典型用法代码示例。如果您正苦于以下问题:Golang MatrixMode函数的具体用法?Golang MatrixMode怎么用?Golang MatrixMode使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了MatrixMode函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。

示例1: drawHud

func (ctx *DrawContext) drawHud(o *orrery.Orrery, frametime time.Duration) {
	txt, size, err := ctx.createHudTexture(o, frametime)
	if err != nil {
		log.Fatalf(`can't create texture from text surface: %s`, err)
	}
	defer gl.DeleteTextures(1, &txt)

	gl.MatrixMode(gl.PROJECTION)
	gl.PushMatrix()
	gl.LoadIdentity()
	gl.Ortho(0.0, float64(ctx.width), float64(ctx.height), 0.0, -1.0, 1.0)
	gl.MatrixMode(gl.MODELVIEW)
	gl.LoadIdentity()
	gl.Clear(gl.DEPTH_BUFFER_BIT)

	gl.BindTexture(gl.TEXTURE_2D, txt)
	gl.Enable(gl.TEXTURE_2D)
	defer gl.Disable(gl.TEXTURE_2D)

	gl.Color3f(1, 1, 1)
	gl.Begin(gl.QUADS)
	gl.TexCoord2f(0, 0)
	gl.Vertex2f(0.0, 0.0)
	gl.TexCoord2f(1, 0)
	gl.Vertex2f(float32(size[0]), 0.0)
	gl.TexCoord2f(1, 1)
	gl.Vertex2f(float32(size[0]), float32(size[1]))
	gl.TexCoord2f(0, 1)
	gl.Vertex2f(0.0, float32(size[1]))
	gl.End()

	gl.PopMatrix()
}
开发者ID:farhaven,项目名称:universe,代码行数:33,代码来源:drawing.go


示例2: initGraphics

func initGraphics() error {
	if err := gl.Init(); err != nil {
		return err
	}

	if err := glfw.Init(); err != nil {
		return err
	}

	glfw.WindowHint(glfw.Resizable, glfw.False)

	var err error
	window, err = glfw.CreateWindow(64*scaleRatio, 32*scaleRatio, "CHIP-8 Emulator", nil, nil)

	if err != nil {
		return err
	}

	window.MakeContextCurrent()

	gl.MatrixMode(gl.PROJECTION)
	gl.LoadIdentity()
	gl.Ortho(0, 64, 32, 0, 0, 1)
	gl.MatrixMode(gl.MODELVIEW)
	gl.LoadIdentity()

	clear()
	window.SwapBuffers()

	return nil
}
开发者ID:am4,项目名称:chip8,代码行数:31,代码来源:graphics.go


示例3: recalcOrthoBorders

func (cam *camera) recalcOrthoBorders() {
	const totalW = gameW + leftBorder + rightBorder
	const totalH = gameH + topBorder + bottomBorder
	const totalRatio = float64(totalW) / totalH

	windowRatio := float64(cam.WindowWidth) / float64(cam.WindowHeight)

	var horizontalBorder, verticalBorder float64

	if windowRatio > totalRatio {
		// window is wider than game => borders left and right
		horizontalBorder = (windowRatio*totalH - totalW) / 2
	} else {
		// window is higher than game => borders on top and bottom
		verticalBorder = (totalW/windowRatio - totalH) / 2
	}

	cam.Left = -leftBorder - horizontalBorder
	cam.Right = gameW + rightBorder + horizontalBorder
	cam.Top = -topBorder - verticalBorder
	cam.Bottom = gameH + bottomBorder + verticalBorder

	gl.MatrixMode(gl.PROJECTION)
	gl.LoadIdentity()
	gl.Ortho(cam.Left, cam.Right, cam.Bottom, cam.Top, -1, 1)
	gl.MatrixMode(gl.MODELVIEW)
}
开发者ID:gonutz,项目名称:settlers,代码行数:27,代码来源:camera.go


示例4: drawScene

func drawScene(w *glfw.Window) {
	width, height := w.GetFramebufferSize()
	ratio := float32(width) / float32(height)
	var x1, x2, y1, y2 float32
	if ratio > 1 {
		x1, x2, y1, y2 = -ratio, ratio, -1, 1
	} else {
		x1, x2, y1, y2 = -1, 1, -1/ratio, 1/ratio
	}

	gl.Viewport(0, 0, int32(width), int32(height))
	gl.Clear(gl.COLOR_BUFFER_BIT)

	// Applies subsequent matrix operations to the projection matrix stack
	gl.MatrixMode(gl.PROJECTION)

	gl.LoadIdentity()                                                   // replace the current matrix with the identity matrix
	gl.Ortho(float64(x1), float64(x2), float64(y1), float64(y2), 1, -1) // multiply the current matrix with an orthographic matrix

	// Applies subsequent matrix operations to the modelview matrix stack
	gl.MatrixMode(gl.MODELVIEW)

	gl.LoadIdentity()

	gl.LineWidth(1)
	gl.Begin(gl.LINE)   // delimit the vertices of a primitive or a group of like primitives
	gl.Color3f(0, 0, 0) // set the current color
	gl.Vertex3f(0, y1, 0)
	gl.Vertex3f(0, y2, 0)
	gl.Vertex3f(x1, 0, 0)
	gl.Vertex3f(x2, 0, 0)
	gl.End()

	gl.Rotatef(float32(glfw.GetTime()*50), 0, 0, 1) // multiply the current matrix by a rotation matrix

	s := float32(.95)

	gl.Begin(gl.TRIANGLES)
	gl.Color3f(1, 0, 0)  // set the current color
	gl.Vertex3f(0, s, 0) // specify a vertex
	gl.Color3f(0, 1, 0)
	gl.Vertex3f(s*.866, s*-0.5, 0)
	gl.Color3f(0, 0, 1)
	gl.Vertex3f(s*-.866, s*-0.5, 0)
	gl.End()

	gl.LineWidth(5)
	gl.Begin(gl.LINE_LOOP)
	for i := float64(0); i < 2*math.Pi; i += .05 {
		r, g, b := hsb2rgb(float32(i/(2*math.Pi)), 1, 1)
		gl.Color3f(r, g, b)
		gl.Vertex3f(s*float32(math.Sin(i)), s*float32(math.Cos(i)), 0)
	}
	gl.End()

}
开发者ID:rdterner,项目名称:gl,代码行数:56,代码来源:demo.go


示例5: reshape

/* new window size or exposure */
func reshape(width int32, height int32) {
	h := float64(height) / float64(width)
	gl.Viewport(0, 0, width, height)
	gl.MatrixMode(gl.PROJECTION)
	gl.LoadIdentity()
	gl.Frustum(-1.0, 1.0, -h, h, 5.0, 600.0)
	gl.MatrixMode(gl.MODELVIEW)
	gl.LoadIdentity()
	gl.Translatef(0.0, 0.0, -100)
}
开发者ID:pietdaniel,项目名称:gl_maze,代码行数:11,代码来源:main.go


示例6: onResize

// onResize sets up a simple 2d ortho context based on the window size
func onResize(window *glfw.Window, w, h int) {
	w, h = window.GetSize() // query window to get screen pixels
	width, height := window.GetFramebufferSize()
	gl.Viewport(0, 0, int32(width), int32(height))
	gl.MatrixMode(gl.PROJECTION)
	gl.LoadIdentity()
	gl.Ortho(0, float64(w), 0, float64(h), -1, 1)
	gl.MatrixMode(gl.MODELVIEW)
	gl.LoadIdentity()
	gl.ClearColor(1, 1, 1, 1)
}
开发者ID:jhautefeuille,项目名称:hellochipmunk,代码行数:12,代码来源:glfwtest.go


示例7: main

func main() {
	runtime.LockOSThread()

	if err := glfw.Init(); err != nil {
		panic(err)
	}
	defer glfw.Terminate()

	window, err := glfw.CreateWindow(800, 600, "fontstash example", nil, nil)
	if err != nil {
		panic(err)
	}

	window.MakeContextCurrent()
	glfw.SwapInterval(1)
	gl.Init()

	data, err := ioutil.ReadFile(filepath.Join("..", "ClearSans-Regular.ttf"))
	if err != nil {
		panic(err)
	}

	gl.Enable(gl.TEXTURE_2D)

	tmpBitmap := make([]byte, 512*512)
	cdata, err, _, tmpBitmap := truetype.BakeFontBitmap(data, 0, 32, tmpBitmap, 512, 512, 32, 96)
	var ftex uint32
	gl.GenTextures(1, &ftex)
	gl.BindTexture(gl.TEXTURE_2D, ftex)
	gl.TexParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR)
	gl.TexParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR)
	gl.TexImage2D(gl.TEXTURE_2D, 0, gl.ALPHA, 512, 512, 0,
		gl.ALPHA, gl.UNSIGNED_BYTE, unsafe.Pointer(&tmpBitmap[0]))

	gl.ClearColor(0.3, 0.3, 0.32, 1.)

	for !window.ShouldClose() {
		gl.Clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT)
		gl.MatrixMode(gl.PROJECTION)
		gl.LoadIdentity()
		gl.Ortho(0, 800, 600, 0, 0, 1)
		gl.MatrixMode(gl.MODELVIEW)
		gl.LoadIdentity()
		gl.Disable(gl.DEPTH_TEST)
		gl.Color4ub(255, 255, 255, 255)
		gl.Enable(gl.BLEND)
		gl.BlendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA)

		my_print(100, 100, "The quick brown fox jumps over the fence", ftex, cdata)

		window.SwapBuffers()
		glfw.PollEvents()
	}
}
开发者ID:shibukawa,项目名称:fontstash.go,代码行数:54,代码来源:truetype.go


示例8: setupScene

func setupScene(width int, height int) {
	gl.Disable(gl.DEPTH_TEST)
	gl.Disable(gl.LIGHTING)

	gl.ClearColor(0.5, 0.5, 0.5, 0.0)

	gl.MatrixMode(gl.PROJECTION)
	gl.LoadIdentity()
	gl.Ortho(0, float64(width), 0, float64(height), -1, 1)
	gl.MatrixMode(gl.MODELVIEW)
	gl.LoadIdentity()
}
开发者ID:nightowlware,项目名称:gooey,代码行数:12,代码来源:gooey.go


示例9: drawSlide

func drawSlide() {
	gl.Clear(gl.COLOR_BUFFER_BIT)

	gl.MatrixMode(gl.MODELVIEW)
	gl.LoadIdentity()
	gl.Translatef(0, 0, -3.0)

	gl.Begin(gl.QUADS)

	//top left
	gl.TexCoord2f(0, 0)
	gl.Vertex3f(-1, 1, 0)
	//top right
	gl.TexCoord2f(1, 0)
	gl.Vertex3f(1, 1, 0)

	//bottom right
	gl.TexCoord2f(1, 1)
	gl.Vertex3f(1, -1, 0)

	//bottom left
	gl.TexCoord2f(0, 1)
	gl.Vertex3f(-1, -1, 0)

	gl.End()

}
开发者ID:lordwelch,项目名称:PresentationApp,代码行数:27,代码来源:glfw.go


示例10: setupScene

func setupScene() {

	gl.ClearColor(0, 0, 0, 0)
	if texDel {
		gl.DeleteTextures(1, tex1)
	}
	tex1 = newTexture(*slides[selCell].getImage(monWidth, monHeight))

	gl.MatrixMode(gl.PROJECTION)
	gl.LoadIdentity()
	gl.Ortho(-1, 1, -1, 1, 1.0, 10.0)
	gl.MatrixMode(gl.MODELVIEW)
	gl.LoadIdentity()
	texDel = true

}
开发者ID:lordwelch,项目名称:PresentationApp,代码行数:16,代码来源:glfw.go


示例11: main

func main() {
	err := glfw.Init()
	if err != nil {
		panic(err)
	}
	defer glfw.Terminate()
	fp, err := os.Open("example.tmx")
	if err != nil {
		panic(err)
	}

	m, err := tmx.NewMap(fp)
	if err != nil {
		panic(err)
	}

	var monitor *glfw.Monitor
	window, err := glfw.CreateWindow(screenWidth, screenHeight, "Map Renderer", monitor, nil)
	if err != nil {
		panic(err)
	}

	window.MakeContextCurrent()

	if err := gl.Init(); err != nil {
		panic(err)
	}

	width, height := window.GetFramebufferSize()
	gl.Clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT)
	gl.ClearColor(1.0, 1.0, 1.0, 1.0)
	gl.Viewport(0, 0, int32(width), int32(height))
	gl.MatrixMode(gl.PROJECTION)
	gl.LoadIdentity()
	gl.Ortho(0, float64(width), float64(height), 0, -1, 1)
	gl.Enable(gl.BLEND)
	gl.BlendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA)
	canvas := newOpenGLCanvas(width, height, float32(width)/float32(screenWidth), float32(height)/float32(screenHeight))
	renderer := tmx.NewRenderer(*m, canvas)
	fps := 0
	startTime := time.Now().UnixNano()
	timer := tmx.CreateTimer()
	timer.Start()
	for !window.ShouldClose() {
		elapsed := float64(timer.GetElapsedTime()) / (1000 * 1000)
		renderer.Render(int64(math.Ceil(elapsed)))
		fps++
		if time.Now().UnixNano()-startTime > 1000*1000*1000 {
			log.Println(fps)
			startTime = time.Now().UnixNano()
			fps = 0
		}

		window.SwapBuffers()
		glfw.PollEvents()
		timer.UpdateTime()
	}
}
开发者ID:manyminds,项目名称:tmx,代码行数:58,代码来源:opengl.go


示例12: Update

func (c *Camera) Update() {
	// This has to be called in the GL thread
	vx := math.Cos(c.alpha)*10 + c.Pos.X
	vy := math.Sin(c.alpha)*10 + c.Pos.Y
	vz := math.Sin(c.theta)*10 + c.Pos.Z

	c.lookAt(vector.V3{vx, vy, vz})

	gl.MatrixMode(gl.PROJECTION)
	gl.LoadIdentity()
	gl.Frustum(-c.frustum.nearW, c.frustum.nearW, -c.frustum.nearH, c.frustum.nearH, c.frustum.zNear, c.frustum.zFar)
}
开发者ID:farhaven,项目名称:universe,代码行数:12,代码来源:camera.go


示例13: Reset

func (state *State) Reset(window *glfw.Window) {
	gl.ClearColor(1, 1, 1, 1)
	gl.Clear(gl.COLOR_BUFFER_BIT)
	gl.MatrixMode(gl.MODELVIEW)
	gl.LoadIdentity()

	gl.Disable(gl.DEPTH)
	gl.Enable(gl.FRAMEBUFFER_SRGB)

	width, height := window.GetSize()
	gl.Viewport(0, 0, int32(width), int32(height))
	gl.Ortho(0, float64(width), float64(height), 0, 30, -30)
}
开发者ID:egonelbre,项目名称:spector,代码行数:13,代码来源:ui.go


示例14: setupScene

func setupScene() {
	gl.Enable(gl.DEPTH_TEST)
	gl.Enable(gl.LIGHTING)

	gl.ClearColor(0.5, 0.5, 0.5, 0.0)
	gl.ClearDepth(1)
	gl.DepthFunc(gl.LEQUAL)

	ambient := []float32{0.5, 0.5, 0.5, 1}
	diffuse := []float32{1, 1, 1, 1}
	lightPosition := []float32{-5, 5, 10, 0}
	gl.Lightfv(gl.LIGHT0, gl.AMBIENT, &ambient[0])
	gl.Lightfv(gl.LIGHT0, gl.DIFFUSE, &diffuse[0])
	gl.Lightfv(gl.LIGHT0, gl.POSITION, &lightPosition[0])
	gl.Enable(gl.LIGHT0)

	gl.MatrixMode(gl.PROJECTION)
	gl.LoadIdentity()
	gl.Frustum(-1, 1, -1, 1, 1.0, 10.0)
	gl.MatrixMode(gl.MODELVIEW)
	gl.LoadIdentity()
}
开发者ID:donomii,项目名称:throfflib,代码行数:22,代码来源:throffgraphics.go


示例15: lookAt

func (c *Camera) lookAt(at vector.V3) {
	up := vector.V3{0, 0, 1}

	fw := at.Sub(c.Pos).Normalized()
	side := fw.Cross(up).Normalized()
	up = side.Cross(fw).Normalized()

	m := [16]float64{
		side.X, up.X, -fw.X, 0,
		side.Y, up.Y, -fw.Y, 0,
		side.Z, up.Z, -fw.Z, 0,
		0, 0, 0, 1,
	}

	gl.MatrixMode(gl.MODELVIEW)
	gl.LoadMatrixd(&m[0])
	gl.Translated(-c.Pos.X, -c.Pos.Y, -c.Pos.Z)

	// Update frustum
	nc := c.Pos.Sub(fw.Scaled(-c.frustum.zNear))
	fc := c.Pos.Sub(fw.Scaled(-c.frustum.zFar))

	planes := []vector.Plane{
		vector.Plane{fw, nc},            // NEARP
		vector.Plane{fw.Scaled(-1), fc}, // FARP
	}

	nh, nw := c.frustum.nearH, c.frustum.nearW

	// TOP
	aux := nc.Add(up.Scaled(nh)).Sub(c.Pos).Normalized()
	normal := aux.Cross(side)
	planes = append(planes, vector.Plane{normal, nc.Add(up.Scaled(nh))})

	// BOTTOM
	aux = nc.Sub(up.Scaled(nh)).Sub(c.Pos).Normalized()
	normal = side.Cross(aux)
	planes = append(planes, vector.Plane{normal, nc.Sub(up.Scaled(nh))})

	// LEFT
	aux = nc.Sub(side.Scaled(nw)).Sub(c.Pos).Normalized()
	normal = aux.Cross(up)
	planes = append(planes, vector.Plane{normal, nc.Sub(side.Scaled(nw))})

	// LEFT
	aux = nc.Add(side.Scaled(nw)).Sub(c.Pos).Normalized()
	normal = up.Cross(aux)
	planes = append(planes, vector.Plane{normal, nc.Add(side.Scaled(nw))})

	c.frustum.planes = planes
}
开发者ID:farhaven,项目名称:universe,代码行数:51,代码来源:camera.go


示例16: reshape

func reshape(window *glfw.Window, w, h int) {
	gl.ClearColor(1, 1, 1, 1)
	//fmt.Println(gl.GetString(gl.EXTENSIONS))
	gl.Viewport(0, 0, int32(w), int32(h))         /* Establish viewing area to cover entire window. */
	gl.MatrixMode(gl.PROJECTION)                  /* Start modifying the projection matrix. */
	gl.LoadIdentity()                             /* Reset project matrix. */
	gl.Ortho(0, float64(w), 0, float64(h), -1, 1) /* Map abstract coords directly to window coords. */
	gl.Scalef(1, -1, 1)                           /* Invert Y axis so increasing Y goes down. */
	gl.Translatef(0, float32(-h), 0)              /* Shift origin up to upper-left corner. */
	gl.Enable(gl.BLEND)
	gl.BlendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA)
	gl.Disable(gl.DEPTH_TEST)
	width, height = w, h
}
开发者ID:zzn01,项目名称:draw2d,代码行数:14,代码来源:postscriptgl.go


示例17: reshape

func reshape(w int, h int) {
	/* Because Gil specified "screen coordinates" (presumably with an
	   upper-left origin), this short bit of code sets up the coordinate
	   system to correspond to actual window coodrinates.  This code
	   wouldn't be required if you chose a (more typical in 3D) abstract
	   coordinate system. */

	gl.Viewport(0, 0, int32(w), int32(h))         /* Establish viewing area to cover entire window. */
	gl.MatrixMode(gl.PROJECTION)                  /* Start modifying the projection matrix. */
	gl.LoadIdentity()                             /* Reset project matrix. */
	gl.Ortho(0, float64(w), 0, float64(h), -1, 1) /* Map abstract coords directly to window coords. */
	gl.Scalef(1, -1, 1)                           /* Invert Y axis so increasing Y goes down. */
	gl.Translatef(0, float32(-h), 0)              /* Shift origin up to upper-left corner. */
}
开发者ID:XO-Lib,项目名称:GCXO,代码行数:14,代码来源:Window.go


示例18: drawScene

func drawScene() {
	gl.Clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT)

	gl.LineWidth(1)

	gl.MatrixMode(gl.MODELVIEW)
	gl.LoadIdentity()
	gl.Translatef(0, 0, 0.0)
	//gl.Rotatef(rotationX, 1, 0, 0)
	//gl.Rotatef(rotationY, 0, 1, 0)

	//rotationX += 0.5
	//rotationY += 0.5

	//gl.BindTexture(gl.TEXTURE_2D, texture)

}
开发者ID:nightowlware,项目名称:gooey,代码行数:17,代码来源:gooey.go


示例19: main

func main() {
	if err := glfw.Init(nopContextWatcher{}); err != nil {
		panic(err)
	}
	defer glfw.Terminate()

	glfw.WindowHint(glfw.Samples, 8) // Anti-aliasing.

	window, err := glfw.CreateWindow(400, 400, "", nil, nil)
	if err != nil {
		panic(err)
	}
	window.MakeContextCurrent()

	if err := gl.Init(); err != nil {
		panic(err)
	}

	glfw.SwapInterval(1) // Vsync.

	InitFont()
	defer DeinitFont()

	framebufferSizeCallback := func(w *glfw.Window, framebufferSize0, framebufferSize1 int) {
		gl.Viewport(0, 0, int32(framebufferSize0), int32(framebufferSize1))

		var windowSize [2]int
		windowSize[0], windowSize[1] = w.GetSize()

		// Update the projection matrix.
		gl.MatrixMode(gl.PROJECTION)
		gl.LoadIdentity()
		gl.Ortho(0, float64(windowSize[0]), float64(windowSize[1]), 0, -1, 1)
		gl.MatrixMode(gl.MODELVIEW)
	}
	{
		var framebufferSize [2]int
		framebufferSize[0], framebufferSize[1] = window.GetFramebufferSize()
		framebufferSizeCallback(window, framebufferSize[0], framebufferSize[1])
	}
	window.SetFramebufferSizeCallback(framebufferSizeCallback)

	var inputEventQueue []events.InputEvent
	mousePointer = &events.Pointer{VirtualCategory: events.POINTING}

	window.SetMouseMovementCallback(func(w *glfw.Window, xpos, ypos, xdelta, ydelta float64) {
		inputEvent := events.InputEvent{
			Pointer:    mousePointer,
			EventTypes: map[events.EventType]struct{}{events.SLIDER_EVENT: {}},
			InputId:    0,
			Buttons:    nil,
			Sliders:    []float64{xdelta, ydelta},
		}
		if w.GetInputMode(glfw.CursorMode) != glfw.CursorDisabled {
			inputEvent.EventTypes[events.AXIS_EVENT] = struct{}{}
			inputEvent.Axes = []float64{xpos, ypos}
		}
		inputEventQueue = events.EnqueueInputEvent(inputEventQueue, inputEvent)
	})

	window.SetMouseButtonCallback(func(w *glfw.Window, button glfw.MouseButton, action glfw.Action, mods glfw.ModifierKey) {
		inputEvent := events.InputEvent{
			Pointer:     mousePointer,
			EventTypes:  map[events.EventType]struct{}{events.BUTTON_EVENT: {}},
			InputId:     uint16(button),
			Buttons:     []bool{action != glfw.Release},
			Sliders:     nil,
			Axes:        nil,
			ModifierKey: uint8(mods),
		}
		inputEventQueue = events.EnqueueInputEvent(inputEventQueue, inputEvent)
	})

	go func() {
		<-time.After(5 * time.Second)
		log.Println("trigger!")
		boxUpdated = true

		glfw.PostEmptyEvent()
	}()

	gl.BlendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA) // For font.

	gl.ClearColor(247.0/255, 247.0/255, 247.0/255, 1)

	var spinner int

	var widgets []events.Widgeter

	widgets = append(widgets, NewButtonWidget(mgl64.Vec2{50, 200}, func() { fmt.Println("button triggered") }))

	for !window.ShouldClose() && glfw.Press != window.GetKey(glfw.KeyEscape) {
		glfw.WaitEvents()

		// Process Input.
		inputEventQueue = events.ProcessInputEventQueue(inputEventQueue, widgets[0])

		gl.Clear(gl.COLOR_BUFFER_BIT)
		gl.LoadIdentity()

//.........这里部分代码省略.........
开发者ID:rexposadas,项目名称:gx,代码行数:101,代码来源:main.go


示例20: main

func main() {
	if err := glfw.Init(); err != nil {
		panic(err)
	}
	defer glfw.Terminate()

	glfw.WindowHint(glfw.Samples, 8) // Anti-aliasing.

	window, err := glfw.CreateWindow(400, 400, "", nil, nil)
	if err != nil {
		panic(err)
	}
	window.MakeContextCurrent()

	if err := gl.Init(); err != nil {
		panic(err)
	}

	glfw.SwapInterval(1)
	//window.SetPos(50, 600)
	//window.SetPos(1600, 600)
	//window.SetPos(1275, 300)
	//window.SetPos(1200, 300)

	framebufferSizeCallback := func(w *glfw.Window, framebufferSize0, framebufferSize1 int) {
		gl.Viewport(0, 0, int32(framebufferSize0), int32(framebufferSize1))

		var windowSize [2]int
		windowSize[0], windowSize[1] = w.GetSize()

		// Update the projection matrix.
		gl.MatrixMode(gl.PROJECTION)
		gl.LoadIdentity()
		gl.Ortho(0, float64(windowSize[0]), float64(windowSize[1]), 0, -1, 1)
		gl.MatrixMode(gl.MODELVIEW)
	}
	{
		var framebufferSize [2]int
		framebufferSize[0], framebufferSize[1] = window.GetFramebufferSize()
		framebufferSizeCallback(window, framebufferSize[0], framebufferSize[1])
	}
	window.SetFramebufferSizeCallback(framebufferSizeCallback)

	go func() {
		<-time.After(5 * time.Second)
		log.Println("trigger!")
		boxUpdated = true

		glfw.PostEmptyEvent()
	}()

	//gl.ClearColor(0.8, 0.3, 0.01, 1)
	gl.ClearColor(247.0/255, 247.0/255, 247.0/255, 1)

	var spinner int

	for !window.ShouldClose() && glfw.Press != window.GetKey(glfw.KeyEscape) {
		glfw.WaitEvents()
		//glfw.PollEvents()

		gl.Clear(gl.COLOR_BUFFER_BIT)

		drawSpinner(spinner)
		spinner++

		drawBox()

		window.SwapBuffers()
		log.Println("swapped buffers")

		//runtime.Gosched()
	}
}
开发者ID:taliszhou,项目名称:Conception-go,代码行数:73,代码来源:main.go



注:本文中的github.com/go-gl/gl/v2/1/gl.MatrixMode函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang gl.Ortho函数代码示例发布时间:2022-05-23
下一篇:
Golang gl.LoadIdentity函数代码示例发布时间:2022-05-23
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap