update gl sample
This commit is contained in:
parent
8bc0343156
commit
a68b429f0f
1 changed files with 2 additions and 29 deletions
|
@ -24,8 +24,6 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
"gl"
|
"gl"
|
||||||
"glut"
|
"glut"
|
||||||
"image"
|
|
||||||
"draw2d.googlecode.com/hg/draw2d"
|
|
||||||
"draw2d.googlecode.com/hg/draw2dgl"
|
"draw2d.googlecode.com/hg/draw2dgl"
|
||||||
"draw2d.googlecode.com/hg/postscript"
|
"draw2d.googlecode.com/hg/postscript"
|
||||||
"log"
|
"log"
|
||||||
|
@ -34,30 +32,6 @@ import (
|
||||||
|
|
||||||
var postscriptContent string
|
var postscriptContent string
|
||||||
|
|
||||||
func TestDrawCubicCurve(gc draw2d.GraphicContext) {
|
|
||||||
// draw a cubic curve
|
|
||||||
x, y := 25.6, 128.0
|
|
||||||
x1, y1 := 102.4, 230.4
|
|
||||||
x2, y2 := 153.6, 25.6
|
|
||||||
x3, y3 := 230.4, 128.0
|
|
||||||
|
|
||||||
gc.SetStrokeColor(image.NRGBAColor{0, 0, 0, 0xff})
|
|
||||||
gc.SetLineWidth(10)
|
|
||||||
gc.MoveTo(x, y)
|
|
||||||
gc.CubicCurveTo(x1, y1, x2, y2, x3, y3)
|
|
||||||
gc.Stroke()
|
|
||||||
|
|
||||||
gc.SetStrokeColor(image.NRGBAColor{0xFF, 0x33, 0x33, 0x99})
|
|
||||||
|
|
||||||
gc.SetLineWidth(6)
|
|
||||||
// draw segment of curve
|
|
||||||
gc.MoveTo(x, y)
|
|
||||||
gc.LineTo(x1, y1)
|
|
||||||
gc.MoveTo(x2, y2)
|
|
||||||
gc.LineTo(x3, y3)
|
|
||||||
gc.Stroke()
|
|
||||||
}
|
|
||||||
|
|
||||||
var (
|
var (
|
||||||
width, height int
|
width, height int
|
||||||
rotate int
|
rotate int
|
||||||
|
@ -79,12 +53,11 @@ func reshape(w, h int) {
|
||||||
gl.Translatef(0, float32(-h), 0) /* Shift origin up to upper-left corner. */
|
gl.Translatef(0, float32(-h), 0) /* Shift origin up to upper-left corner. */
|
||||||
gl.Enable(gl.BLEND)
|
gl.Enable(gl.BLEND)
|
||||||
gl.BlendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA)
|
gl.BlendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA)
|
||||||
|
gl.Disable(gl.DEPTH_TEST);
|
||||||
width, height = w, h
|
width, height = w, h
|
||||||
}
|
}
|
||||||
|
|
||||||
func display() {
|
func display() {
|
||||||
|
|
||||||
gl.Clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT)
|
gl.Clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT)
|
||||||
gl.LineWidth(1)
|
gl.LineWidth(1)
|
||||||
gc := draw2dgl.NewGraphicContext(width, height)
|
gc := draw2dgl.NewGraphicContext(width, height)
|
||||||
|
@ -115,7 +88,7 @@ func main() {
|
||||||
postscriptContent = string(bytes)
|
postscriptContent = string(bytes)
|
||||||
glut.Init()
|
glut.Init()
|
||||||
glut.InitWindowSize(800, 800)
|
glut.InitWindowSize(800, 800)
|
||||||
glut.CreateWindow("single triangle")
|
glut.CreateWindow("Show Tiger in Opengl")
|
||||||
|
|
||||||
glut.DisplayFunc(display)
|
glut.DisplayFunc(display)
|
||||||
glut.ReshapeFunc(reshape)
|
glut.ReshapeFunc(reshape)
|
||||||
|
|
Loading…
Reference in a new issue