mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-25 19:28:57 +01:00
Refactoring
This commit is contained in:
parent
97857715fa
commit
6f3e45098b
@ -26,25 +26,24 @@ func newGraphicsContext(screenWidth, screenHeight, screenScale int) (*graphicsCo
|
|||||||
gl.Enable(gl.TEXTURE_2D)
|
gl.Enable(gl.TEXTURE_2D)
|
||||||
gl.Enable(gl.BLEND)
|
gl.Enable(gl.BLEND)
|
||||||
|
|
||||||
|
// The defualt framebuffer should be 0.
|
||||||
|
r := opengl.NewRenderTarget(screenWidth*screenScale, screenHeight*screenScale, true)
|
||||||
|
|
||||||
|
screenID, err := idsInstance.createRenderTarget(screenWidth, screenHeight, gl.NEAREST)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
c := &graphicsContext{
|
c := &graphicsContext{
|
||||||
|
currentIDs: make([]RenderTargetID, 1),
|
||||||
|
defaultID: idsInstance.addRenderTarget(r),
|
||||||
|
screenID: screenID,
|
||||||
screenWidth: screenWidth,
|
screenWidth: screenWidth,
|
||||||
screenHeight: screenHeight,
|
screenHeight: screenHeight,
|
||||||
screenScale: screenScale,
|
screenScale: screenScale,
|
||||||
}
|
}
|
||||||
|
|
||||||
// The defualt framebuffer should be 0.
|
idsInstance.fillRenderTarget(c.screenID, 0, 0, 0)
|
||||||
r := opengl.NewRenderTarget(screenWidth*screenScale, screenHeight*screenScale, true)
|
|
||||||
c.defaultID = idsInstance.addRenderTarget(r)
|
|
||||||
|
|
||||||
var err error
|
|
||||||
c.screenID, err = idsInstance.createRenderTarget(screenWidth, screenHeight, gl.NEAREST)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: This is a special stack only for clearing. Can we change this?
|
|
||||||
c.currentIDs = []RenderTargetID{c.screenID}
|
|
||||||
c.Clear()
|
|
||||||
|
|
||||||
return c, nil
|
return c, nil
|
||||||
}
|
}
|
||||||
@ -90,7 +89,8 @@ func (c *graphicsContext) PopRenderTarget() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *graphicsContext) preUpdate() {
|
func (c *graphicsContext) preUpdate() {
|
||||||
c.currentIDs = []RenderTargetID{c.defaultID}
|
c.currentIDs = c.currentIDs[0:1]
|
||||||
|
c.currentIDs[0] = c.defaultID
|
||||||
c.PushRenderTarget(c.screenID)
|
c.PushRenderTarget(c.screenID)
|
||||||
c.Clear()
|
c.Clear()
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user