Skip to content

Commit

Permalink
Added remaining implementations for new IVertexBufferObject methods. …
Browse files Browse the repository at this point in the history
…Added cummulative getters for memory usage of loaded VertexBufferObjects in the VertexBufferObjectManager. Minor javadoc update in IVertexBufferObject.
  • Loading branch information
Nicolas Gramlich committed Feb 11, 2012
1 parent 06ef700 commit 0366ae3
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 4 deletions.
5 changes: 4 additions & 1 deletion src/org/andengine/opengl/vbo/IVertexBufferObject.java
Expand Up @@ -28,7 +28,10 @@ public interface IVertexBufferObject extends IDisposable {
public int getHardwareBufferID();

public boolean isLoadedToHardware();
/** Mark this {@link VertexBufferObject} as not not loaded to hardware, so it gets loaded to hardware before being used.. */
/**
* Mark this {@link VertexBufferObject} as not not loaded to hardware.
* It will reload itself to hardware when it gets used again.
*/
public void setNotLoadedToHardware();
public void unloadFromHardware(final GLState pGLState);

Expand Down
22 changes: 19 additions & 3 deletions src/org/andengine/opengl/vbo/VertexBufferObjectManager.java
Expand Up @@ -32,13 +32,29 @@ public class VertexBufferObjectManager {
// Getter & Setter
// ===========================================================

// TODO public synchronized int getPermamentByteSize() {
public synchronized int getHeapMemoryByteSize() {
int byteSize = 0;
final ArrayList<IVertexBufferObject> vertexBufferObjectsLoaded = this.mVertexBufferObjectsLoaded;
for(int i = vertexBufferObjectsLoaded.size() - 1; i >= 0; i--) {
byteSize += vertexBufferObjectsLoaded.get(i).getHeapMemoryByteSize();
}
return byteSize;
}

public synchronized int getNativeHeapMemoryByteSize() {
int byteSize = 0;
final ArrayList<IVertexBufferObject> vertexBufferObjectsLoaded = this.mVertexBufferObjectsLoaded;
for(int i = vertexBufferObjectsLoaded.size() - 1; i >= 0; i--) {
byteSize += vertexBufferObjectsLoaded.get(i).getNativeHeapMemoryByteSize();
}
return byteSize;
}

public synchronized int getByteSize() {
public synchronized int getGPUHeapMemoryByteSize() {
int byteSize = 0;
final ArrayList<IVertexBufferObject> vertexBufferObjectsLoaded = this.mVertexBufferObjectsLoaded;
for(int i = vertexBufferObjectsLoaded.size() - 1; i >= 0; i--) {
byteSize += vertexBufferObjectsLoaded.get(i).getByteCapacity();
byteSize += vertexBufferObjectsLoaded.get(i).getGPUMemoryByteSize();
}
return byteSize;
}
Expand Down
Expand Up @@ -129,6 +129,15 @@ public int getNativeHeapMemoryByteSize() {
return 0;
}

@Override
public int getGPUMemoryByteSize() {
if(this.isLoadedToHardware()) {
return this.getByteCapacity();
} else {
return 0;
}
}

// ===========================================================
// Methods for/from SuperClass/Interfaces
// ===========================================================
Expand Down

0 comments on commit 0366ae3

Please sign in to comment.