mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-24 10:48:53 +01:00
graphics: Remove framebuffer's width/height
This commit is contained in:
parent
085336d50f
commit
93f7fdd349
@ -122,11 +122,13 @@ func (c *drawImageCommand) Exec(context *opengl.Context) error {
|
|||||||
if n == 0 {
|
if n == 0 {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
_, h := c.dst.Size()
|
||||||
|
proj := glMatrix(c.dst.framebuffer.projectionMatrix(h))
|
||||||
p := programContext{
|
p := programContext{
|
||||||
state: &theOpenGLState,
|
state: &theOpenGLState,
|
||||||
program: theOpenGLState.programTexture,
|
program: theOpenGLState.programTexture,
|
||||||
context: context,
|
context: context,
|
||||||
projectionMatrix: glMatrix(c.dst.framebuffer.projectionMatrix()),
|
projectionMatrix: proj,
|
||||||
texture: c.src.texture.native,
|
texture: c.src.texture.native,
|
||||||
geoM: c.geo,
|
geoM: c.geo,
|
||||||
colorM: c.color,
|
colorM: c.color,
|
||||||
@ -275,8 +277,6 @@ func (c *newScreenFramebufferImageCommand) Exec(context *opengl.Context) error {
|
|||||||
}
|
}
|
||||||
f := &framebuffer{
|
f := &framebuffer{
|
||||||
native: context.ScreenFramebuffer(),
|
native: context.ScreenFramebuffer(),
|
||||||
width: c.width,
|
|
||||||
height: c.height,
|
|
||||||
flipY: true,
|
flipY: true,
|
||||||
}
|
}
|
||||||
c.result.framebuffer = f
|
c.result.framebuffer = f
|
||||||
|
@ -34,8 +34,6 @@ func orthoProjectionMatrix(left, right, bottom, top int) *[4][4]float64 {
|
|||||||
|
|
||||||
type framebuffer struct {
|
type framebuffer struct {
|
||||||
native opengl.Framebuffer
|
native opengl.Framebuffer
|
||||||
width int
|
|
||||||
height int
|
|
||||||
flipY bool
|
flipY bool
|
||||||
proMatrix *[4][4]float64
|
proMatrix *[4][4]float64
|
||||||
}
|
}
|
||||||
@ -47,8 +45,6 @@ func newFramebufferFromTexture(context *opengl.Context, texture *texture) (*fram
|
|||||||
}
|
}
|
||||||
return &framebuffer{
|
return &framebuffer{
|
||||||
native: native,
|
native: native,
|
||||||
width: texture.width,
|
|
||||||
height: texture.height,
|
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -60,16 +56,14 @@ func (f *framebuffer) setAsViewport(context *opengl.Context) error {
|
|||||||
return context.SetViewport(f.native, width, height)
|
return context.SetViewport(f.native, width, height)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *framebuffer) projectionMatrix() *[4][4]float64 {
|
func (f *framebuffer) projectionMatrix(height int) *[4][4]float64 {
|
||||||
if f.proMatrix != nil {
|
if f.proMatrix != nil {
|
||||||
return f.proMatrix
|
return f.proMatrix
|
||||||
}
|
}
|
||||||
width := viewportSize
|
m := orthoProjectionMatrix(0, viewportSize, 0, viewportSize)
|
||||||
height := viewportSize
|
|
||||||
m := orthoProjectionMatrix(0, width, 0, height)
|
|
||||||
if f.flipY {
|
if f.flipY {
|
||||||
m[1][1] *= -1
|
m[1][1] *= -1
|
||||||
m[1][3] += float64(f.height) / float64(height) * 2
|
m[1][3] += float64(height) / float64(viewportSize) * 2
|
||||||
}
|
}
|
||||||
f.proMatrix = m
|
f.proMatrix = m
|
||||||
return f.proMatrix
|
return f.proMatrix
|
||||||
|
@ -112,7 +112,7 @@ func (i *Image) Pixels(context *opengl.Context) ([]uint8, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
f := i.framebuffer
|
f := i.framebuffer
|
||||||
return context.FramebufferPixels(f.native, f.width, f.height)
|
return context.FramebufferPixels(f.native, i.width, i.height)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (i *Image) ReplacePixels(p []uint8) error {
|
func (i *Image) ReplacePixels(p []uint8) error {
|
||||||
|
Loading…
Reference in New Issue
Block a user