本文整理汇总了Golang中github.com/remogatto/opengles2.Clear函数的典型用法代码示例。如果您正苦于以下问题:Golang Clear函数的具体用法?Golang Clear怎么用?Golang Clear使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Clear函数的16个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: TestRotatedBox
func (t *TestSuite) TestRotatedBox() {
filename := "expected_box_rotated_20.png"
t.rlControl.drawFunc <- func() {
w, h := t.renderState.window.GetSize()
world := newWorld(w, h)
// Create a 100x100 pixel² box
box := shapes.NewBox(t.renderState.boxProgram, 100, 100)
box.AttachToWorld(world)
// Place the box at the center of the screen
box.MoveTo(float32(w/2), 0)
// Rotate the box 20 degrees
box.Rotate(20.0)
gl.Clear(gl.COLOR_BUFFER_BIT)
box.Draw()
t.testDraw <- testlib.Screenshot(t.renderState.window)
t.renderState.window.SwapBuffers()
}
distance, exp, act, err := testlib.TestImage(filename, <-t.testDraw, imagetest.Center)
if err != nil {
panic(err)
}
t.True(distance < distanceThreshold, distanceError(distance, filename))
if t.Failed() {
saveExpAct(t.outputPath, "failed_"+filename, exp, act)
}
}
开发者ID:remogatto,项目名称:shapes,代码行数:26,代码来源:tests.go
示例2: newGameState
func newGameState(window mandala.Window) *gameState {
s := new(gameState)
s.window = window
s.window.MakeContextCurrent()
w, h := window.GetSize()
s.world = newWorld(w, h)
// Create the building reading it from a string
rand.Seed(int64(time.Now().Nanosecond()))
// Uncomment the following lines to generate the world
// starting from a string (defined in world.go)
// s.world.createFromString(pyramid)
// s.world.setGround(newGround(0, float32(10), float32(w), float32(10)))
s.world.createFromSvg("raw/world.svg")
gl.ClearColor(0.0, 0.0, 0.0, 1.0)
gl.Clear(gl.COLOR_BUFFER_BIT)
return s
}
开发者ID:TimothyKlim,项目名称:mandala-examples,代码行数:26,代码来源:game.go
示例3: TestScaledBox
func (t *TestSuite) TestScaledBox() {
filename := "expected_box_scaled.png"
t.rlControl.drawFunc <- func() {
w, h := t.renderState.window.GetSize()
world := newWorld(w, h)
box := shapes.NewBox(t.renderState.boxProgram, 100, 100)
// Color is yellow
box.SetColor(color.RGBA{0, 0, 255, 255})
box.AttachToWorld(world)
box.MoveTo(float32(w/2), 0)
box.Scale(1.5, 1.5)
gl.Clear(gl.COLOR_BUFFER_BIT)
box.Draw()
t.testDraw <- testlib.Screenshot(t.renderState.window)
t.renderState.window.SwapBuffers()
}
distance, exp, act, err := testlib.TestImage(filename, <-t.testDraw, imagetest.Center)
if err != nil {
panic(err)
}
t.True(distance < distanceThreshold, distanceError(distance, filename))
if t.Failed() {
saveExpAct(t.outputPath, "failed_"+filename, exp, act)
}
}
开发者ID:remogatto,项目名称:shapes,代码行数:25,代码来源:tests.go
示例4: draw
func draw() {
// Draw
gl.ClearColor(0.9, 0.85, 0.46, 0.0)
gl.Clear(gl.COLOR_BUFFER_BIT)
w := g.world
w.background.Draw()
}
开发者ID:remogatto,项目名称:mozaik,代码行数:7,代码来源:game.go
示例5: NewGameState
// NewGameState creates a new game state. It needs a window onto which
// render the scene.
func NewGameState(window mandala.Window) *GameState {
s := new(GameState)
s.window = window
s.window.MakeContextCurrent()
w, h := window.GetSize()
s.World = NewWorld(w, h)
s.Fps = DefaultFps
// Uncomment the following lines to generate the world
// starting from a string (defined in world.go)
// s.World.CreateFromString(pyramid)
// s.World.setGround(newGround(s.World, 0, float32(10), float32(w), float32(10)))
s.World.CreateFromSvg("raw/world.svg")
gl.Enable(gl.BLEND)
gl.BlendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA)
gl.ClearColor(0.0, 0.0, 0.0, 1.0)
gl.Clear(gl.COLOR_BUFFER_BIT)
return s
}
开发者ID:remogatto,项目名称:mandala-examples,代码行数:30,代码来源:gamestate.go
示例6: draw
func (renderState *renderState) draw() {
gl.Clear(gl.COLOR_BUFFER_BIT)
gl.VertexAttribPointer(attrPos, 4, gl.FLOAT, false, 6*4, &vertices[0])
gl.VertexAttribPointer(attrTexIn, 2, gl.FLOAT, false, 6*4, &vertices[4])
gl.ActiveTexture(gl.TEXTURE0)
gl.BindTexture(gl.TEXTURE_2D, textureBuffer)
gl.Uniform1i(int32(unifTexture), 0)
gl.DrawArrays(gl.TRIANGLE_FAN, 0, 4)
gl.Flush()
gl.Finish()
}
开发者ID:leonardyp,项目名称:mandala,代码行数:14,代码来源:testlib.go
示例7: draw
func (s *gameState) draw() {
gl.Clear(gl.COLOR_BUFFER_BIT)
s.world.space.Step(vect.Float(1 / float32(FramesPerSecond)))
for i := 0; i < len(s.world.boxes); i++ {
box := s.world.boxes[i]
if box.inViewport() {
box.draw()
} else {
s.world.removeBox(box, i)
i--
}
}
s.world.ground.draw()
}
开发者ID:TimothyKlim,项目名称:mandala-examples,代码行数:17,代码来源:game.go
示例8: Draw
func (s *GameState) Draw() {
gl.Clear(gl.COLOR_BUFFER_BIT)
s.World.space.Step(vect.Float(1 / float32(s.Fps)))
for i := 0; i < len(s.World.boxes); i++ {
box := s.World.boxes[i]
if box.inViewport() {
box.draw()
} else {
s.World.removeBox(box, i)
i--
}
}
s.World.ground.draw()
s.printFPS(float32(s.World.width/2), float32(s.World.height)-25)
}
开发者ID:remogatto,项目名称:mandala-examples,代码行数:19,代码来源:gamestate.go
示例9: TestGroup
func (t *TestSuite) TestGroup() {
filename := "expected_group.png"
t.rlControl.drawFunc <- func() {
w, h := t.renderState.window.GetSize()
world := newWorld(w, h)
// Create first group, 2 small boxes
group1 := shapes.NewGroup()
b1 := shapes.NewBox(t.renderState.boxProgram, 20, 20)
b1.MoveTo(30, 40)
b2 := shapes.NewBox(t.renderState.boxProgram, 50, 50)
b2.MoveTo(45, -25)
b2.Rotate(20.0)
group1.Append(b1)
group1.Append(b2)
// Create the main group
group := shapes.NewGroup()
group.Append(group1)
group.Append(shapes.NewBox(t.renderState.boxProgram, 100, 100))
// Get the second element of the group
b3 := group.GetAt(1)
b3.MoveTo(float32(w/2), 0)
group.AttachToWorld(world)
gl.Clear(gl.COLOR_BUFFER_BIT)
group.Draw()
t.testDraw <- testlib.Screenshot(t.renderState.window)
t.renderState.window.SwapBuffers()
}
distance, exp, act, err := testlib.TestImage(filename, <-t.testDraw, imagetest.Center)
if err != nil {
panic(err)
}
t.True(distance < distanceThreshold, distanceError(distance, filename))
if t.Failed() {
saveExpAct(t.outputPath, "failed_"+filename, exp, act)
}
}
开发者ID:remogatto,项目名称:shapes,代码行数:41,代码来源:tests.go
示例10: TestPartialTextureRotatedBox
func (t *TestSuite) TestPartialTextureRotatedBox() {
filename := "expected_box_partial_texture_rotated_20.png"
t.rlControl.drawFunc <- func() {
w, h := t.renderState.window.GetSize()
world := newWorld(w, h)
// Create a box
box := shapes.NewBox(t.renderState.boxProgram, 100, 100)
box.AttachToWorld(world)
gl.Clear(gl.COLOR_BUFFER_BIT)
box.MoveTo(float32(w/2), 0)
// Add an image as a texture
gopherTexture := world.addImageAsTexture(texFilename)
texCoords := []float32{
0, 0,
0.5, 0,
0, 0.5,
0.5, 0.5,
}
box.SetTexture(gopherTexture, texCoords)
box.Rotate(20.0)
box.Draw()
t.testDraw <- testlib.Screenshot(t.renderState.window)
t.renderState.window.SwapBuffers()
}
distance, exp, act, err := testlib.TestImage(filename, <-t.testDraw, imagetest.Center)
if err != nil {
panic(err)
}
t.True(distance < texDistThreshold, distanceError(distance, filename))
if t.Failed() {
saveExpAct(t.outputPath, "failed_"+filename, exp, act)
}
}
开发者ID:remogatto,项目名称:shapes,代码行数:38,代码来源:tests.go
示例11: TestTranslatedBox
func (t *TestSuite) TestTranslatedBox() {
filename := "expected_box_translated_10_10.png"
t.rlControl.drawFunc <- func() {
w, h := t.renderState.window.GetSize()
world := newWorld(w, h)
// Place a box on the center of the window
box := shapes.NewBox(t.renderState.boxProgram, 100, 100)
box.AttachToWorld(world)
box.MoveTo(111, 0)
gl.Clear(gl.COLOR_BUFFER_BIT)
box.Draw()
t.testDraw <- testlib.Screenshot(t.renderState.window)
t.renderState.window.SwapBuffers()
}
distance, exp, act, err := testlib.TestImage(filename, <-t.testDraw, imagetest.Center)
if err != nil {
panic(err)
}
t.True(distance < distanceThreshold, distanceError(distance, filename))
if t.Failed() {
saveExpAct(t.outputPath, "failed_"+filename, exp, act)
}
}
开发者ID:remogatto,项目名称:shapes,代码行数:23,代码来源:tests.go
示例12: TestRotate
func (t *TestSuite) TestRotate() {
filename := "expected_hello_world_rotated.png"
t.rlControl.drawFunc <- func() {
w, h := t.renderState.window.GetSize()
world := newWorld(w, h)
// Render an "Hello World" string
text, err := world.font.Printf("%s", "Hello World!")
if err != nil {
panic(err)
}
text.AttachToWorld(world)
text.MoveTo(float32(world.width/2)+5, -5.0)
text.Rotate(45)
gl.Enable(gl.BLEND)
gl.BlendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA)
gl.Clear(gl.COLOR_BUFFER_BIT)
text.Draw()
t.testDraw <- testlib.Screenshot(t.renderState.window)
t.renderState.window.SwapBuffers()
}
distance, exp, act, err := testlib.TestImage(filename, <-t.testDraw, imagetest.Center)
if err != nil {
panic(err)
}
t.True(distance < distanceThreshold, distanceError(distance, filename))
if t.Failed() {
saveExpAct(t.outputPath, "failed_"+filename, exp, act)
}
}
开发者ID:remogatto,项目名称:gltext,代码行数:37,代码来源:tests.go
示例13: TestSegment
func (t *TestSuite) TestSegment() {
filename := "expected_line.png"
t.rlControl.drawFunc <- func() {
w, h := t.renderState.window.GetSize()
world := newWorld(w, h)
segment := shapes.NewSegment(t.renderState.segmentProgram, 81.5, -40, 238.5, 44)
// Color is yellow
segment.SetColor(color.RGBA{255, 0, 0, 255})
segment.AttachToWorld(world)
gl.Clear(gl.COLOR_BUFFER_BIT)
segment.Draw()
t.testDraw <- testlib.Screenshot(t.renderState.window)
t.renderState.window.SwapBuffers()
}
distance, exp, act, err := testlib.TestImage(filename, <-t.testDraw, imagetest.Center)
if err != nil {
panic(err)
}
t.True(distance < 0.0009, distanceError(distance, filename))
if t.Failed() {
saveExpAct(t.outputPath, "failed_"+filename, exp, act)
}
}
开发者ID:remogatto,项目名称:shapes,代码行数:24,代码来源:tests.go
示例14: draw
func draw() {
gl.ClearColor(1.0, 0.0, 0.0, 1.0)
gl.Clear(gl.COLOR_BUFFER_BIT)
}
开发者ID:remogatto,项目名称:mandala-examples,代码行数:4,代码来源:game.go
示例15: Draw
func (w *World) Draw() {
gl.Clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT)
for _, obj := range w.objects {
obj.Draw()
}
}
开发者ID:remogatto,项目名称:mandala-examples,代码行数:6,代码来源:world.go
示例16: draw
func (renderState *renderState) draw() {
gl.Clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT)
}
开发者ID:remogatto,项目名称:mozaik,代码行数:3,代码来源:testlib.go
注:本文中的github.com/remogatto/opengles2.Clear函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论