소스 검색

fixed gls stats update

leonsal 8 년 전
부모
커밋
a51a7bbdc8
2개의 변경된 파일11개의 추가작업 그리고 9개의 파일을 삭제
  1. 8 6
      gls/gls.go
  2. 3 3
      util/stats/table.go

+ 8 - 6
gls/gls.go

@@ -19,8 +19,8 @@ import (
 // methods to call OpenGL functions.
 type GLS struct {
 	stats               Stats             // statistics
-	prog                *Program          // current active program
-	programs            map[*Program]bool // programs cache
+	prog                *Program          // current active shader program
+	programs            map[*Program]bool // shader programs cache
 	checkErrors         bool              // check openGL API errors flag
 	viewportX           int32             // cached last set viewport x
 	viewportY           int32             // cached last set viewport y
@@ -51,7 +51,7 @@ type GLS struct {
 type Stats struct {
 	Shaders    int    // Current number of shader programs
 	Vaos       int    // Number of Vertex Array Objects
-	Vbos       int    // Number of Vertex Buffer Objects
+	Buffers    int    // Number of Buffer Objects
 	Textures   int    // Number of Textures
 	Caphits    uint64 // Cummulative number of hits for Enable/Disable
 	UnilocHits uint64 // Cummulative number of uniform location cache hits
@@ -274,9 +274,10 @@ func (gs *GLS) CreateShader(stype uint32) uint32 {
 	return uint32(h)
 }
 
-func (gs *GLS) DeleteBuffers(vbos ...uint32) {
+func (gs *GLS) DeleteBuffers(bufs ...uint32) {
 
-	C.glDeleteBuffers(C.GLsizei(len(vbos)), (*C.GLuint)(&vbos[0]))
+	C.glDeleteBuffers(C.GLsizei(len(bufs)), (*C.GLuint)(&bufs[0]))
+	gs.stats.Buffers -= len(bufs)
 }
 
 func (gs *GLS) DeleteShader(shader uint32) {
@@ -298,6 +299,7 @@ func (gs *GLS) DeleteTextures(tex ...uint32) {
 func (gs *GLS) DeleteVertexArrays(vaos ...uint32) {
 
 	C.glDeleteVertexArrays(C.GLsizei(len(vaos)), (*C.GLuint)(&vaos[0]))
+	gs.stats.Vaos -= len(vaos)
 }
 
 func (gs *GLS) DepthFunc(mode uint32) {
@@ -376,7 +378,7 @@ func (gs *GLS) GenBuffer() uint32 {
 
 	var buf uint32
 	C.glGenBuffers(1, (*C.GLuint)(&buf))
-	gs.stats.Vbos++
+	gs.stats.Buffers++
 	return buf
 }
 

+ 3 - 3
util/stats/table.go

@@ -33,7 +33,7 @@ func NewStatsTable(width, height float32, gs *gls.GLS) *StatsTable {
 	st.ShowHeader(false)
 	st.addRow("shaders", "Shaders:")
 	st.addRow("vaos", "Vaos:")
-	st.addRow("vbos", "Vbos:")
+	st.addRow("buffers", "Buffers:")
 	st.addRow("textures", "Textures:")
 	st.addRow("unisets", "Uniforms/frame:")
 	st.addRow("drawcalls", "Draw calls/frame:")
@@ -59,8 +59,8 @@ func (st *StatsTable) update() {
 			st.Table.SetCell(f.row, "v", st.stats.Glstats.Shaders)
 		case "vaos":
 			st.Table.SetCell(f.row, "v", st.stats.Glstats.Vaos)
-		case "vbos":
-			st.Table.SetCell(f.row, "v", st.stats.Glstats.Vbos)
+		case "buffers":
+			st.Table.SetCell(f.row, "v", st.stats.Glstats.Buffers)
 		case "textures":
 			st.Table.SetCell(f.row, "v", st.stats.Glstats.Textures)
 		case "unisets":