Skip to content

Commit

Permalink
Fixes Mesh and MeshPart mapbuffer and unmapbuffer
Browse files Browse the repository at this point in the history
  • Loading branch information
seanpaultaylor committed Mar 22, 2016
1 parent b6654c8 commit b9afc8f
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 18 deletions.
6 changes: 6 additions & 0 deletions gameplay/src/Base.h
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,9 @@ using std::va_list;
extern PFNGLDELETEVERTEXARRAYSOESPROC glDeleteVertexArrays;
extern PFNGLGENVERTEXARRAYSOESPROC glGenVertexArrays;
extern PFNGLISVERTEXARRAYOESPROC glIsVertexArray;
extern PFNGLMAPBUFFEROESPROC glMapBuffer;
extern PFNGLUNMAPBUFFEROESPROC glUnmapBuffer;
#define GL_WRITE_ONLY GL_WRITE_ONLY_OES
#define GL_DEPTH24_STENCIL8 GL_DEPTH24_STENCIL8_OES
#define glClearDepth glClearDepthf
#define OPENGL_ES
Expand All @@ -239,6 +242,9 @@ using std::va_list;
#define glDeleteVertexArrays glDeleteVertexArraysOES
#define glGenVertexArrays glGenVertexArraysOES
#define glIsVertexArray glIsVertexArrayOES
#define glMapBuffer glMapBufferOES
#define glUnmapBuffer glUnmapBufferOES
#define GL_WRITE_ONLY GL_WRITE_ONLY_OES
#define GL_DEPTH24_STENCIL8 GL_DEPTH24_STENCIL8_OES
#define glClearDepth glClearDepthf
#define OPENGL_ES
Expand Down
4 changes: 2 additions & 2 deletions gameplay/src/Mesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -261,11 +261,11 @@ void Mesh::setPrimitiveType(PrimitiveType type)
_primitiveType = type;
}

void* Mesh::mapVertexBuffer(MapAccess access)
void* Mesh::mapVertexBuffer()
{
GL_ASSERT( glBindBuffer(GL_ARRAY_BUFFER, _vertexBuffer) );

return (void*)glMapBuffer(GL_ARRAY_BUFFER, access);
return (void*)glMapBuffer(GL_ARRAY_BUFFER, GL_WRITE_ONLY);
}

bool Mesh::unmapVertexBuffer()
Expand Down
13 changes: 1 addition & 12 deletions gameplay/src/Mesh.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,6 @@ class Mesh : public Ref
POINTS = GL_POINTS
};

/**
* Defines mapping access/usage.
*/
enum MapAccess
{
MAP_READ_ONLY = GL_READ_ONLY,
MAP_WRITE_ONLY = GL_WRITE_ONLY,
MAP_READ_WRITE = GL_READ_WRITE
};

/**
* Constructs a new mesh with the specified vertex format.
*
Expand Down Expand Up @@ -231,10 +221,9 @@ class Mesh : public Ref
* vertex buffer become corrupted while the buffer was mapped. The corruption results from screen
* resolution change or window system specific events. In this case, the data must be resubmitted.
*
* @param access The access for which the data can be use. Ex. read, write, read_write.
* @return The mapped vertex buffer
*/
void* mapVertexBuffer(Mesh::MapAccess access);
void* mapVertexBuffer();

/**
* Unmaps the vertex buffer.
Expand Down
4 changes: 2 additions & 2 deletions gameplay/src/MeshPart.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,11 @@ IndexBufferHandle MeshPart::getIndexBuffer() const
return _indexBuffer;
}

void* MeshPart::mapIndexBuffer(Mesh::MapAccess access)
void* MeshPart::mapIndexBuffer()
{
GL_ASSERT( glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _indexBuffer) );

return (void*)glMapBuffer(GL_ELEMENT_ARRAY_BUFFER, access);
return (void*)glMapBuffer(GL_ELEMENT_ARRAY_BUFFER, GL_WRITE_ONLY);
}

bool MeshPart::unmapIndexBuffer()
Expand Down
3 changes: 1 addition & 2 deletions gameplay/src/MeshPart.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,9 @@ class MeshPart
* index buffer become corrupted while the buffer was mapped. The corruption results from screen
* resolution change or window system specific events. In this case, the data must be resubmitted.
*
* @param access The access for which the data can be use. Ex. read, write, read_write.
* @return The mapped index buffer
*/
void* mapIndexBuffer(Mesh::MapAccess access);
void* mapIndexBuffer();

/**
* Unmaps the index buffer.
Expand Down
4 changes: 4 additions & 0 deletions gameplay/src/PlatformAndroid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ PFNGLBINDVERTEXARRAYOESPROC glBindVertexArray = NULL;
PFNGLDELETEVERTEXARRAYSOESPROC glDeleteVertexArrays = NULL;
PFNGLGENVERTEXARRAYSOESPROC glGenVertexArrays = NULL;
PFNGLISVERTEXARRAYOESPROC glIsVertexArray = NULL;
PFNGLMAPBUFFEROESPROC glMapBuffer = NULL;
PFNGLUNMAPBUFFEROESPROC glUnmapBuffer = NULL;

#define GESTURE_TAP_DURATION_MAX 200
#define GESTURE_LONG_TAP_DURATION_MIN GESTURE_TAP_DURATION_MAX
Expand Down Expand Up @@ -329,6 +331,8 @@ static bool initEGL()
glDeleteVertexArrays = (PFNGLDELETEVERTEXARRAYSOESPROC)eglGetProcAddress("glDeleteVertexArraysOES");
glGenVertexArrays = (PFNGLGENVERTEXARRAYSOESPROC)eglGetProcAddress("glGenVertexArraysOES");
glIsVertexArray = (PFNGLISVERTEXARRAYOESPROC)eglGetProcAddress("glIsVertexArrayOES");
glMapBuffer = (PFNGLMAPBUFFEROESPROC)eglGetProcAddress("glMapBufferOES");
glUnmapBuffer = (PFNGLUNMAPBUFFEROESPROC)eglGetProcAddress("glUnmapBufferOES");
}

return true;
Expand Down

0 comments on commit b9afc8f

Please sign in to comment.