소스 검색

fixed renderer bug

leonsal 8 년 전
부모
커밋
fbe8bb762c
1개의 변경된 파일5개의 추가작업 그리고 2개의 파일을 삭제
  1. 5 2
      renderer/renderer.go

+ 5 - 2
renderer/renderer.go

@@ -18,6 +18,7 @@ type Renderer struct {
 	gs           *gls.GLS
 	shaman       Shaman                     // Internal shader manager
 	stats        Stats                      // Renderer statistics
+	prevStats    Stats                      // Renderer statistics for previous frame
 	scene        core.INode                 // Node containing 3D scene to render
 	panelGui     gui.IPanel                 // Panel containing GUI to render
 	panel3D      gui.IPanel                 // Panel which contains the 3D scene
@@ -237,8 +238,9 @@ func (r *Renderer) renderScene(iscene core.INode, icam camera.ICamera) error {
 		r.stats.Others++
 	}
 
-	// If there is graphic material to render
-	if len(r.grmats) > 0 {
+	// If there is graphic material to render or there was in the previous frame
+	// it is necessary to clear the screen.
+	if len(r.grmats) > 0 || r.prevStats.Graphics > 0 {
 		// If the 3D scene to draw is to be confined to user specified panel
 		// sets scissor to avoid erasing gui elements outside of this panel
 		if r.panel3D != nil {
@@ -292,6 +294,7 @@ func (r *Renderer) renderScene(iscene core.INode, icam camera.ICamera) error {
 		grmat.Render(r.gs, &r.rinfo)
 		r.stats.Graphics++
 	}
+	r.prevStats = r.stats
 	return nil
 }