Пример #1
0
void Texture2DArray::pushToGPU(bool deleteAfterPush) {
	glTextureStorage3D(name, mipmapLevels, images[0].format.sizedFormat, images[0].width, images[0].height, images.size()); //allocate space for all

	for (unsigned int i = 0; i < images.size(); ++i) {
		ImageData &imageData = images[i];

		if (imageData.data != 0)
			glTextureSubImage3D(name,
				0,
				0, 0, i,
				imageData.width, imageData.height, 1,
				imageData.format.baseFormat, imageData.format.type, imageData.data);

		if (deleteAfterPush) {
			delete[] imageData.data;
			imageData.data = 0;
		}
	}

	if (mipmapLevels > 1) {
		glGenerateTextureMipmap(name); //generate the remaining mipmaps
		glTextureParameterf(name, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
	}
	else
		glTextureParameterf(name, GL_TEXTURE_MIN_FILTER, GL_LINEAR);

	glTextureParameterf(name, GL_TEXTURE_MAG_FILTER, GL_LINEAR);

	glTextureParameterf(name, GL_TEXTURE_WRAP_S, GL_REPEAT);
	glTextureParameterf(name, GL_TEXTURE_WRAP_T, GL_REPEAT);
}
Пример #2
0
/*
 * The texture parameter must be an existing texture object as returned
 * by glCreateTextures
 */
static bool
test_target_name(void)
{
	static const GLuint badname = 250;
	static const GLfloat fvec[2] = { 1.0, 1.0 };
	static const GLint ivec[2] = { -1, 1 };
	static const GLuint uvec[2] = { 1, 1 };
	bool pass = true;

	glTextureParameteri(badname, GL_TEXTURE_MAX_LEVEL, 4);
	pass = piglit_check_gl_error(GL_INVALID_OPERATION) && pass;

	glTextureParameterf(badname, GL_TEXTURE_MAX_LEVEL, 4.0);
	pass = piglit_check_gl_error(GL_INVALID_OPERATION) && pass;

	glTextureParameterfv(badname, GL_TEXTURE_MAX_LEVEL, fvec);
	pass = piglit_check_gl_error(GL_INVALID_OPERATION) && pass;

	glTextureParameteriv(badname, GL_TEXTURE_MAX_LEVEL, ivec);
	pass = piglit_check_gl_error(GL_INVALID_OPERATION) && pass;

	glTextureParameterIiv(badname, GL_TEXTURE_MAX_LEVEL, ivec);
	pass = piglit_check_gl_error(GL_INVALID_OPERATION) && pass;

	glTextureParameterIuiv(badname, GL_TEXTURE_MAX_LEVEL, uvec);
	pass = piglit_check_gl_error(GL_INVALID_OPERATION) && pass;

	piglit_report_subtest_result(pass ? PIGLIT_PASS : PIGLIT_FAIL,
				     "glTextureParameter: GL_INVALID_OPERATION "
				     "on bad texture");
	return pass;
}
Пример #3
0
void kit::Texture::setAnisotropicLevel(float l)
{
    m_anisotropicLevel = l;
#ifndef KIT_SHITTY_INTEL
    glTextureParameterf(m_glHandle, GL_TEXTURE_MAX_ANISOTROPY_EXT, l);
#else
    bind();
    glTexParameterf(m_type, GL_TEXTURE_MAX_ANISOTROPY_EXT, l);
#endif
}
Пример #4
0
	void OGLTexture::TexParameterf(GLenum pname, GLfloat param)
	{
		auto iter = tex_param_f_.find(pname);
		if ((iter == tex_param_f_.end()) || (iter->second != param))
		{
			if (glloader_GL_VERSION_4_5() || glloader_GL_ARB_direct_state_access())
			{
				glTextureParameterf(texture_, pname, param);
			}
			else if (glloader_GL_EXT_direct_state_access())
			{
				glTextureParameterfEXT(texture_, target_type_, pname, param);
			}
			else
			{
				OGLRenderEngine& re = *checked_cast<OGLRenderEngine*>(&Context::Instance().RenderFactoryInstance().RenderEngineInstance());
				re.BindTexture(0, target_type_, texture_);
				glTexParameterf(target_type_, pname, param);
			}

			tex_param_f_[pname] = param;
		}
	}
Пример #5
0
/* GL_INVALID_ENUM is generated if glTextureParamter{if} is called for a
 * non-scalar parameter
 */
static bool
test_scalar_vector(void)
{
	bool pass = true;
	const static GLfloat f = 1.0;
	const static GLint i = -1;
	GLuint name;

	/* Setup dsa. */
	glCreateTextures(GL_TEXTURE_2D, 1, &name);
	glBindTextureUnit(0, name);	/* Since next command isn't bindless. */

	glTextureParameteri(name, GL_TEXTURE_BORDER_COLOR, i);
	pass = piglit_check_gl_error(GL_INVALID_ENUM) && pass;

	glTextureParameterf(name, GL_TEXTURE_BORDER_COLOR, f);
	pass = piglit_check_gl_error(GL_INVALID_ENUM) && pass;

	piglit_report_subtest_result(pass ? PIGLIT_PASS : PIGLIT_FAIL,
				     "glTextureParameter{if}: GL_INVALID_ENUM "
				     "for non-scalars");
	return pass;
}
		void setTextureParameters(const graphics::Context::TexParameters & _parameters) override
		{
			const u32 handle(_parameters.handle);
			auto it = m_parameters.find(handle);
			// TODO make cacheable
			if (it == m_parameters.end()) {
				auto res = m_parameters.emplace(handle, _parameters);
				if (res.second)
					it = res.first;
			}

			if (_parameters.magFilter.isValid())
				glTextureParameteri(handle, GL_TEXTURE_MAG_FILTER, GLint(_parameters.magFilter));
			if (_parameters.minFilter.isValid())
				glTextureParameteri(handle, GL_TEXTURE_MIN_FILTER, GLint(_parameters.minFilter));
			if (_parameters.wrapS.isValid())
				glTextureParameteri(handle, GL_TEXTURE_WRAP_S, GLint(_parameters.wrapS));
			if (_parameters.wrapT.isValid())
				glTextureParameteri(handle, GL_TEXTURE_WRAP_T, GLint(_parameters.wrapT));
			if (_parameters.maxMipmapLevel.isValid())
				glTextureParameteri(handle, GL_TEXTURE_MAX_LEVEL, GLint(_parameters.maxMipmapLevel));
			if (_parameters.maxAnisotropy.isValid())
				glTextureParameterf(handle, GL_TEXTURE_MAX_ANISOTROPY_EXT, GLfloat(_parameters.maxAnisotropy));
		}
Пример #7
0
void kit::Texture::setAnisotropicLevel(float l)
{
  KIT_GL(glTextureParameterf(this->m_glHandle, GL_TEXTURE_MAX_ANISOTROPY_EXT, l));
}
Пример #8
0
void Tex2DArray::setParam(GLenum pname, GLfloat param)
{
	RN_CHECK_PARAM(glTextureParameterf(id, pname, param), rn::getEnumName(pname) << " " << param);
}
Пример #9
0
/* XXX: Is this actually a valid implementation? */
static bool
test_multisample(void)
{
	bool pass = true;
	static const GLfloat f = 1.0;
	static const GLint i = -1;
	static const GLfloat fvec[2] = { 1.0, -1.0 };
	static const GLint ivec[2] = { 1, -1 };
	static const GLuint uvec[2] = { 1, 4 };
	GLuint name;

	/* GL_TEXTURE_2D_MULTISAMPLE_ARRAY */
	glCreateTextures(GL_TEXTURE_2D_MULTISAMPLE_ARRAY, 1, &name);
	glBindTextureUnit(0, name);	/* Since next command isn't bindless. */

	glTextureParameteri(name, GL_TEXTURE_WRAP_R, i);
	pass = piglit_check_gl_error(GL_INVALID_ENUM) && pass;

	glTextureParameterf(name, GL_TEXTURE_WRAP_R, f);
	pass = piglit_check_gl_error(GL_INVALID_ENUM) && pass;

	glTextureParameterfv(name, GL_TEXTURE_WRAP_R, fvec);
	pass = piglit_check_gl_error(GL_INVALID_ENUM) && pass;

	glTextureParameteriv(name, GL_TEXTURE_WRAP_R, ivec);
	pass = piglit_check_gl_error(GL_INVALID_ENUM) && pass;

	glTextureParameterIiv(name, GL_TEXTURE_WRAP_R, ivec);
	pass = piglit_check_gl_error(GL_INVALID_ENUM) && pass;

	glTextureParameterIuiv(name, GL_TEXTURE_WRAP_R, uvec);
	pass = piglit_check_gl_error(GL_INVALID_ENUM) && pass;

	/* GL_TEXTURE_2D_MULTISAMPLE */
	glDeleteTextures(1, &name);
	glCreateTextures(GL_TEXTURE_2D_MULTISAMPLE, 1, &name);
	glBindTextureUnit(0, name);	/* Since next command isn't bindless. */

	glTextureParameteri(name, GL_TEXTURE_WRAP_R, i);
	pass = piglit_check_gl_error(GL_INVALID_ENUM) && pass;

	glTextureParameterf(name, GL_TEXTURE_WRAP_R, f);
	pass = piglit_check_gl_error(GL_INVALID_ENUM) && pass;

	glTextureParameterfv(name, GL_TEXTURE_WRAP_R, fvec);
	pass = piglit_check_gl_error(GL_INVALID_ENUM) && pass;

	glTextureParameteriv(name, GL_TEXTURE_WRAP_R, ivec);
	pass = piglit_check_gl_error(GL_INVALID_ENUM) && pass;

	glTextureParameterIiv(name, GL_TEXTURE_WRAP_R, ivec);
	pass = piglit_check_gl_error(GL_INVALID_ENUM) && pass;

	glTextureParameterIuiv(name, GL_TEXTURE_WRAP_R, uvec);
	pass = piglit_check_gl_error(GL_INVALID_ENUM) && pass;

	piglit_report_subtest_result(pass ? PIGLIT_PASS : PIGLIT_FAIL,
				     "glTextureParameter: GL_INVALID_ENUM if "
				     "multisample+sampler state");
	return pass;
}
Пример #10
0
void Texture::changeTextureParameter(GLenum parameter, GLfloat value) {
	glTextureParameterf(name, parameter, value);
}