2023-08-17 20:22:24 +08:00
|
|
|
#include "CommandBufferGLES2.h"
|
|
|
|
|
2023-08-17 21:48:57 +08:00
|
|
|
#if defined(__ANDROID__)
|
2023-08-17 20:22:24 +08:00
|
|
|
|
|
|
|
# include "platform/GL.h"
|
|
|
|
|
|
|
|
NS_AX_BACKEND_BEGIN
|
|
|
|
|
|
|
|
CommandBufferGLES2::CommandBufferGLES2()
|
|
|
|
{
|
|
|
|
if (glDrawElementsInstancedEXT)
|
|
|
|
glDrawElementsInstanced = glDrawElementsInstancedEXT;
|
|
|
|
else if (glDrawElementsInstancedANGLE)
|
|
|
|
glDrawElementsInstanced = glDrawElementsInstancedANGLE;
|
|
|
|
|
|
|
|
if (glVertexAttribDivisorEXT)
|
|
|
|
glVertexAttribDivisor = glVertexAttribDivisorEXT;
|
|
|
|
else if (glVertexAttribDivisorANGLE)
|
|
|
|
glVertexAttribDivisor = glVertexAttribDivisorANGLE;
|
|
|
|
|
|
|
|
if (!glDrawElementsInstancedEXT)
|
|
|
|
{
|
|
|
|
AXLOG("%s", "Device not support instancing draw");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void CommandBufferGLES2::drawElementsInstanced(PrimitiveType primitiveType,
|
|
|
|
IndexFormat indexType,
|
|
|
|
std::size_t count,
|
|
|
|
std::size_t offset,
|
|
|
|
int instanceCount,
|
|
|
|
bool wireframe)
|
|
|
|
{
|
|
|
|
if (!glDrawElementsInstanced)
|
|
|
|
return;
|
|
|
|
CommandBufferGL::drawElementsInstanced(primitiveType, indexType, count, offset, instanceCount, wireframe);
|
|
|
|
}
|
|
|
|
|
2023-08-17 21:48:57 +08:00
|
|
|
void CommandBufferGLES2::bindInstanceBuffer(ProgramGL* program, bool* usedList) const
|
2023-08-17 20:22:24 +08:00
|
|
|
{
|
|
|
|
|
|
|
|
if (!glDrawElementsInstanced)
|
|
|
|
return;
|
2023-08-17 21:48:57 +08:00
|
|
|
CommandBufferGL::bindInstanceBuffer(program, usedList);
|
2023-08-17 20:22:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_AX_BACKEND_END
|
|
|
|
|
|
|
|
#endif
|