mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2025-01-23 17:32:02 +01:00
go fmt
This commit is contained in:
parent
e91ab21d8d
commit
6ed9102f01
@ -1,9 +1,9 @@
|
|||||||
package ebiten
|
package ebiten
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"time"
|
|
||||||
"github.com/hajimehoshi/go-ebiten/graphics"
|
"github.com/hajimehoshi/go-ebiten/graphics"
|
||||||
"github.com/hajimehoshi/go-ebiten/graphics/opengl"
|
"github.com/hajimehoshi/go-ebiten/graphics/opengl"
|
||||||
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Game interface {
|
type Game interface {
|
||||||
@ -26,7 +26,7 @@ func OpenGLRun(game Game, ui UI) {
|
|||||||
func(g graphics.GraphicsContext, offscreen graphics.TextureID) {
|
func(g graphics.GraphicsContext, offscreen graphics.TextureID) {
|
||||||
ticket := <-ch
|
ticket := <-ch
|
||||||
game.Draw(g, offscreen)
|
game.Draw(g, offscreen)
|
||||||
ch<- ticket
|
ch <- ticket
|
||||||
})
|
})
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
@ -36,11 +36,11 @@ func OpenGLRun(game Game, ui UI) {
|
|||||||
<-tick
|
<-tick
|
||||||
ticket := <-ch
|
ticket := <-ch
|
||||||
game.Update()
|
game.Update()
|
||||||
ch<- ticket
|
ch <- ticket
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
game.Init(device.TextureFactory())
|
game.Init(device.TextureFactory())
|
||||||
ch<- true
|
ch <- true
|
||||||
ui.Run(device)
|
ui.Run(device)
|
||||||
}
|
}
|
||||||
|
@ -15,17 +15,17 @@ package main
|
|||||||
//
|
//
|
||||||
import "C"
|
import "C"
|
||||||
import (
|
import (
|
||||||
|
"github.com/hajimehoshi/go-ebiten"
|
||||||
|
"github.com/hajimehoshi/go-ebiten/graphics"
|
||||||
"image"
|
"image"
|
||||||
"image/color"
|
"image/color"
|
||||||
_ "image/png"
|
_ "image/png"
|
||||||
"os"
|
"os"
|
||||||
"runtime"
|
"runtime"
|
||||||
"unsafe"
|
"unsafe"
|
||||||
"github.com/hajimehoshi/go-ebiten"
|
|
||||||
"github.com/hajimehoshi/go-ebiten/graphics"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type GlutUI struct{
|
type GlutUI struct {
|
||||||
screenWidth int
|
screenWidth int
|
||||||
screenHeight int
|
screenHeight int
|
||||||
screenScale int
|
screenScale int
|
||||||
@ -62,10 +62,10 @@ func (ui *GlutUI) Init() {
|
|||||||
ui.screenScale = 2
|
ui.screenScale = 2
|
||||||
|
|
||||||
C.glutInit(&cargc, &cargs[0])
|
C.glutInit(&cargc, &cargs[0])
|
||||||
C.glutInitDisplayMode(C.GLUT_RGBA);
|
C.glutInitDisplayMode(C.GLUT_RGBA)
|
||||||
C.glutInitWindowSize(
|
C.glutInitWindowSize(
|
||||||
C.int(ui.screenWidth * ui.screenScale),
|
C.int(ui.screenWidth*ui.screenScale),
|
||||||
C.int(ui.screenHeight * ui.screenScale))
|
C.int(ui.screenHeight*ui.screenScale))
|
||||||
|
|
||||||
title := C.CString("Ebiten Demo")
|
title := C.CString("Ebiten Demo")
|
||||||
defer C.free(unsafe.Pointer(title))
|
defer C.free(unsafe.Pointer(title))
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
package graphics_test
|
package graphics_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"testing"
|
|
||||||
. "."
|
. "."
|
||||||
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
func setElements(matrix *AffineMatrix, elements [][]float64) {
|
func setElements(matrix *AffineMatrix, elements [][]float64) {
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
package graphics_test
|
package graphics_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"testing"
|
|
||||||
. "."
|
. "."
|
||||||
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestGeometryMatrixElements(t *testing.T) {
|
func TestGeometryMatrixElements(t *testing.T) {
|
||||||
|
@ -7,10 +7,10 @@ package opengl
|
|||||||
import "C"
|
import "C"
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"github.com/hajimehoshi/go-ebiten/graphics"
|
||||||
"image"
|
"image"
|
||||||
"image/color"
|
"image/color"
|
||||||
"unsafe"
|
"unsafe"
|
||||||
"github.com/hajimehoshi/go-ebiten/graphics"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type GraphicsContext struct {
|
type GraphicsContext struct {
|
||||||
@ -53,10 +53,10 @@ func (context *GraphicsContext) Fill(clr color.Color) {
|
|||||||
r, g, b, a := clr.RGBA()
|
r, g, b, a := clr.RGBA()
|
||||||
max := 65535.0
|
max := 65535.0
|
||||||
C.glClearColor(
|
C.glClearColor(
|
||||||
C.GLclampf(float64(r) / max),
|
C.GLclampf(float64(r)/max),
|
||||||
C.GLclampf(float64(g) / max),
|
C.GLclampf(float64(g)/max),
|
||||||
C.GLclampf(float64(b) / max),
|
C.GLclampf(float64(b)/max),
|
||||||
C.GLclampf(float64(a) / max))
|
C.GLclampf(float64(a)/max))
|
||||||
C.glClear(C.GL_COLOR_BUFFER_BIT)
|
C.glClear(C.GL_COLOR_BUFFER_BIT)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -88,9 +88,9 @@ func (context *GraphicsContext) DrawTexture(
|
|||||||
}
|
}
|
||||||
|
|
||||||
tu1 := float32(srcX) / float32(texture.textureWidth)
|
tu1 := float32(srcX) / float32(texture.textureWidth)
|
||||||
tu2 := float32(srcX + srcWidth) / float32(texture.textureWidth)
|
tu2 := float32(srcX+srcWidth) / float32(texture.textureWidth)
|
||||||
tv1 := float32(srcY) / float32(texture.textureHeight)
|
tv1 := float32(srcY) / float32(texture.textureHeight)
|
||||||
tv2 := float32(srcY + srcHeight) / float32(texture.textureHeight)
|
tv2 := float32(srcY+srcHeight) / float32(texture.textureHeight)
|
||||||
texCoord := [...]float32{
|
texCoord := [...]float32{
|
||||||
tu1, tv1,
|
tu1, tv1,
|
||||||
tu2, tv1,
|
tu2, tv1,
|
||||||
@ -138,8 +138,7 @@ func (context *GraphicsContext) setOffscreenFramebuffer(framebuffer C.GLuint,
|
|||||||
C.glFlush()
|
C.glFlush()
|
||||||
|
|
||||||
C.glBindFramebuffer(C.GL_FRAMEBUFFER, framebuffer)
|
C.glBindFramebuffer(C.GL_FRAMEBUFFER, framebuffer)
|
||||||
if err := C.glCheckFramebufferStatus(C.GL_FRAMEBUFFER);
|
if err := C.glCheckFramebufferStatus(C.GL_FRAMEBUFFER); err != C.GL_FRAMEBUFFER_COMPLETE {
|
||||||
err != C.GL_FRAMEBUFFER_COMPLETE {
|
|
||||||
panic(fmt.Sprintf("glBindFramebuffer failed: %d", err))
|
panic(fmt.Sprintf("glBindFramebuffer failed: %d", err))
|
||||||
}
|
}
|
||||||
C.glEnable(C.GL_BLEND)
|
C.glEnable(C.GL_BLEND)
|
||||||
@ -241,7 +240,7 @@ func (context *GraphicsContext) setShaderProgram(
|
|||||||
1, (*C.GLfloat)(&glColorMatrixTranslation[0]))
|
1, (*C.GLfloat)(&glColorMatrixTranslation[0]))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (context *GraphicsContext) getFramebuffer(textureID C.GLuint) C.GLuint{
|
func (context *GraphicsContext) getFramebuffer(textureID C.GLuint) C.GLuint {
|
||||||
framebuffer, ok := context.framebuffers[textureID]
|
framebuffer, ok := context.framebuffers[textureID]
|
||||||
if ok {
|
if ok {
|
||||||
return framebuffer
|
return framebuffer
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
package opengl_test
|
package opengl_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"testing"
|
|
||||||
. "."
|
. "."
|
||||||
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestClp2(t *testing.T) {
|
func TestClp2(t *testing.T) {
|
||||||
|
Loading…
Reference in New Issue
Block a user