diff --git a/graphics.go b/graphics.go index 7da77c209..f5e61cff4 100644 --- a/graphics.go +++ b/graphics.go @@ -59,5 +59,5 @@ type Texture struct { // Size returns the size of the texture. func (t *Texture) Size() (width int, height int) { - return t.glTexture.Width(), t.glTexture.Height() + return t.glTexture.Size() } diff --git a/internal/opengl/rendertarget.go b/internal/opengl/rendertarget.go index 874f19782..734e20d9f 100644 --- a/internal/opengl/rendertarget.go +++ b/internal/opengl/rendertarget.go @@ -58,19 +58,16 @@ func NewRenderTargetFromTexture(texture *Texture) (*RenderTarget, error) { if err != nil { return nil, err } + w, h := texture.Size() return &RenderTarget{ framebuffer: framebuffer, - width: texture.Width(), - height: texture.Height(), + width: w, + height: h, }, nil } -func (r *RenderTarget) Width() int { - return r.width -} - -func (r *RenderTarget) Height() int { - return r.height +func (r *RenderTarget) Size() (width, height int) { + return r.width, r.height } func (r *RenderTarget) Dispose() { diff --git a/internal/opengl/texture.go b/internal/opengl/texture.go index 5071e1148..097a352de 100644 --- a/internal/opengl/texture.go +++ b/internal/opengl/texture.go @@ -55,12 +55,8 @@ func (t *Texture) Native() gl.Texture { return t.native } -func (t *Texture) Width() int { - return t.width -} - -func (t *Texture) Height() int { - return t.height +func (t *Texture) Size() (width, height int) { + return t.width, t.height } func createNativeTexture(textureWidth, textureHeight int, pixels []uint8, filter int) gl.Texture { diff --git a/rendertarget.go b/rendertarget.go index fa7c196d0..7e39f9062 100644 --- a/rendertarget.go +++ b/rendertarget.go @@ -46,7 +46,7 @@ func newInnerRenderTarget(width, height int, filter int) (*innerRenderTarget, er } func (r *innerRenderTarget) size() (width, height int) { - return r.glRenderTarget.Width(), r.glRenderTarget.Height() + return r.glRenderTarget.Size() } func (r *innerRenderTarget) Clear() error { @@ -73,14 +73,15 @@ func (r *innerRenderTarget) DrawTexture(texture *Texture, parts []TexturePart, g return err } glTexture := texture.glTexture - quads := textureQuads(parts, glTexture.Width(), glTexture.Height()) + w, h := glTexture.Size() + quads := textureQuads(parts, w, h) targetNativeTexture := gl.Texture(0) if r.texture != nil { targetNativeTexture = r.texture.glTexture.Native() } - w, h := r.size() + w2, h2 := r.size() projectionMatrix := r.glRenderTarget.ProjectionMatrix() - shader.DrawTexture(glTexture.Native(), targetNativeTexture, w, h, projectionMatrix, quads, &geo, &color) + shader.DrawTexture(glTexture.Native(), targetNativeTexture, w2, h2, projectionMatrix, quads, &geo, &color) return nil }