mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-11-10 04:57:26 +01:00
graphicscommand: Remove Texture
This commit is contained in:
parent
bc3ca38f76
commit
e28c7b0f50
@ -244,7 +244,7 @@ func (c *drawImageCommand) Exec(indexOffsetInBytes int) error {
|
||||
proj := f.projectionMatrix()
|
||||
dw, dh := c.dst.Size()
|
||||
sw, sh := c.src.Size()
|
||||
opengl.UseProgram(proj, c.src.texture.native, dw, dh, sw, sh, c.color, c.filter)
|
||||
opengl.UseProgram(proj, c.src.texture, dw, dh, sw, sh, c.color, c.filter)
|
||||
opengl.GetContext().DrawElements(c.nindices, indexOffsetInBytes)
|
||||
|
||||
// glFlush() might be necessary at least on MacBook Pro (a smilar problem at #419),
|
||||
@ -310,7 +310,7 @@ func (c *replacePixelsCommand) Exec(indexOffsetInBytes int) error {
|
||||
// glFlush is necessary on Android.
|
||||
// glTexSubImage2D didn't work without this hack at least on Nexus 5x and NuAns NEO [Reloaded] (#211).
|
||||
opengl.GetContext().Flush()
|
||||
opengl.GetContext().BindTexture(c.dst.texture.native)
|
||||
opengl.GetContext().BindTexture(c.dst.texture)
|
||||
opengl.GetContext().TexSubImage2D(c.pixels, c.x, c.y, c.width, c.height)
|
||||
return nil
|
||||
}
|
||||
@ -389,8 +389,8 @@ func (c *disposeCommand) Exec(indexOffsetInBytes int) error {
|
||||
c.target.framebuffer.native != opengl.GetContext().ScreenFramebuffer() {
|
||||
opengl.GetContext().DeleteFramebuffer(c.target.framebuffer.native)
|
||||
}
|
||||
if c.target.texture != nil {
|
||||
opengl.GetContext().DeleteTexture(c.target.texture.native)
|
||||
if c.target.texture != *new(opengl.Texture) {
|
||||
opengl.GetContext().DeleteTexture(c.target.texture)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@ -445,13 +445,11 @@ func (c *newImageCommand) Exec(indexOffsetInBytes int) error {
|
||||
w := emath.NextPowerOf2Int(c.width)
|
||||
h := emath.NextPowerOf2Int(c.height)
|
||||
checkSize(w, h)
|
||||
native, err := opengl.GetContext().NewTexture(w, h)
|
||||
t, err := opengl.GetContext().NewTexture(w, h)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
c.result.texture = &texture{
|
||||
native: native,
|
||||
}
|
||||
c.result.texture = t
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -27,8 +27,8 @@ type framebuffer struct {
|
||||
}
|
||||
|
||||
// newFramebufferFromTexture creates a framebuffer from the given texture.
|
||||
func newFramebufferFromTexture(texture *texture, width, height int) (*framebuffer, error) {
|
||||
native, err := opengl.GetContext().NewFramebuffer(texture.native)
|
||||
func newFramebufferFromTexture(texture opengl.Texture, width, height int) (*framebuffer, error) {
|
||||
native, err := opengl.GetContext().NewFramebuffer(texture)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ func MaxImageSize() int {
|
||||
|
||||
// Image represents an image that is implemented with OpenGL.
|
||||
type Image struct {
|
||||
texture *texture
|
||||
texture opengl.Texture
|
||||
framebuffer *framebuffer
|
||||
width int
|
||||
height int
|
||||
@ -118,7 +118,7 @@ func (i *Image) ReplacePixels(p []byte, x, y, width, height int) {
|
||||
}
|
||||
|
||||
func (i *Image) IsInvalidated() bool {
|
||||
return !opengl.GetContext().IsTexture(i.texture.native)
|
||||
return !opengl.GetContext().IsTexture(i.texture)
|
||||
}
|
||||
|
||||
func (i *Image) createFramebufferIfNeeded() (*framebuffer, error) {
|
||||
|
@ -1,24 +0,0 @@
|
||||
// Copyright 2014 Hajime Hoshi
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package graphicscommand
|
||||
|
||||
import (
|
||||
"github.com/hajimehoshi/ebiten/internal/opengl"
|
||||
)
|
||||
|
||||
// texture represents OpenGL's texture.
|
||||
type texture struct {
|
||||
native opengl.Texture
|
||||
}
|
Loading…
Reference in New Issue
Block a user