Exemplo n.º 1
0
	rgba_mask(boolean r, boolean g, boolean b, boolean a)
	noexcept
	{
		_v[0] = GLint(GLboolean(r));
		_v[1] = GLint(GLboolean(g));
		_v[2] = GLint(GLboolean(b));
		_v[3] = GLint(GLboolean(a));
	}
Exemplo n.º 2
0
void printLog(GLuint handle, bool is_program)
{
	//Why write two log printing functions when you can use FUNCTION POINTERS AND TERNARY OPERATORS >:D
	GLboolean (*glIs)(GLuint)                                  = is_program? glIsProgram         : glIsShader;
	void (*glGetiv)(GLuint, GLenum, GLint *)                   = is_program? glGetProgramiv      : glGetShaderiv;
	void (*glGetInfoLog)(GLuint, GLsizei, GLsizei *, GLchar *) = is_program? glGetProgramInfoLog : glGetShaderInfoLog;

	if (glIs(handle)) {
		int log_length = 0;
		int max_length = log_length;
		glGetiv(handle, GL_INFO_LOG_LENGTH, &max_length);
		char *info_log = (char *)malloc(max_length);
		glGetInfoLog(handle, max_length, &log_length, info_log);
		if (log_length > 0) {
			printf("%s\n", info_log);
		}
		free(info_log);
	} else {
		printf("Name %d is not a %s.\n", handle, is_program?"program":"shader");
	}
}
Exemplo n.º 3
0
GLboolean ProgramNULL::validate(const gl::Caps &caps, gl::InfoLog *infoLog)
{
    UNIMPLEMENTED();
    return GLboolean();
}
Exemplo n.º 4
0
	/**
	*	Extract Shader Storage Buffer data from the shader
	*/
	void Program::ExtractStorageBlockData()
	{
		GLint numBlocks = 0;
		glGetProgramInterfaceiv(_program, GL_SHADER_STORAGE_BLOCK, GL_ACTIVE_RESOURCES, &numBlocks);

		char tempNameAR[1024];

		Log("\tBuffer :")

			for (int blockIdx = 0; blockIdx < numBlocks; blockIdx++)
			{
				std::vector<BufferVariableInfo> vars;

				glGetProgramResourceName(_program, GL_SHADER_STORAGE_BLOCK, blockIdx, 1024, NULL, tempNameAR);

				std::string bufferName(tempNameAR);

				GLint binding = 0;
				{
					GLenum prop[] = { GL_BUFFER_BINDING };
					glGetProgramResourceiv(_program, GL_SHADER_STORAGE_BLOCK, blockIdx, 1, prop, 1, NULL, &binding);
				}

				Log("\t\t" + bufferName + " index " + ToString(blockIdx) + " binding " + ToString(binding));

				GLint vcount = 0;
				{
					GLenum prop[] = { GL_NUM_ACTIVE_VARIABLES };
					glGetProgramResourceiv(_program, GL_SHADER_STORAGE_BLOCK, blockIdx, 1, prop, 1, NULL, &vcount);
				}

				std::vector<GLint> variables(vcount);
				{
					GLenum prop[] = { GL_ACTIVE_VARIABLES };
					glGetProgramResourceiv(_program, GL_SHADER_STORAGE_BLOCK, blockIdx, 1, prop, vcount, NULL, &variables.front());
				}

				GLchar vnameAR[128] = { 0 };
				for (int k = 0; k < vcount; k++)
				{
					GLenum propsAR[] = { GL_OFFSET, GL_TYPE, GL_ARRAY_STRIDE, GL_MATRIX_STRIDE, GL_IS_ROW_MAJOR, GL_TOP_LEVEL_ARRAY_STRIDE };
					GLint paramsAR[sizeof(propsAR) / sizeof(GLenum)];

					glGetProgramResourceiv(_program, GL_BUFFER_VARIABLE, variables[k], sizeof(propsAR) / sizeof(GLenum), propsAR, sizeof(paramsAR) / sizeof(GLenum), NULL, paramsAR);
					glGetProgramResourceName(_program, GL_BUFFER_VARIABLE, variables[k], sizeof(vnameAR), NULL, vnameAR);

					Log("\t\t\t" + std::string(vnameAR) + " offset " + ToString(paramsAR[0]) + " type " + GLUtil::GLSLTypeToStr(GLenum(paramsAR[1])) + " array stride " + ToString(paramsAR[2]) + " top level stride " + ToString(paramsAR[5]));

					vars.push_back(BufferVariableInfo(std::string(vnameAR), paramsAR[0], GLenum(paramsAR[1]), paramsAR[2], paramsAR[3], GLboolean(paramsAR[4]), paramsAR[5]));
				}

				_buffers.insert(std::make_pair(bufferName, BufferInfo(bufferName, blockIdx, vars)));
			}
	}
Exemplo n.º 5
0
namespace gl
{


const GLboolean GLboolean::GL_FALSE = GLboolean(false);
const GLboolean GLboolean::GL_TRUE = GLboolean(true);

GLboolean::GLboolean()
: GLboolean(false)
{
}

GLboolean::GLboolean(bool on)
: m_value(on)
{
}

GLboolean::GLboolean(const GLboolean & other)
: m_value(other.m_value)
{
}

GLboolean::GLboolean(GLboolean && other)
: m_value(std::move(other.m_value))
{
}

GLboolean::operator bool() const
{
    return m_value;
}

GLboolean::operator char() const
{
    return m_value;
}

GLboolean::operator unsigned char() const
{
    return m_value;
}

GLboolean::operator int() const
{
    return m_value;
}

GLboolean::operator unsigned int() const
{
    return m_value;
}

GLboolean & GLboolean::operator=(const GLboolean & other)
{
    m_value = other.m_value;

    return *this;
}

GLboolean & GLboolean::operator=(GLboolean && other)
{
    m_value = std::move(other.m_value);

    return *this;
}

bool GLboolean::operator<(const GLboolean & other) const
{
    return m_value < other.m_value;
}

bool GLboolean::operator>(const GLboolean & other) const
{
    return m_value > other.m_value;
}

bool GLboolean::operator<=(const GLboolean & other) const
{
    return m_value <= other.m_value;
}

bool GLboolean::operator>=(const GLboolean & other) const
{
    return m_value >= other.m_value;
}

bool GLboolean::operator==(const GLboolean & other) const
{
    return m_value == other.m_value;
}

bool GLboolean::operator!=(const GLboolean & other) const
{
    return m_value != other.m_value;
}


} // namespace gl
Exemplo n.º 6
0
	boolean alpha(void) const
	noexcept
	{
		return boolean{GLboolean(_v[3])};
	}
Exemplo n.º 7
0
	boolean blue(void) const
	noexcept
	{
		return boolean{GLboolean(_v[2])};
	}
Exemplo n.º 8
0
	boolean green(void) const
	noexcept
	{
		return boolean{GLboolean(_v[1])};
	}
Exemplo n.º 9
0
	boolean red(void) const
	noexcept
	{
		return boolean{GLboolean(_v[0])};
	}