mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-26 11:48:55 +01:00
Add some comments
This commit is contained in:
parent
a6bf0f6634
commit
1c187597e6
@ -1,15 +1,14 @@
|
|||||||
package opengl
|
package opengl
|
||||||
|
|
||||||
import (
|
|
||||||
"github.com/hajimehoshi/go-ebiten/graphics"
|
|
||||||
"github.com/hajimehoshi/go-ebiten/graphics/matrix"
|
|
||||||
)
|
|
||||||
|
|
||||||
// #cgo LDFLAGS: -framework OpenGL
|
// #cgo LDFLAGS: -framework OpenGL
|
||||||
//
|
//
|
||||||
// #include <stdlib.h>
|
// #include <stdlib.h>
|
||||||
// #include <OpenGL/gl.h>
|
// #include <OpenGL/gl.h>
|
||||||
import "C"
|
import "C"
|
||||||
|
import (
|
||||||
|
"github.com/hajimehoshi/go-ebiten/graphics"
|
||||||
|
"github.com/hajimehoshi/go-ebiten/graphics/matrix"
|
||||||
|
)
|
||||||
|
|
||||||
func enableAlphaBlending() {
|
func enableAlphaBlending() {
|
||||||
C.glEnable(C.GL_TEXTURE_2D)
|
C.glEnable(C.GL_TEXTURE_2D)
|
||||||
|
@ -25,6 +25,7 @@ func DrawTexture(native NativeTexture, projectionMatrix [16]float32,
|
|||||||
if len(quads) == 0 {
|
if len(quads) == 0 {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
// TODO: Check performance
|
||||||
shaderProgram := use(projectionMatrix, geometryMatrix, colorMatrix)
|
shaderProgram := use(projectionMatrix, geometryMatrix, colorMatrix)
|
||||||
defer C.glUseProgram(0)
|
defer C.glUseProgram(0)
|
||||||
|
|
||||||
|
@ -85,7 +85,8 @@ func getLocation(program C.GLuint, name string, qvType qualifierVariableType) C.
|
|||||||
locationName := C.CString(name)
|
locationName := C.CString(name)
|
||||||
defer C.free(unsafe.Pointer(locationName))
|
defer C.free(unsafe.Pointer(locationName))
|
||||||
|
|
||||||
location := C.GLint(-1)
|
const invalidLocation = -1
|
||||||
|
location := C.GLint(invalidLocation)
|
||||||
|
|
||||||
switch qvType {
|
switch qvType {
|
||||||
case qualifierVariableTypeAttribute:
|
case qualifierVariableTypeAttribute:
|
||||||
@ -95,7 +96,7 @@ func getLocation(program C.GLuint, name string, qvType qualifierVariableType) C.
|
|||||||
default:
|
default:
|
||||||
panic("no reach")
|
panic("no reach")
|
||||||
}
|
}
|
||||||
if location == -1 {
|
if location == invalidLocation {
|
||||||
panic("glGetUniformLocation failed")
|
panic("glGetUniformLocation failed")
|
||||||
}
|
}
|
||||||
shaderLocationCache[qvType][name] = location
|
shaderLocationCache[qvType][name] = location
|
||||||
@ -112,7 +113,8 @@ func getUniformLocation(program C.GLuint, name string) C.GLint {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func use(projectionMatrix [16]float32,
|
func use(projectionMatrix [16]float32,
|
||||||
geometryMatrix matrix.Geometry, colorMatrix matrix.Color) C.GLuint {
|
geometryMatrix matrix.Geometry,
|
||||||
|
colorMatrix matrix.Color) C.GLuint {
|
||||||
programId := programRegular
|
programId := programRegular
|
||||||
if !colorMatrix.IsIdentity() {
|
if !colorMatrix.IsIdentity() {
|
||||||
programId = programColorMatrix
|
programId = programColorMatrix
|
||||||
|
Loading…
Reference in New Issue
Block a user