Пример #1
0
func (me *RenderViewport) update() {
	me.shouldScissor = !(me.relative && me.relX == 0 && me.relY == 0 && me.relW == 1 && me.relH == 1)
	if me.relative {
		me.absW, me.absH = int(me.relW*float64(me.canvWidth)), int(me.relH*float64(me.canvHeight))
		me.absX, me.absY = int(me.relX*float64(me.canvWidth)), int(me.relY*float64(me.canvHeight))
	}
	me.glVpX, me.glVpY, me.glVpW, me.glVpH = gl.Int(me.absX), gl.Int(me.absY), gl.Sizei(me.absW), gl.Sizei(me.absH)
	me.aspect = float64(me.absW) / float64(me.absH)
}
Пример #2
0
func (me *FxProc) setProcIndex(index int) {
	if index != me.procIndex {
		me.procIndex = index
		me.unifNames = map[[2]string]string{}
		if me.IsTex() {
			me.Tex.glUnitI = gl.Int(index)
			me.Tex.glUnitU = gl.Uint(index)
			me.Tex.glUnitE = gl.Enum(gl.TEXTURE0 + index)
		}
	}
}
Пример #3
0
func setSupportInfos() {
	//	Extensions
	var num gl.Int
	gl.GetIntegerv(gl.NUM_EXTENSIONS, &num)
	Support.Extensions = make([]string, num)
	if num > 0 {
		for i := gl.Int(0); i < num; i++ {
			Support.Extensions[i] = Util.Stri(gl.EXTENSIONS, gl.Uint(i))
		}
	}

	//	Sampling limits, textures
	// Support.Textures.StreamUpdatesViaPixelBuffer = true
	if Util.Extension("texture_filter_anisotropic") {
		gl.GetFloatv(gl.MAX_TEXTURE_MAX_ANISOTROPY_EXT, &Support.Textures.MaxFilterAnisotropy)
	}
	gl.GetFloatv(gl.MAX_TEXTURE_LOD_BIAS, &Support.Textures.MaxMipLoadBias)
	Support.Textures.ImageUnits.MaxCombined = Util.Val(gl.MAX_COMBINED_TEXTURE_IMAGE_UNITS)
	Support.Textures.ImageUnits.MaxFragment = Util.Val(gl.MAX_TEXTURE_IMAGE_UNITS)
	Support.Textures.ImageUnits.MaxGeometry = Util.Val(gl.MAX_GEOMETRY_TEXTURE_IMAGE_UNITS)
	Support.Textures.ImageUnits.MaxVertex = Util.Val(gl.MAX_VERTEX_TEXTURE_IMAGE_UNITS)

	//	GL version-specifics
	if Support.GlVersion.Is42 {
		Support.Buffers.AtomicCounter, Support.Textures.Immutable = true, true
	}
	if Support.GlVersion.Is43 {
		Support.Textures.ImageUnits.MaxCompute = Util.Val(gl.MAX_COMPUTE_TEXTURE_IMAGE_UNITS)
		Support.Buffers.DispatchIndirect, Support.Buffers.ShaderStorage = true, true
	}

	//	GLSL version-specifics
	if Support.Glsl.Version.Is400 {
		Support.Glsl.Shaders.TessellationStages = true
	}
	if Support.Glsl.Version.Is430 {
		Support.Glsl.Shaders.ComputeStage = true
	}

	Cache.onGlInit()
}
Пример #4
0
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()
	}
}
Пример #5
0
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)
		}
	}
}
Пример #6
0
func (me *TextureBase) texImage(glTarget gl.Enum, width, height gl.Sizei, ptr gl.Ptr) (err error) {
	err = Try.TexImage2D(glTarget, 0, gl.Int(me.SizedInternalFormat), width, height, 0, me.PixelData.Format, me.PixelData.Type, ptr)
	return
}