From d6bfa72c5c9fd95ae89cd3a57072455422548d7a Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Mon, 16 May 2016 11:32:21 +0900 Subject: [PATCH] graphics: Remove openGLState.initialize --- internal/graphics/program.go | 12 +++--------- internal/ui/ui_glfw.go | 2 +- internal/ui/ui_js.go | 4 ++-- 3 files changed, 6 insertions(+), 12 deletions(-) diff --git a/internal/graphics/program.go b/internal/graphics/program.go index adfff7878..e98e0f547 100644 --- a/internal/graphics/program.go +++ b/internal/graphics/program.go @@ -21,7 +21,6 @@ import ( ) type openGLState struct { - initialized bool indexBufferLines opengl.Buffer indexBufferQuads opengl.Buffer programTexture opengl.Program @@ -44,15 +43,11 @@ const ( float32Size = 4 ) -func InitializeIfNeeded(c *opengl.Context) error { - return theOpenGLState.initializeIfNeeded(c) +func Initialize(c *opengl.Context) error { + return theOpenGLState.initialize(c) } -func (s *openGLState) initializeIfNeeded(c *opengl.Context) error { - if s.initialized { - return nil - } - +func (s *openGLState) initialize(c *opengl.Context) error { var zeroProgram opengl.Program s.lastProgram = zeroProgram s.lastProjectionMatrix = nil @@ -100,7 +95,6 @@ func (s *openGLState) initializeIfNeeded(c *opengl.Context) error { } s.indexBufferLines = c.NewBuffer(c.ElementArrayBuffer, indices, c.StaticDraw) - s.initialized = true return nil } diff --git a/internal/ui/ui_glfw.go b/internal/ui/ui_glfw.go index fd0d7e15c..6659d05a3 100644 --- a/internal/ui/ui_glfw.go +++ b/internal/ui/ui_glfw.go @@ -88,7 +88,7 @@ func Init() (*opengl.Context, error) { if err := u.context.Init(); err != nil { return nil, err } - if err := graphics.InitializeIfNeeded(u.context); err != nil { + if err := graphics.Initialize(u.context); err != nil { return nil, err } diff --git a/internal/ui/ui_js.go b/internal/ui/ui_js.go index 56a740ceb..668f72642 100644 --- a/internal/ui/ui_js.go +++ b/internal/ui/ui_js.go @@ -110,7 +110,7 @@ func Init() (*opengl.Context, error) { if err != nil { return nil, err } - if err := graphics.InitializeIfNeeded(c); err != nil { + if err := graphics.Initialize(c); err != nil { return nil, err } return c, nil @@ -220,7 +220,7 @@ func Init() (*opengl.Context, error) { if err != nil { return nil, err } - if err := graphics.InitializeIfNeeded(c); err != nil { + if err := graphics.Initialize(c); err != nil { return nil, err } return c, nil