mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2025-01-27 03:02:49 +01:00
Refactoring
This commit is contained in:
parent
ee23301538
commit
11a9b77be3
@ -33,13 +33,12 @@ func main() {
|
|||||||
textureFactory := cocoa.TextureFactory()
|
textureFactory := cocoa.TextureFactory()
|
||||||
window := u.CreateGameWindow(screenWidth, screenHeight, screenScale, title)
|
window := u.CreateGameWindow(screenWidth, screenHeight, screenScale, title)
|
||||||
|
|
||||||
textureFactoryEvents := textureFactory.Events()
|
|
||||||
|
|
||||||
drawing := make(chan *graphics.LazyContext)
|
drawing := make(chan *graphics.LazyContext)
|
||||||
quit := make(chan struct{})
|
quit := make(chan struct{})
|
||||||
go func() {
|
go func() {
|
||||||
defer close(quit)
|
defer close(quit)
|
||||||
|
|
||||||
|
textureFactoryEvents := textureFactory.Events()
|
||||||
windowEvents := window.Events()
|
windowEvents := window.Events()
|
||||||
var game Game = blocks.NewGame(textureFactory)
|
var game Game = blocks.NewGame(textureFactory)
|
||||||
frameTime := time.Duration(int64(time.Second) / int64(fps))
|
frameTime := time.Duration(int64(time.Second) / int64(fps))
|
||||||
|
@ -15,14 +15,14 @@ type Context struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func newContext(ids *ids, screenWidth, screenHeight, screenScale int) *Context {
|
func newContext(ids *ids, screenWidth, screenHeight, screenScale int) *Context {
|
||||||
mainFramebuffer := rendertarget.NewWithCurrentFramebuffer(
|
|
||||||
screenWidth*screenScale,
|
|
||||||
screenHeight*screenScale)
|
|
||||||
context := &Context{
|
context := &Context{
|
||||||
ids: ids,
|
ids: ids,
|
||||||
screenScale: screenScale,
|
screenScale: screenScale,
|
||||||
}
|
}
|
||||||
context.mainId = context.ids.AddRenderTarget(mainFramebuffer)
|
mainRenderTarget := rendertarget.NewWithCurrentFramebuffer(
|
||||||
|
screenWidth*screenScale,
|
||||||
|
screenHeight*screenScale)
|
||||||
|
context.mainId = context.ids.AddRenderTarget(mainRenderTarget)
|
||||||
|
|
||||||
var err error
|
var err error
|
||||||
context.screenId, err = ids.CreateRenderTarget(
|
context.screenId, err = ids.CreateRenderTarget(
|
||||||
|
@ -10,10 +10,9 @@ type SharedContext struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func NewSharedContext() *SharedContext {
|
func NewSharedContext() *SharedContext {
|
||||||
device := &SharedContext{
|
return &SharedContext{
|
||||||
ids: newIds(),
|
ids: newIds(),
|
||||||
}
|
}
|
||||||
return device
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *SharedContext) CreateContext(screenWidth, screenHeight, screenScale int) *Context {
|
func (s *SharedContext) CreateContext(screenWidth, screenHeight, screenScale int) *Context {
|
||||||
|
@ -15,12 +15,12 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type sharedContext struct {
|
type sharedContext struct {
|
||||||
inited chan struct{}
|
inited chan struct{}
|
||||||
graphicsSharedContext *opengl.SharedContext
|
graphicsSharedContext *opengl.SharedContext
|
||||||
events chan interface{}
|
events chan interface{}
|
||||||
funcs chan func()
|
funcs chan func()
|
||||||
funcsDone chan struct{}
|
funcsDone chan struct{}
|
||||||
gameWindows chan *GameWindow
|
gameWindows chan *GameWindow
|
||||||
}
|
}
|
||||||
|
|
||||||
func newSharedContext() *sharedContext {
|
func newSharedContext() *sharedContext {
|
||||||
|
Loading…
Reference in New Issue
Block a user