コード例 #1
0
ファイル: render.go プロジェクト: go3d/go-ngine
func (me *RenderTechniqueScene) renderBatched(scene *Scene) {
	var (
		mesh   *Mesh
		node   *SceneNode
		effect *FxEffect
	)
	b := &me.thrRend.batch
	for i := 0; i < b.n; i++ {
		if node, mesh, effect = scene.allNodes.get(b.all[i].node), Core.Libs.Meshes.get(b.all[i].mesh), Core.Libs.Effects.get(b.all[i].fx); effect != nil && mesh != nil && node != nil && thrRend.curCam.thrRend.nodeRender[node.ID] {
			thrRend.nextEffect = effect
			Core.useTechFx()
			mesh.meshBuffer.use()
			if node.Render.skyMode {
				Core.Render.states.DisableFaceCulling()
				gl.DepthFunc(gl.LEQUAL)
				thrRend.curProg.Uniform1i("uni_int_Sky", 1)
			}
			thrRend.curProg.UniformMat4("uni_mat4_VertexMatrix", &thrRend.curCam.thrRend.nodeProjMats[node.ID])
			// thrRend.curProg.UniformMatrix4fv("uni_mat4_VertexMatrix", 1, gl.FALSE, &thrRend.curCam.thrRend.nodeProjMats[me.ID][0])
			if b.all[i].face == -1 {
				gl.DrawElementsBaseVertex(gl.TRIANGLES, mesh.raw.lastNumIndices, gl.UNSIGNED_INT, gl.Util.PtrOffset(nil, uintptr(mesh.meshBufOffsetIndices)), gl.Int(mesh.meshBufOffsetBaseIndex))
			} else {
				gl.DrawElementsBaseVertex(gl.TRIANGLES, 3, gl.UNSIGNED_INT, gl.Util.PtrOffset(nil, uintptr(mesh.meshBufOffsetIndices+(b.all[i].face*3*Core.Mesh.Buffers.MemSizePerIndex()))), gl.Int(mesh.meshBufOffsetBaseIndex))
			}
			if node.Render.skyMode {
				thrRend.curProg.Uniform1i("uni_int_Sky", 0)
				gl.DepthFunc(gl.LESS)
			}
		}
	}
	if thrRend.curCam.thrRend.nodeRender[0] {
		scene.allNodes[0].render()
	}
}
コード例 #2
0
ファイル: render.go プロジェクト: go3d/go-ngine
func (me *SceneNode) render() {
	mesh, mat := me.meshMat()
	if mat.HasFaceEffects() {
		for i, l := int32(0), int32(len(mesh.raw.faces)); i < l; i++ {
			thrRend.nextEffect = mat.faceEffect(&mesh.raw.faces[i])
			Core.useTechFx()
			mesh.meshBuffer.use()
			thrRend.curProg.UniformMat4("uni_mat4_VertexMatrix", &thrRend.curCam.thrRend.nodeProjMats[me.ID])
			// thrRend.curProg.UniformMatrix4fv("uni_mat4_VertexMatrix", 1, gl.FALSE, &thrRend.curCam.thrRend.nodeProjMats[me.ID][0])
			gl.DrawElementsBaseVertex(gl.TRIANGLES, 3, gl.UNSIGNED_INT, gl.Util.PtrOffset(nil, uintptr(mesh.meshBufOffsetIndices+(i*3*Core.Mesh.Buffers.MemSizePerIndex()))), gl.Int(mesh.meshBufOffsetBaseIndex))
		}
	} else {
		thrRend.nextEffect = Core.Libs.Effects.get(mat.DefaultEffectID)
		Core.useTechFx()
		mesh.meshBuffer.use()
		if me.Render.skyMode {
			Core.Render.states.DisableFaceCulling()
			gl.DepthFunc(gl.LEQUAL)
			thrRend.curProg.Uniform1i("uni_int_Sky", 1)
		}
		thrRend.curProg.UniformMat4("uni_mat4_VertexMatrix", &thrRend.curCam.thrRend.nodeProjMats[me.ID])
		// thrRend.curProg.UniformMatrix4fv("uni_mat4_VertexMatrix", 1, gl.FALSE, &thrRend.curCam.thrRend.nodeProjMats[me.ID][0])
		gl.DrawElementsBaseVertex(gl.TRIANGLES, mesh.raw.lastNumIndices, gl.UNSIGNED_INT, gl.Util.PtrOffset(nil, uintptr(mesh.meshBufOffsetIndices)), gl.Int(mesh.meshBufOffsetBaseIndex))
		if me.Render.skyMode {
			thrRend.curProg.Uniform1i("uni_int_Sky", 0)
			gl.DepthFunc(gl.LESS)
		}
	}
}