示例#1
0
文件: texture.go 项目: tanema/amore
// SetWrap will set how the texture behaves when applies to a plane that is larger
// than itself.
func (texture *Texture) SetWrap(wrap_s, wrap_t WrapMode) {
	texture.wrap.s = wrap_s
	texture.wrap.t = wrap_t
	bindTexture(texture.getHandle())
	gl.TexParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, int(wrap_s))
	gl.TexParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, int(wrap_t))
}
示例#2
0
文件: opengl.go 项目: tanema/amore
// Set the 'default' texture (id 0) as a repeating white pixel. Otherwise,
// texture2D calls inside a shader would return black when drawing graphics
// primitives, which would create the need to use different "passthrough"
// shaders for untextured primitives vs images.
func createDefaultTexture() {
	gl_state.defaultTexture = gl.CreateTexture()
	bindTexture(gl_state.defaultTexture)

	gl.TexParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST)
	gl.TexParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST)
	gl.TexParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.REPEAT)
	gl.TexParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.REPEAT)

	pix := []byte{255, 255, 255, 255}
	gl.TexImage2D(gl.TEXTURE_2D, 0, 1, 1, gl.RGBA, gl.UNSIGNED_BYTE, gl.Ptr(pix))
}
示例#3
0
文件: texture.go 项目: tanema/amore
// setTextureFilter will set the texture filter on the actual gl texture. It will
// not reach this state if the filter is not valid.
func (texture *Texture) setTextureFilter() {
	var gmin, gmag uint32

	bindTexture(texture.getHandle())

	if texture.filter.mipmap == FILTER_NONE {
		if texture.filter.min == FILTER_NEAREST {
			gmin = gl.NEAREST
		} else { // f.min == FILTER_LINEAR
			gmin = gl.LINEAR
		}
	} else {
		if texture.filter.min == FILTER_NEAREST && texture.filter.mipmap == FILTER_NEAREST {
			gmin = gl.NEAREST_MIPMAP_NEAREST
		} else if texture.filter.min == FILTER_NEAREST && texture.filter.mipmap == FILTER_LINEAR {
			gmin = gl.NEAREST_MIPMAP_LINEAR
		} else if texture.filter.min == FILTER_LINEAR && texture.filter.mipmap == FILTER_NEAREST {
			gmin = gl.LINEAR_MIPMAP_NEAREST
		} else if texture.filter.min == FILTER_LINEAR && texture.filter.mipmap == FILTER_LINEAR {
			gmin = gl.LINEAR_MIPMAP_LINEAR
		} else {
			gmin = gl.LINEAR
		}
	}

	switch texture.filter.mag {
	case FILTER_NEAREST:
		gmag = gl.NEAREST
	case FILTER_LINEAR:
		fallthrough
	default:
		gmag = gl.LINEAR
	}

	gl.TexParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, int(gmin))
	gl.TexParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, int(gmag))
	//gl.TexParameterf(gl.TEXTURE_2D, gl.TEXTURE_MAX_ANISOTROPY_EXT, texture.filter.anisotropy)
}