mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-11-13 22:47:26 +01:00
Remove opengl.RenderTarget
This commit is contained in:
parent
db4e3fdc03
commit
c8011ffe88
@ -15,13 +15,13 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type Context struct {
|
type Context struct {
|
||||||
screen *RenderTarget
|
screen *Texture
|
||||||
screenWidth int
|
screenWidth int
|
||||||
screenHeight int
|
screenHeight int
|
||||||
screenScale int
|
screenScale int
|
||||||
textures map[C.GLuint]*Texture
|
textures map[C.GLuint]*Texture
|
||||||
currentOffscreen *RenderTarget
|
currentOffscreen *Texture
|
||||||
mainFramebufferTexture *RenderTarget
|
mainFramebufferTexture *Texture
|
||||||
}
|
}
|
||||||
|
|
||||||
func newContext(screenWidth, screenHeight, screenScale int) *Context {
|
func newContext(screenWidth, screenHeight, screenScale int) *Context {
|
||||||
@ -49,7 +49,7 @@ func (context *Context) Init() {
|
|||||||
|
|
||||||
screenID := context.NewRenderTarget(
|
screenID := context.NewRenderTarget(
|
||||||
context.screenWidth, context.screenHeight)
|
context.screenWidth, context.screenHeight)
|
||||||
context.screen = (*RenderTarget)(context.textures[C.GLuint(screenID)])
|
context.screen = context.textures[C.GLuint(screenID)]
|
||||||
}
|
}
|
||||||
|
|
||||||
func (context *Context) TextureID(renderTargetID graphics.RenderTargetID) graphics.TextureID {
|
func (context *Context) TextureID(renderTargetID graphics.RenderTargetID) graphics.TextureID {
|
||||||
@ -149,15 +149,15 @@ func abs(x int) int {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (context *Context) SetOffscreen(renderTargetID graphics.RenderTargetID) {
|
func (context *Context) SetOffscreen(renderTargetID graphics.RenderTargetID) {
|
||||||
renderTarget :=
|
renderTarget := context.textures[C.GLuint(renderTargetID)]
|
||||||
(*RenderTarget)(context.textures[C.GLuint(renderTargetID)])
|
// TODO: This is a kind of side-effect.
|
||||||
if renderTarget.framebuffer == 0 {
|
if renderTarget.framebuffer == 0 {
|
||||||
renderTarget.framebuffer = createFramebuffer(renderTarget.id)
|
renderTarget.framebuffer = createFramebuffer(renderTarget.id)
|
||||||
}
|
}
|
||||||
context.setOffscreen(renderTarget)
|
context.setOffscreen(renderTarget)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (context *Context) setOffscreen(renderTarget *RenderTarget) {
|
func (context *Context) setOffscreen(renderTarget *Texture) {
|
||||||
context.currentOffscreen = renderTarget
|
context.currentOffscreen = renderTarget
|
||||||
|
|
||||||
C.glFlush()
|
C.glFlush()
|
||||||
@ -293,11 +293,12 @@ func (context *Context) NewRenderTarget(width, height int) graphics.RenderTarget
|
|||||||
renderTarget := newRenderTarget(width, height)
|
renderTarget := newRenderTarget(width, height)
|
||||||
context.textures[renderTarget.id] = (*Texture)(renderTarget)
|
context.textures[renderTarget.id] = (*Texture)(renderTarget)
|
||||||
|
|
||||||
context.SetOffscreen(renderTarget.ID())
|
//context.setOffscreen((*Texture)(renderTarget))
|
||||||
|
context.SetOffscreen(graphics.RenderTargetID(renderTarget.id))
|
||||||
context.Clear()
|
context.Clear()
|
||||||
context.resetOffscreen()
|
context.resetOffscreen()
|
||||||
|
|
||||||
return renderTarget.ID()
|
return graphics.RenderTargetID(renderTarget.id)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (context *Context) NewTextureFromImage(img image.Image) (
|
func (context *Context) NewTextureFromImage(img image.Image) (
|
||||||
|
@ -53,7 +53,7 @@ func (device *Device) Update(draw func(graphics.Context)) {
|
|||||||
{0, scale, 0},
|
{0, scale, 0},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
context.DrawTexture(context.screen.TextureID(),
|
context.DrawTexture(graphics.TextureID(context.screen.id),
|
||||||
geometryMatrix, matrix.IdentityColor())
|
geometryMatrix, matrix.IdentityColor())
|
||||||
context.flush()
|
context.flush()
|
||||||
}
|
}
|
||||||
|
@ -103,9 +103,8 @@ func (err textureError) Error() string {
|
|||||||
return "Texture Error: " + string(err)
|
return "Texture Error: " + string(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
func newRenderTarget(width, height int) *RenderTarget {
|
func newRenderTarget(width, height int) *Texture {
|
||||||
renderTarget := createTexture(width, height, nil)
|
return createTexture(width, height, nil)
|
||||||
return (*RenderTarget)(renderTarget)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func newTextureFromImage(img image.Image) (*Texture, error) {
|
func newTextureFromImage(img image.Image) (*Texture, error) {
|
||||||
@ -123,8 +122,8 @@ func newTextureFromImage(img image.Image) (*Texture, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func newRenderTargetWithFramebuffer(width, height int,
|
func newRenderTargetWithFramebuffer(width, height int,
|
||||||
framebuffer C.GLuint) *RenderTarget {
|
framebuffer C.GLuint) *Texture {
|
||||||
texture := &Texture{
|
return &Texture{
|
||||||
id: 0,
|
id: 0,
|
||||||
width: width,
|
width: width,
|
||||||
height: height,
|
height: height,
|
||||||
@ -132,15 +131,4 @@ func newRenderTargetWithFramebuffer(width, height int,
|
|||||||
textureHeight: int(clp2(uint64(height))),
|
textureHeight: int(clp2(uint64(height))),
|
||||||
framebuffer: framebuffer,
|
framebuffer: framebuffer,
|
||||||
}
|
}
|
||||||
return (*RenderTarget)(texture)
|
|
||||||
}
|
|
||||||
|
|
||||||
type RenderTarget Texture
|
|
||||||
|
|
||||||
func (renderTarget *RenderTarget) TextureID() graphics.TextureID {
|
|
||||||
return graphics.TextureID(renderTarget.id)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (renderTarget *RenderTarget) ID() graphics.RenderTargetID {
|
|
||||||
return graphics.RenderTargetID(renderTarget.id)
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user