mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-11-10 04:57:26 +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 {
|
||||
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 {
|
||||
|
@ -32,17 +32,12 @@ func (device *Device) Init() {
|
||||
func (device *Device) Update(draw func(graphics.Context)) {
|
||||
context := device.context
|
||||
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.Clear()
|
||||
|
||||
draw(context)
|
||||
|
||||
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.Clear()
|
||||
|
||||
|
@ -175,7 +175,7 @@ func DrawTexture(native Texture, projectionMatrix [16]float32, quads []texture.Q
|
||||
shaderProgram := use(projectionMatrix, geometryMatrix, colorMatrix)
|
||||
// This state affects the other functions, so can't disable here...
|
||||
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")
|
||||
textureAttrLocation := getAttributeLocation(shaderProgram, "texture")
|
||||
|
@ -69,7 +69,7 @@ var (
|
||||
func (s *shader) compile() {
|
||||
csource := (*C.GLchar)(C.CString(s.source))
|
||||
// TODO: defer?
|
||||
//defer C.free(unsafe.Pointer(csource))
|
||||
// defer C.free(unsafe.Pointer(csource))
|
||||
|
||||
C.glShaderSource(s.id, 1, &csource, nil)
|
||||
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.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)
|
||||
if pixels != nil {
|
||||
@ -29,10 +33,6 @@ func createNativeTexture(textureWidth, textureHeight int, pixels []uint8) C.GLui
|
||||
C.GLsizei(textureWidth), C.GLsizei(textureHeight),
|
||||
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
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user