From 11a9b77be3c4ce25c096c4f7c73fbb5c3d2773bd Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Sat, 11 Jan 2014 15:18:04 +0900 Subject: [PATCH] Refactoring --- example/main.go | 3 +-- graphics/opengl/context.go | 8 ++++---- graphics/opengl/shared_context.go | 3 +-- ui/cocoa/shared_context.go | 10 +++++----- 4 files changed, 11 insertions(+), 13 deletions(-) diff --git a/example/main.go b/example/main.go index c7634fe7b..91db1f883 100644 --- a/example/main.go +++ b/example/main.go @@ -33,13 +33,12 @@ func main() { textureFactory := cocoa.TextureFactory() window := u.CreateGameWindow(screenWidth, screenHeight, screenScale, title) - textureFactoryEvents := textureFactory.Events() - drawing := make(chan *graphics.LazyContext) quit := make(chan struct{}) go func() { defer close(quit) + textureFactoryEvents := textureFactory.Events() windowEvents := window.Events() var game Game = blocks.NewGame(textureFactory) frameTime := time.Duration(int64(time.Second) / int64(fps)) diff --git a/graphics/opengl/context.go b/graphics/opengl/context.go index 5534d951b..b5b0245b8 100644 --- a/graphics/opengl/context.go +++ b/graphics/opengl/context.go @@ -15,14 +15,14 @@ type Context struct { } func newContext(ids *ids, screenWidth, screenHeight, screenScale int) *Context { - mainFramebuffer := rendertarget.NewWithCurrentFramebuffer( - screenWidth*screenScale, - screenHeight*screenScale) context := &Context{ ids: ids, screenScale: screenScale, } - context.mainId = context.ids.AddRenderTarget(mainFramebuffer) + mainRenderTarget := rendertarget.NewWithCurrentFramebuffer( + screenWidth*screenScale, + screenHeight*screenScale) + context.mainId = context.ids.AddRenderTarget(mainRenderTarget) var err error context.screenId, err = ids.CreateRenderTarget( diff --git a/graphics/opengl/shared_context.go b/graphics/opengl/shared_context.go index fc9e581a9..c6a750a74 100644 --- a/graphics/opengl/shared_context.go +++ b/graphics/opengl/shared_context.go @@ -10,10 +10,9 @@ type SharedContext struct { } func NewSharedContext() *SharedContext { - device := &SharedContext{ + return &SharedContext{ ids: newIds(), } - return device } func (s *SharedContext) CreateContext(screenWidth, screenHeight, screenScale int) *Context { diff --git a/ui/cocoa/shared_context.go b/ui/cocoa/shared_context.go index dc725de2a..41e21aedc 100644 --- a/ui/cocoa/shared_context.go +++ b/ui/cocoa/shared_context.go @@ -15,12 +15,12 @@ import ( ) type sharedContext struct { - inited chan struct{} + inited chan struct{} graphicsSharedContext *opengl.SharedContext - events chan interface{} - funcs chan func() - funcsDone chan struct{} - gameWindows chan *GameWindow + events chan interface{} + funcs chan func() + funcsDone chan struct{} + gameWindows chan *GameWindow } func newSharedContext() *sharedContext {