Skip to content

Commit

Permalink
Fixed the buffer AGAIN, fixed the mesh so it accepts offsets, Impleme…
Browse files Browse the repository at this point in the history
…nted the rest of the SpriteCacheTest :)
  • Loading branch information
scooterman committed Sep 13, 2011
1 parent aa3de21 commit e800994
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/gdx-cpp/graphics/Mesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ void Mesh::render (int primitiveType,int offset,int count) {
int oldLimit = buffer.limit();
buffer.position(offset);
buffer.limit(offset + count);
Gdx::gl10->glDrawElements(primitiveType, count, GL10::GL_UNSIGNED_SHORT, (void *) buffer);
Gdx::gl10->glDrawElements(primitiveType, count, GL10::GL_UNSIGNED_SHORT, (void *) ((char*)buffer + offset));
buffer.position(oldPosition);
buffer.limit(oldLimit);
} else
Expand Down
4 changes: 2 additions & 2 deletions src/gdx-cpp/utils/Buffer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ struct buffer : public buffer_base {
throw std::runtime_error("buffer overflow");

T* casted_array = (T*) bf.get();
memcpy(casted_array, &src[offset], sizeof(T) * length);
memcpy(&casted_array[_position], &src[offset], sizeof(T) * length);

_position += length;

Expand All @@ -271,7 +271,7 @@ struct buffer : public buffer_base {
throw std::runtime_error("buffer overflow");

T* casted_array = (T*) bf.get();
memcpy(casted_array, &src[offset], sizeof(T) * length);
memcpy(&casted_array[_position], &src[offset], sizeof(T) * length);

_position += length;

Expand Down
15 changes: 9 additions & 6 deletions src/tests/SpriteCacheTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -178,33 +178,36 @@ class SpriteCacheTest : public gdx_cpp::ApplicationListener, gdx_cpp::InputProce
}

bool keyDown(int keycode) {
return false;
}

bool keyTyped(char character) {

return false;
}

bool keyUp(int keycode) {

return false;
}

bool scrolled(int amount) {
return false;
}

bool touchDown(int x, int y, int pointer, int button) {

++renderMethod %= 2;
return false;
}

bool touchDragged(int x, int y, int pointer) {

return false;
}

bool touchMoved(int x, int y) {

return false;
}

bool touchUp(int x, int y, int pointer, int button) {

return false;
}

protected:
Expand Down

0 comments on commit e800994

Please sign in to comment.