예제 #1
0
파일: main.go 프로젝트: rexposadas/gx
func (w *MultitouchTestBoxWidget) Render() {
	colors := [...]mgl64.Vec3{
		{0 / 255.0, 140 / 255.0, 0 / 255.0},
		{0 / 255.0, 98 / 255.0, 140 / 255.0},
		{194 / 255.0, 74 / 255.0, 0 / 255.0},
		{89 / 255.0, 0 / 255.0, 140 / 255.0},
		{191 / 255.0, 150 / 255.0, 0 / 255.0},
		{140 / 255.0, 0 / 255.0, 0 / 255.0},
	}

	backgroundColor := colors[w.color]

	//borderColor := backgroundColor

	switch 1 {
	case 0:
		DrawBorderlessBox(w.pos, mgl64.Vec2{200, 200}, backgroundColor)
	case 1:
		gl.PushMatrix()
		gl.Translated(w.pos[0], w.pos[1], 0)
		gl.Color3dv(&backgroundColor[0])

		gl.EnableClientState(gl.VERTEX_ARRAY)
		gl.BindBuffer(gl.ARRAY_BUFFER, w.buffer)
		gl.VertexPointer(2, gl.FLOAT, 0, nil)

		gl.DrawArrays(gl.TRIANGLE_FAN, 0, 4)

		gl.PopMatrix()
	}
}
예제 #2
0
파일: renderer.go 프로젝트: fmd/gogol
func (r *Renderer) Render() {
	gl.EnableClientState(gl.VERTEX_ARRAY)

	rVbo := r.Vbos[0]
	gl.BindBuffer(gl.ARRAY_BUFFER, rVbo.Id)

	for _, c := range r.Layer.Flatten() {
		renderable := c.GetRenderable()
		transform := c.GetTransform()

		if renderable == nil || transform == nil || !c.Visible() {
			continue
		}

		if rVbo != renderable.VboPosition.Vbo {
			rVbo = renderable.VboPosition.Vbo
			gl.BindBuffer(gl.ARRAY_BUFFER, rVbo.Id)
		}

		gl.VertexPointer(ValsInVertex, gl.FLOAT, 0, nil)

		if transform.NeedsUpdate {
			transform.Update()
		}

		gl.LoadMatrixf(&(transform.Matrix[0]))
		gl.DrawArrays(gl.QUADS, int32(renderable.VboPosition.Index/ValsInVertex),
			int32(renderable.Length/ValsInVertex))
	}

	gl.DisableClientState(gl.VERTEX_ARRAY)
}
예제 #3
0
파일: renderer.go 프로젝트: fmd/bronson
func (r *Renderer) Render() {
	gl.EnableClientState(gl.VERTEX_ARRAY)

	for _, g := range r.GameObjects {
		gl.BindBuffer(gl.ARRAY_BUFFER, g.VboPosition.Vbo.Id)
		gl.VertexPointer(2, gl.FLOAT, 0, nil)
		gl.DrawArrays(gl.QUADS, 0, int32(4))
	}

	gl.DisableClientState(gl.VERTEX_ARRAY)
}
예제 #4
0
func onDisplay(program uint32, coords uint32) {
	gl.ClearColor(1.0, 1.0, 1.0, 1.0)
	gl.Clear(gl.COLOR_BUFFER_BIT)

	gl.UseProgram(program)
	gl.EnableVertexAttribArray(coords)
	triangleVertices := []float32{
		0.0, 0.8,
		-0.8, -0.8,
		0.8, -0.8}
	gl.VertexAttribPointer(coords, 2, gl.FLOAT, false, 0, gl.Ptr(triangleVertices))
	gl.DrawArrays(gl.TRIANGLES, 0, 3)
	gl.DisableVertexAttribArray(coords)

}
예제 #5
0
파일: gc.go 프로젝트: stanim/draw2d
func (p *Painter) Flush() {
	if len(p.vertices) != 0 {
		gl.EnableClientState(gl.COLOR_ARRAY)
		gl.EnableClientState(gl.VERTEX_ARRAY)
		gl.ColorPointer(4, gl.UNSIGNED_BYTE, 0, gl.Ptr(p.colors))
		gl.VertexPointer(2, gl.INT, 0, gl.Ptr(p.vertices))

		// draw lines
		gl.DrawArrays(gl.LINES, 0, int32(len(p.vertices)/2))
		gl.DisableClientState(gl.VERTEX_ARRAY)
		gl.DisableClientState(gl.COLOR_ARRAY)
		p.vertices = p.vertices[0:0]
		p.colors = p.colors[0:0]
	}
}
예제 #6
0
func onDisplay(program uint32, coords uint32) {
	gl.ClearColor(1.0, 1.0, 1.0, 1.0)
	gl.Clear(gl.COLOR_BUFFER_BIT)

	gl.Enable(gl.BLEND)
	gl.BlendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA)

	gl.UseProgram(program)
	gl.EnableVertexAttribArray(coords)

	gl.VertexAttribPointer(coords, 2, gl.FLOAT, false, 0, nil)
	gl.DrawArrays(gl.TRIANGLES, 0, 3)
	gl.DisableVertexAttribArray(coords)

}
예제 #7
0
func onDisplay(program uint32) {
	coords := uint32(attributeCoord2d)
	vcolor := uint32(attributeVColor)

	gl.ClearColor(1.0, 1.0, 1.0, 1.0)
	gl.Clear(gl.COLOR_BUFFER_BIT)

	gl.UseProgram(program)
	gl.Enable(gl.BLEND)
	gl.BlendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA)
	gl.Uniform1f(uniformFade, curFade)

	gl.EnableVertexAttribArray(coords)
	gl.EnableVertexAttribArray(vcolor)
	gl.BindBuffer(gl.ARRAY_BUFFER, vboTriangle)
	gl.VertexAttribPointer(coords, 2, gl.FLOAT, false, 5*floatSize, nil)
	gl.VertexAttribPointer(vcolor, 3, gl.FLOAT, false, 5*floatSize, gl.PtrOffset(2*floatSize))

	gl.DrawArrays(gl.TRIANGLES, 0, 3)

	gl.DisableVertexAttribArray(vcolor)
	gl.DisableVertexAttribArray(coords)
}
예제 #8
0
파일: gl_opengl.go 프로젝트: tanema/amore
// DrawArrays renders geometric primitives from the bound data.
//
// http://www.khronos.org/opengles/sdk/docs/man3/html/glDrawArrays.xhtml
func DrawArrays(mode Enum, first, count int) {
	gl.DrawArrays(uint32(mode), int32(first), int32(count))
}
예제 #9
0
파일: gl_gl2.go 프로젝트: EngoEngine/gl
func (c *Context) DrawArrays(mode, first, count int) {
	gl.DrawArrays(uint32(mode), int32(first), int32(count))
}
예제 #10
0
func (v *Video) Render() {
	for running {
		select {
		case buf := <-v.videoTick:
			gl.Clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT)

			gl.UseProgram(v.prog)

			gl.ActiveTexture(gl.TEXTURE0)
			gl.BindTexture(v.texture, gl.TEXTURE_2D)

			gl.TexImage2D(gl.TEXTURE_2D, 0, 3, 240, 224, 0, gl.RGBA,
				gl.UNSIGNED_INT_8_8_8_8, gl.Ptr(buf))

			gl.DrawArrays(gl.TRIANGLES, 0, 6)

			if v.screen != nil {
				sdl.GL_SwapBuffers()
				v.fpsmanager.FramerateDelay()
			}
		case ev := <-sdl.Events:
			switch e := ev.(type) {
			case sdl.ResizeEvent:
				v.ResizeEvent(e.W, e.H)
			case sdl.QuitEvent:
				os.Exit(0)
			case sdl.KeyboardEvent:
				switch e.Keysym.Sym {
				case sdl.K_ESCAPE:
					running = false
				case sdl.K_r:
					// Trigger reset interrupt
					if e.Type == sdl.KEYDOWN {
						// cpu.RequestInterrupt(InterruptReset)
					}
				case sdl.K_l:
					if e.Type == sdl.KEYDOWN {
						nes.LoadGameState()
					}
				case sdl.K_s:
					if e.Type == sdl.KEYDOWN {
						nes.SaveGameState()
					}
				case sdl.K_i:
					if e.Type == sdl.KEYDOWN {
						nes.AudioEnabled = !nes.AudioEnabled
					}
				case sdl.K_p:
					if e.Type == sdl.KEYDOWN {
						nes.TogglePause()
					}
				case sdl.K_d:
					if e.Type == sdl.KEYDOWN {
						jsHandler.ReloadFile(debugfile)
					}
				case sdl.K_m:
					if e.Type == sdl.KEYDOWN {
						nes.Handler.Handle("debug-mode")
					}
				case sdl.K_BACKSLASH:
					if e.Type == sdl.KEYDOWN {
						nes.Pause()
						nes.StepFrame()
					}
				case sdl.K_1:
					if e.Type == sdl.KEYDOWN {
						v.ResizeEvent(256, 240)
					}
				case sdl.K_2:
					if e.Type == sdl.KEYDOWN {
						v.ResizeEvent(512, 480)
					}
				case sdl.K_3:
					if e.Type == sdl.KEYDOWN {
						v.ResizeEvent(768, 720)
					}
				case sdl.K_4:
					if e.Type == sdl.KEYDOWN {
						v.ResizeEvent(1024, 960)
					}
				}

				switch e.Type {
				case sdl.KEYDOWN:
					nes.Pads[0].KeyDown(e, 0)
				case sdl.KEYUP:
					nes.Pads[0].KeyUp(e, 0)
				}
			}
		}
	}
}
예제 #11
0
파일: gg.go 프로젝트: dmac/gg
func (*backend) DrawArrays(mode gg.Enum, first, count int) {
	gl.DrawArrays(uint32(mode), int32(first), int32(count))
}