Esempio n. 1
0
File: main.go Progetto: sycoso/glfw
func loadTextures() (err error) {
	gl.GenTextures(textures)

	// Texture 1
	textures[0].Bind(gl.TEXTURE_2D)

	if !glfw.LoadTexture2D(texturefile, 0) {
		return errors.New("Failed to load texture: " + texturefile)
	}

	gl.TexParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST)
	gl.TexParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST)

	// Texture 2
	textures[1].Bind(gl.TEXTURE_2D)

	if !glfw.LoadTexture2D(texturefile, 0) {
		return errors.New("Failed to load texture: " + texturefile)
	}

	gl.TexParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR)
	gl.TexParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR)

	// Texture 3
	textures[2].Bind(gl.TEXTURE_2D)

	if !glfw.LoadTexture2D(texturefile, glfw.BuildMipmapsBit) {
		return errors.New("Failed to load texture: " + texturefile)
	}

	gl.TexParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR)
	gl.TexParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR_MIPMAP_NEAREST)

	return
}
Esempio n. 2
0
File: main.go Progetto: andrebq/glfw
func loadTextures() (err error) {
	textures = make([]gl.Texture, len(texturefiles))
	gl.GenTextures(textures)

	for i := range texturefiles {
		textures[i].Bind(gl.TEXTURE_2D)

		if glfw.LoadTexture2D(texturefiles[i], 0) {
			return errors.New("Failed to load texture: " + texturefiles[i])
		}

		gl.TexParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR)
		gl.TexParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR)
	}

	return
}