Commit a6f63dd3 authored by Robert Menzel's avatar Robert Menzel

added objectLabel functions - untested

parent 42b115f8
......@@ -264,24 +264,158 @@ GLuint KHR_DEBUG_EMULATOR_GetDebugMessageLog(GLuint count, GLsizei bufsize, GLen
return 1;
}
void KHR_DEBUG_EMULATOR_GetObjectLabel(GLenum identifier, GLuint name, GLsizei bufSize, GLsizei * length, GLchar * label)
#ifndef GL_TRANSFORM_FEEDBACK
#define GL_TRANSFORM_FEEDBACK 0x8E22
#endif
GLboolean isValidObjectLabelNamespace( GLenum e )
{
KHR_DEBUG_EMULATOR_insertMissingFeatureError( "function not simulated yet - ignored" );
if (e == GL_BUFFER || e == GL_SHADER || e == GL_PROGRAM || e == GL_VERTEX_ARRAY
|| e == GL_QUERY || e == GL_PROGRAM_PIPELINE || e == GL_TRANSFORM_FEEDBACK
|| e == GL_SAMPLER || e == GL_TEXTURE || e == GL_RENDERBUFFER || e == GL_FRAMEBUFFER ) {
return true;
}
return false;
}
void KHR_DEBUG_EMULATOR_GetObjectPtrLabel(const void * ptr, GLsizei bufSize, GLsizei * length, GLchar * label)
typedef struct ObjectLabel {
GLenum identifier;
GLuint name;
GLsizei length;
GLchar * label;
ObjectLabel *nextLabel;
ObjectLabel *previousLabel;
} ObjectLabel;
ObjectLabel *g_ObjectLabels = NULL;
ObjectLabel *findObjectLabel(GLenum identifier, GLuint name)
{
KHR_DEBUG_EMULATOR_insertMissingFeatureError( "function not simulated yet - ignored" );
ObjectLabel *l = g_ObjectLabels;
while ( l != NULL ) {
if (l->identifier == identifier && l->name == name) return l;
l = l->nextLabel;
}
// none found:
return NULL;
}
void insertObjectLabel(GLenum identifier, GLuint name, GLsizei length, const GLchar * label)
{
ObjectLabel *l = (ObjectLabel *) malloc( sizeof(ObjectLabel) );
l->identifier = identifier;
l->name = name;
l->length = length;
l->label = (GLchar *) malloc( length+1 );
l->nextLabel = NULL;
l->previousLabel = NULL;
strncpy( l->label , label, length );
l->label[ length ] = 0;
// find last label
ObjectLabel *last = g_ObjectLabels;
if (last == NULL) {
// first label:
g_ObjectLabels = l;
return;
}
while ( last->nextLabel != NULL ) { last = last->nextLabel; }
last->nextLabel = l;
l->previousLabel = last;
}
//
// glObjectLabel
//
// TODO: check if name is a valid object, emit an INVALID_VALUE otherwise
//
void KHR_DEBUG_EMULATOR_ObjectLabel(GLenum identifier, GLuint name, GLsizei length, const GLchar * label)
{
KHR_DEBUG_EMULATOR_insertMissingFeatureError( "function not simulated yet - ignored" );
if ( !isValidObjectLabelNamespace(identifier) ) {
INSERT_API_ERROR( GL_INVALID_ENUM, "invalid enum in glObjectLabel" );
return;
}
if (length < 0) {
length = strlen( label );
}
if (length >= KHR_DEBUG_EMULATOR_MAX_LABEL_LENGTH) {
INSERT_API_ERROR( GL_INVALID_VALUE, "invalid value in glObjectLabel: label too long" );
return;
}
ObjectLabel *thelabel = findObjectLabel( identifier, name );
if (thelabel == NULL) {
insertObjectLabel( identifier, name, length, label );
} else {
// update
if (length == 0) {
// delete
ObjectLabel *pre = thelabel->previousLabel;
ObjectLabel *next = thelabel->nextLabel;
if (pre) pre->nextLabel = next;
if (next) next->previousLabel = pre;
if (!pre) g_ObjectLabels = next; // this was the first label
free( (void*) thelabel->label );
free( (void*) thelabel );
} else {
// update name & length:
if (length < 0) {
length = strlen( label );
}
free( (void*) thelabel->label );
thelabel->label = (GLchar *) malloc( length+1 );
strncpy( thelabel->label , label, length );
thelabel->label[ length ] = 0;
thelabel->length = length;
}
}
}
void KHR_DEBUG_EMULATOR_GetObjectLabel(GLenum identifier, GLuint name, GLsizei bufSize, GLsizei * length, GLchar * label)
{
ObjectLabel *thelabel = findObjectLabel( identifier, name );
if (thelabel == NULL) {
// label not found:
label[0] = 0;
*length = 0;
return;
}
size_t size = thelabel->length + 1;
if (bufSize-1 < size) size = bufSize-1;
if (label != NULL) {
strncpy( label, thelabel->label, size );
label[size] = 0;
}
*length = size;
}
void KHR_DEBUG_EMULATOR_ObjectPtrLabel(const void * ptr, GLsizei length, const GLchar * label)
{
KHR_DEBUG_EMULATOR_insertMissingFeatureError( "function not simulated yet - ignored" );
KHR_DEBUG_EMULATOR_insertMissingFeatureError( "function not simulated yet - ignored" );
}
void KHR_DEBUG_EMULATOR_GetObjectPtrLabel(const void * ptr, GLsizei bufSize, GLsizei * length, GLchar * label)
{
KHR_DEBUG_EMULATOR_insertMissingFeatureError( "function not simulated yet - ignored" );
}
struct DebugGroupDescription {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment