/* $Id$
This file is part of gldbg
-Copyright © 2009-2010 Mikko Rasa, Mikkosoft Productions
+Copyright © 2009-2011 Mikko Rasa, Mikkosoft Productions
Distributed under the GPL
*/
-#include <msp/core/except.h>
+#include <stdexcept>
#include "glstate.h"
using namespace std;
-using namespace Msp;
namespace {
decoder->glBufferSubDataARB = glBufferSubData;
decoder->glDeleteBuffers = glDeleteBuffers;
decoder->glDeleteBuffersARB = glDeleteBuffers;
+
+ decoder->glDrawElements = glDrawElements;
+ decoder->glDrawRangeElements = glDrawRangeElements;
+ decoder->glDrawRangeElementsEXT = glDrawRangeElements;
}
GlState::~GlState()
{
TextureMap::const_iterator i = textures.find(id);
if(i==textures.end())
- throw KeyError("Unknown texture");
+ throw runtime_error("Unknown texture");
return i->second;
}
{
BufferMap::const_iterator i = buffers.find(id);
if(i==buffers.end())
- throw KeyError("Unknown buffer");
+ throw runtime_error("Unknown buffer");
return i->second;
}
else if(array==GL_TEXTURE_COORD_ARRAY)
return texcoord_arrays[client_active_tex];
else
- throw InvalidParameterValue("Invalid array");
+ throw logic_error("Invalid array");
}
const ArrayState &GlState::get_texture_coord_array(unsigned index) const
return i->second;
// XXX Return a dummy?
- throw KeyError("Unknown attribute array");
+ throw runtime_error("Unknown attribute array");
}
void GlState::set_current_texture(GLenum target, unsigned id)
for(int i=0; i<count; ++i)
reinterpret_cast<GlState *>(user_data)->buffers.erase(ids[i]);
}
+
+void GlState::glDrawElements(void *user_data, GLenum, int, GLenum type, const void *)
+{
+ if(BufferState *buf = reinterpret_cast<GlState *>(user_data)->element_buffer)
+ buf->content.update_elements(type);
+}
+
+void GlState::glDrawRangeElements(void *user_data, GLenum, unsigned, unsigned, int, GLenum type, const void *)
+{
+ if(BufferState *buf = reinterpret_cast<GlState *>(user_data)->element_buffer)
+ buf->content.update_elements(type);
+}