예제 #1
0
파일: draw.go 프로젝트: velovix/paunch
func checkForErrors() error {

	err := OpenGLError{make([]gl.Enum, 0)}
	for errNumb := gl.GetError(); errNumb != gl.NO_ERROR; {
		err.ErrorCodes = append(err.ErrorCodes, errNumb)
		if len(err.ErrorCodes) >= 10 {
			err.ErrorCodes = append(err.ErrorCodes, 255)
			for errNumb := gl.GetError(); errNumb != gl.NO_ERROR; {
			}
			break
		}
	}

	if len(err.ErrorCodes) == 0 {
		return nil
	}

	return err
}
예제 #2
0
파일: gomandel.go 프로젝트: nsf/gomandel
func reuploadTexture(tex *gl.Uint, w, h int, data []byte) {
	if *tex > 0 {
		gl.BindTexture(gl.TEXTURE_2D, *tex)
		gl.TexImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.Sizei(w), gl.Sizei(h), 0,
			gl.RGBA, gl.UNSIGNED_BYTE, gl.Pointer(&data[0]))
		if gl.GetError() != gl.NO_ERROR {
			gl.DeleteTextures(1, tex)
			panic("Failed to reupload texture")
		}
		return
	}
	*tex = uploadTexture_RGBA32(w, h, data)
}
예제 #3
0
파일: gomandel.go 프로젝트: nsf/gomandel
func uploadTexture_RGBA32(w, h int, data []byte) gl.Uint {
	var id gl.Uint
	gl.GenTextures(1, &id)
	gl.BindTexture(gl.TEXTURE_2D, id)
	gl.TexParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR)
	gl.TexParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR)
	gl.TexParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE)
	gl.TexParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE)
	gl.TexParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_R, gl.CLAMP_TO_EDGE)
	gl.TexImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.Sizei(w), gl.Sizei(h), 0, gl.RGBA,
		gl.UNSIGNED_BYTE, gl.Pointer(&data[0]))

	if gl.GetError() != gl.NO_ERROR {
		gl.DeleteTextures(1, &id)
		panic("Failed to load a texture")
	}
	return id
}