mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2025-01-26 10:42:42 +01:00
Move calling glTexParameteri
This commit is contained in:
parent
0baad5a6c3
commit
37746fc323
@ -60,6 +60,11 @@ func (context *Context) Init() {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
panic("initializing the offscreen failed: " + err.Error())
|
panic("initializing the offscreen failed: " + err.Error())
|
||||||
}
|
}
|
||||||
|
screen := context.renderTargets[context.screenId]
|
||||||
|
C.glBindTexture(C.GL_TEXTURE_2D, screen.Texture().Native().(C.GLuint))
|
||||||
|
C.glTexParameteri(C.GL_TEXTURE_2D, C.GL_TEXTURE_MAG_FILTER, C.GL_NEAREST)
|
||||||
|
C.glTexParameteri(C.GL_TEXTURE_2D, C.GL_TEXTURE_MIN_FILTER, C.GL_NEAREST)
|
||||||
|
C.glBindTexture(C.GL_TEXTURE_2D, 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (context *Context) ToTexture(renderTargetId graphics.RenderTargetId) graphics.TextureId {
|
func (context *Context) ToTexture(renderTargetId graphics.RenderTargetId) graphics.TextureId {
|
||||||
|
@ -32,17 +32,12 @@ func (device *Device) Init() {
|
|||||||
func (device *Device) Update(draw func(graphics.Context)) {
|
func (device *Device) Update(draw func(graphics.Context)) {
|
||||||
context := device.context
|
context := device.context
|
||||||
C.glEnable(C.GL_TEXTURE_2D)
|
C.glEnable(C.GL_TEXTURE_2D)
|
||||||
C.glTexParameteri(C.GL_TEXTURE_2D, C.GL_TEXTURE_MIN_FILTER, C.GL_NEAREST)
|
|
||||||
C.glTexParameteri(C.GL_TEXTURE_2D, C.GL_TEXTURE_MAG_FILTER, C.GL_NEAREST)
|
|
||||||
context.ResetOffscreen()
|
context.ResetOffscreen()
|
||||||
context.Clear()
|
context.Clear()
|
||||||
|
|
||||||
draw(context)
|
draw(context)
|
||||||
|
|
||||||
context.flush()
|
context.flush()
|
||||||
|
|
||||||
C.glTexParameteri(C.GL_TEXTURE_2D, C.GL_TEXTURE_MIN_FILTER, C.GL_LINEAR)
|
|
||||||
C.glTexParameteri(C.GL_TEXTURE_2D, C.GL_TEXTURE_MAG_FILTER, C.GL_LINEAR)
|
|
||||||
context.setMainFramebufferOffscreen()
|
context.setMainFramebufferOffscreen()
|
||||||
context.Clear()
|
context.Clear()
|
||||||
|
|
||||||
|
@ -175,7 +175,7 @@ func DrawTexture(native Texture, projectionMatrix [16]float32, quads []texture.Q
|
|||||||
shaderProgram := use(projectionMatrix, geometryMatrix, colorMatrix)
|
shaderProgram := use(projectionMatrix, geometryMatrix, colorMatrix)
|
||||||
// This state affects the other functions, so can't disable here...
|
// This state affects the other functions, so can't disable here...
|
||||||
C.glBindTexture(C.GL_TEXTURE_2D, C.GLuint(native))
|
C.glBindTexture(C.GL_TEXTURE_2D, C.GLuint(native))
|
||||||
//defer C.glBindTexture(C.GL_TEXTURE_2D, 0)
|
defer C.glBindTexture(C.GL_TEXTURE_2D, 0)
|
||||||
|
|
||||||
vertexAttrLocation := getAttributeLocation(shaderProgram, "vertex")
|
vertexAttrLocation := getAttributeLocation(shaderProgram, "vertex")
|
||||||
textureAttrLocation := getAttributeLocation(shaderProgram, "texture")
|
textureAttrLocation := getAttributeLocation(shaderProgram, "texture")
|
||||||
|
@ -69,7 +69,7 @@ var (
|
|||||||
func (s *shader) compile() {
|
func (s *shader) compile() {
|
||||||
csource := (*C.GLchar)(C.CString(s.source))
|
csource := (*C.GLchar)(C.CString(s.source))
|
||||||
// TODO: defer?
|
// TODO: defer?
|
||||||
//defer C.free(unsafe.Pointer(csource))
|
// defer C.free(unsafe.Pointer(csource))
|
||||||
|
|
||||||
C.glShaderSource(s.id, 1, &csource, nil)
|
C.glShaderSource(s.id, 1, &csource, nil)
|
||||||
C.glCompileShader(s.id)
|
C.glCompileShader(s.id)
|
||||||
|
@ -20,6 +20,10 @@ func createNativeTexture(textureWidth, textureHeight int, pixels []uint8) C.GLui
|
|||||||
}
|
}
|
||||||
C.glPixelStorei(C.GL_UNPACK_ALIGNMENT, 4)
|
C.glPixelStorei(C.GL_UNPACK_ALIGNMENT, 4)
|
||||||
C.glBindTexture(C.GL_TEXTURE_2D, C.GLuint(nativeTexture))
|
C.glBindTexture(C.GL_TEXTURE_2D, C.GLuint(nativeTexture))
|
||||||
|
defer C.glBindTexture(C.GL_TEXTURE_2D, 0)
|
||||||
|
|
||||||
|
C.glTexParameteri(C.GL_TEXTURE_2D, C.GL_TEXTURE_MAG_FILTER, C.GL_LINEAR)
|
||||||
|
C.glTexParameteri(C.GL_TEXTURE_2D, C.GL_TEXTURE_MIN_FILTER, C.GL_LINEAR)
|
||||||
|
|
||||||
ptr := unsafe.Pointer(nil)
|
ptr := unsafe.Pointer(nil)
|
||||||
if pixels != nil {
|
if pixels != nil {
|
||||||
@ -29,10 +33,6 @@ func createNativeTexture(textureWidth, textureHeight int, pixels []uint8) C.GLui
|
|||||||
C.GLsizei(textureWidth), C.GLsizei(textureHeight),
|
C.GLsizei(textureWidth), C.GLsizei(textureHeight),
|
||||||
0, C.GL_RGBA, C.GL_UNSIGNED_BYTE, ptr)
|
0, C.GL_RGBA, C.GL_UNSIGNED_BYTE, ptr)
|
||||||
|
|
||||||
C.glTexParameteri(C.GL_TEXTURE_2D, C.GL_TEXTURE_MAG_FILTER, C.GL_LINEAR)
|
|
||||||
C.glTexParameteri(C.GL_TEXTURE_2D, C.GL_TEXTURE_MIN_FILTER, C.GL_LINEAR)
|
|
||||||
C.glBindTexture(C.GL_TEXTURE_2D, 0)
|
|
||||||
|
|
||||||
return nativeTexture
|
return nativeTexture
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user