本文整理汇总了C++中GL_ASSERT函数的典型用法代码示例。如果您正苦于以下问题:C++ GL_ASSERT函数的具体用法?C++ GL_ASSERT怎么用?C++ GL_ASSERT使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了GL_ASSERT函数的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: GL_ASSERT
inline GLint Program::UniformLocation(const char *name)
{
GL_ASSERT(m_id > 0);
GL_ASSERT(name != NULL);
return glGetUniformLocation(m_id, name);
}
开发者ID:sgedev,项目名称:sge,代码行数:7,代码来源:program.hpp
示例2: GUY_ERROR
bool Texture::create(int width, int height)
{
// Check if texture parameters are valid before creating it
if ((width == 0) || (height == 0))
{
GUY_ERROR("Failed to create texture, invalid size (%dx%d)\n", width, height);
return false;
}
// All the validity checks passed, we can store the new texture settings
m_size.x = width;
m_size.y = height;
// Create the OpenGL texture if it doesn't exist yet
if (!m_id)
{
GLuint texture;
GL_ASSERT(glGenTextures(1, &texture));
m_id = texture;
}
// Initialize the texture
GL_ASSERT(glBindTexture(GL_TEXTURE_2D, m_id));
GL_ASSERT(glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, m_size.x, m_size.y, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL));
return true;
}
开发者ID:budsan,项目名称:guyframework,代码行数:27,代码来源:texture.cpp
示例3: GL_ASSERT
bool Shader::Compile(const char *src)
{
GL_ASSERT(m_id != 0);
GL_ASSERT(src != NULL);
int len[1];
len[0] = (int)strlen(src);
GL_ASSERT(len[0] > 0);
glShaderSource(m_id, 1, &src, len);
glCompileShader(m_id);
GLint status;
glGetShaderiv(m_id, GL_COMPILE_STATUS, &status);
if (status == GL_TRUE)
return true;
GLsizei length;
GLchar info_log[256] = { 0 };
glGetShaderInfoLog(m_id, sizeof(info_log) - 1, &length, info_log);
m_info_log = info_log;
return false;
}
开发者ID:sgedev,项目名称:sge,代码行数:25,代码来源:shader.cpp
示例4: GL_ASSERT
bool Shader::compile() const
{
GLint status;
GL_ASSERT(glCompileShader(m_id));
GL_ASSERT(glGetShaderiv(m_id, GL_COMPILE_STATUS, &status));
return status == GL_TRUE;
}
开发者ID:budsan,项目名称:guyframework,代码行数:7,代码来源:shader.cpp
示例5: GL_ASSERT
void Mesh::setVertexData(const void* vertexData, unsigned int vertexStart, unsigned int vertexCount)
{
GL_ASSERT( glBindBuffer(GL_ARRAY_BUFFER, _vertexBuffer) );
if (vertexStart == 0 && vertexCount == 0)
{
GL_ASSERT( glBufferData(GL_ARRAY_BUFFER, _vertexFormat.getVertexSize() * _vertexCount, vertexData, _dynamic ? GL_DYNAMIC_DRAW : GL_STATIC_DRAW) );
}
else
{
if (vertexCount == 0)
{
vertexCount = _vertexCount - vertexStart;
}
else if (vertexCount > _vertexCount || vertexStart == 0 && vertexCount < _vertexCount)
{
_vertexCount = vertexCount;
GL_ASSERT(glBufferData(GL_ARRAY_BUFFER, _vertexFormat.getVertexSize() * _vertexCount, vertexData, _dynamic ? GL_DYNAMIC_DRAW : GL_STATIC_DRAW));
}
else
{
GL_ASSERT(glBufferSubData(GL_ARRAY_BUFFER, vertexStart * _vertexFormat.getVertexSize(), vertexCount * _vertexFormat.getVertexSize(), vertexData));
}
}
}
开发者ID:reven86,项目名称:GamePlay,代码行数:25,代码来源:Mesh.cpp
示例6: GL_ASSERT
void Engine::Texture::updateData( void* data )
{
GL_ASSERT(glBindTexture(target, m_textureId));
switch (target)
{
case GL_TEXTURE_1D:
{
GL_ASSERT(glTexImage1D(target, 0, internalFormat, m_width, 0, m_format, dataType, data));
}
case GL_TEXTURE_2D:
{
GL_ASSERT(glTexImage2D(target, 0, internalFormat, m_width, m_height, 0, m_format, dataType, data));
} break;
case GL_TEXTURE_3D:
{
GL_ASSERT(glTexImage3D(target, 0, internalFormat, m_width, m_height, m_depth, 0, m_format, dataType, data));
} break;
default:
{
CORE_ASSERT( 0, "Dafuck ?" );
} break;
}
}
开发者ID:AGGA-IRIT,项目名称:Radium-Engine,代码行数:27,代码来源:Texture.cpp
示例7: drawWireframe
static bool drawWireframe(Mesh* mesh)
{
switch (mesh->getPrimitiveType())
{
case Mesh::TRIANGLES:
{
unsigned int vertexCount = mesh->getVertexCount();
for (unsigned int i = 0; i < vertexCount; i += 3)
{
GL_ASSERT( glDrawArrays(GL_LINE_LOOP, i, 3) );
}
}
return true;
case Mesh::TRIANGLE_STRIP:
{
unsigned int vertexCount = mesh->getVertexCount();
for (unsigned int i = 2; i < vertexCount; ++i)
{
GL_ASSERT( glDrawArrays(GL_LINE_LOOP, i-2, 3) );
}
}
return true;
default:
// not supported
return false;
}
}
开发者ID:faustgames-ru,项目名称:AndroidWallpapers,代码行数:29,代码来源:Model.cpp
示例8: GL_ASSERT
void GLshader::print_subroutines()
{
int maxSub,maxSubU,countActiveSU;
char name[256]; int len, numCompS;
GL_ASSERT(glGetIntegerv(GL_MAX_SUBROUTINES, &maxSub));
GL_ASSERT(glGetIntegerv(GL_MAX_SUBROUTINE_UNIFORM_LOCATIONS, &maxSubU));
printf("Max Subroutines: %d Max Subroutine Uniforms: %d\n", maxSub,maxSubU);
GL_ASSERT(glGetProgramStageiv(program, GL_VERTEX_SHADER, GL_ACTIVE_SUBROUTINE_UNIFORMS, &countActiveSU));
for (int i = 0; i < countActiveSU; ++i) {
glGetActiveSubroutineUniformName(program, GL_VERTEX_SHADER, i, 256, &len, name);
printf("Suroutine Uniform: %d name: %s\n", i,name);
glGetActiveSubroutineUniformiv(program, GL_VERTEX_SHADER, i, GL_NUM_COMPATIBLE_SUBROUTINES, &numCompS);
int *s = (int *) malloc(sizeof(int) * numCompS);
glGetActiveSubroutineUniformiv(program, GL_VERTEX_SHADER, i, GL_COMPATIBLE_SUBROUTINES, s);
printf("Compatible Subroutines:\n");
for (int j=0; j < numCompS; ++j) {
glGetActiveSubroutineName(program, GL_VERTEX_SHADER, s[j], 256, &len, name);
printf("\t%d - %s\n", s[j],name);
}
printf("\n");
free(s);
}
}
开发者ID:Toeplitz,项目名称:poll,代码行数:29,代码来源:glshader.cpp
示例9: GL_ASSERT
void MeshPart::setIndexData(void* indexData, unsigned int indexStart, unsigned int indexCount)
{
GL_ASSERT( glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _indexBuffer) );
unsigned int indexSize = 0;
switch (_indexFormat)
{
case Mesh::INDEX8:
indexSize = 1;
break;
case Mesh::INDEX16:
indexSize = 2;
break;
case Mesh::INDEX32:
indexSize = 4;
break;
default:
GP_ERROR("Unsupported index format (%d).", _indexFormat);
return;
}
if (indexStart == 0 && indexCount == 0)
{
GL_ASSERT( glBufferData(GL_ELEMENT_ARRAY_BUFFER, indexSize * _indexCount, indexData, _dynamic ? GL_DYNAMIC_DRAW : GL_STATIC_DRAW) );
}
else
{
if (indexCount == 0)
{
indexCount = _indexCount - indexStart;
}
GL_ASSERT( glBufferSubData(GL_ELEMENT_ARRAY_BUFFER, indexStart * indexSize, indexCount * indexSize, indexData) );
}
}
开发者ID:AllenPestaluky,项目名称:GamePlay,代码行数:35,代码来源:MeshPart.cpp
示例10: GL_ASSERT
Texture* Texture::create(Format format, unsigned int width, unsigned int height, unsigned char* data, bool generateMipmaps)
{
// Load our texture.
GLuint textureId;
GL_ASSERT( glGenTextures(1, &textureId) );
GL_ASSERT( glBindTexture(GL_TEXTURE_2D, textureId) );
if (format == DEPTH)
{
// <type> must be UNSIGNED_SHORT or UNSIGNED_INT for a format of DEPTH_COMPONENT.
GL_ASSERT( glTexImage2D(GL_TEXTURE_2D, 0, (GLenum)format, width, height, 0, (GLenum)format, GL_UNSIGNED_INT, data) );
}
else
{
GL_ASSERT( glTexImage2D(GL_TEXTURE_2D, 0, (GLenum)format, width, height, 0, (GLenum)format, GL_UNSIGNED_BYTE, data) );
}
// Set initial minification filter based on whether or not mipmaping was enabled
GL_ASSERT( glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, generateMipmaps ? GL_NEAREST_MIPMAP_LINEAR : GL_LINEAR) );
Texture* texture = new Texture();
texture->_handle = textureId;
texture->_width = width;
texture->_height = height;
if (generateMipmaps)
{
texture->generateMipmaps();
}
return texture;
}
开发者ID:aaweb,项目名称:GamePlay,代码行数:32,代码来源:Texture.cpp
示例11: GL_ASSERT
Texture* Texture::create(Format format, unsigned int width, unsigned int height, unsigned char* data, bool generateMipmaps)
{
// Create and load the texture.
GLuint textureId;
GL_ASSERT( glGenTextures(1, &textureId) );
GL_ASSERT( glBindTexture(GL_TEXTURE_2D, textureId) );
GL_ASSERT( glPixelStorei(GL_UNPACK_ALIGNMENT, 1) );
GL_ASSERT( glTexImage2D(GL_TEXTURE_2D, 0, (GLenum)format, width, height, 0, (GLenum)format, GL_UNSIGNED_BYTE, data) );
// Set initial minification filter based on whether or not mipmaping was enabled.
GL_ASSERT( glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, generateMipmaps ? GL_NEAREST_MIPMAP_LINEAR : GL_LINEAR) );
Texture* texture = new Texture();
texture->_handle = textureId;
texture->_format = format;
texture->_width = width;
texture->_height = height;
if (generateMipmaps)
{
texture->generateMipmaps();
texture->_mipmapped = true;
}
return texture;
}
开发者ID:brobits,项目名称:GamePlay,代码行数:26,代码来源:Texture.cpp
示例12: GL_ASSERT
Mesh* Mesh::createMesh(const VertexFormat& vertexFormat, unsigned int vertexCount, bool dynamic)
{
GLuint vbo;
GL_ASSERT( glGenBuffers(1, &vbo) );
if (GL_LAST_ERROR())
{
return NULL;
}
GL_ASSERT( glBindBuffer(GL_ARRAY_BUFFER, vbo) );
if (GL_LAST_ERROR())
{
glDeleteBuffers(1, &vbo);
return NULL;
}
GL_CHECK( glBufferData(GL_ARRAY_BUFFER, vertexFormat.getVertexSize() * vertexCount, NULL, dynamic ? GL_DYNAMIC_DRAW : GL_STATIC_DRAW) );
if (GL_LAST_ERROR())
{
glBindBuffer(GL_ARRAY_BUFFER, 0);
glDeleteBuffers(1, &vbo);
return NULL;
}
Mesh* mesh = new Mesh(vertexFormat);
mesh->_vertexCount = vertexCount;
mesh->_vertexBuffer = vbo;
mesh->_dynamic = dynamic;
return mesh;
}
开发者ID:aaweb,项目名称:GamePlay,代码行数:31,代码来源:Mesh.cpp
示例13: GL_ASSERT
void VertexAttributeBinding::unbind()
{
if (_handle)
{
// Hardware mode
GL_ASSERT( glBindVertexArray(0) );
}
else
{
// Software mode
if (_mesh)
{
GL_ASSERT( glBindBuffer(GL_ARRAY_BUFFER, 0) );
}
GP_ASSERT(_attributes);
for (unsigned int i = 0; i < __maxVertexAttribs; ++i)
{
if (_attributes[i].enabled)
{
GL_ASSERT( glDisableVertexAttribArray(i) );
}
}
}
}
开发者ID:03050903,项目名称:GamePlay,代码行数:25,代码来源:VertexAttributeBinding.cpp
示例14: GP_ASSERT
unsigned int Model::draw(bool wireframe)
{
GP_ASSERT(_mesh);
unsigned int partCount = _mesh->getPartCount();
if (partCount == 0)
{
// No mesh parts (index buffers).
if (_material)
{
Technique* technique = _material->getTechnique();
GP_ASSERT(technique);
unsigned int passCount = technique->getPassCount();
for (unsigned int i = 0; i < passCount; ++i)
{
Pass* pass = technique->getPassByIndex(i);
GP_ASSERT(pass);
pass->bind();
GL_ASSERT( glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0) );
if (!wireframe || !drawWireframe(_mesh))
{
GL_ASSERT( glDrawArrays(_mesh->getPrimitiveType(), 0, _mesh->getVertexCount()) );
}
pass->unbind();
}
}
}
else
{
for (unsigned int i = 0; i < partCount; ++i)
{
MeshPart* part = _mesh->getPart(i);
GP_ASSERT(part);
// Get the material for this mesh part.
Material* material = getMaterial(i);
if (material)
{
Technique* technique = material->getTechnique();
GP_ASSERT(technique);
unsigned int passCount = technique->getPassCount();
for (unsigned int j = 0; j < passCount; ++j)
{
Pass* pass = technique->getPassByIndex(j);
GP_ASSERT(pass);
pass->bind();
GL_ASSERT( glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, part->_indexBuffer) );
if (!wireframe || !drawWireframe(part))
{
GL_ASSERT( glDrawElements(part->getPrimitiveType(), part->getIndexCount(), part->getIndexFormat(), 0) );
}
pass->unbind();
}
}
}
}
return partCount;
}
开发者ID:faustgames-ru,项目名称:AndroidWallpapers,代码行数:58,代码来源:Model.cpp
注:本文中的GL_ASSERT函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论