emulator opengl: implement glGetString
Added rcGetGLString token to renderControl to query a GL string constant from the current context from the host. Implement glGetString functinality in EGL so that the string value can be cached in the context structure and also implementation can be shared between GLESv1 and GLESv2. Also, fixed clientAPI context initialization check in eglMakeCurrent. The check was for the previously bounded context instead for the newly bounded context. Change-Id: I41c0b4ad462c9ad5bd5c66719b41509bb1b7a947
This commit is contained in:
committed by
David 'Digit' Turner
parent
5b675210ed
commit
1ef706f96f
@@ -17,6 +17,9 @@
|
||||
#include "FrameBuffer.h"
|
||||
#include "FBConfig.h"
|
||||
#include "EGLDispatch.h"
|
||||
#include "GLDispatch.h"
|
||||
#include "GL2Dispatch.h"
|
||||
#include "ThreadInfo.h"
|
||||
|
||||
static const GLint rendererVersion = 1;
|
||||
|
||||
@@ -58,6 +61,38 @@ static EGLint rcQueryEGLString(EGLenum name, void* buffer, EGLint bufferSize)
|
||||
return len;
|
||||
}
|
||||
|
||||
static EGLint rcGetGLString(EGLenum name, void* buffer, EGLint bufferSize)
|
||||
{
|
||||
RenderThreadInfo *tInfo = getRenderThreadInfo();
|
||||
if (!tInfo || !tInfo->currContext.Ptr()) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
const char *str = NULL;
|
||||
#ifdef WITH_GLES2
|
||||
if (tInfo->currContext->isGL2()) {
|
||||
str = (const char *)s_gl2.glGetString(name);
|
||||
}
|
||||
else {
|
||||
#endif
|
||||
str = (const char *)s_gl.glGetString(name);
|
||||
#ifdef WITH_GLES2
|
||||
}
|
||||
#endif
|
||||
|
||||
if (!str) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int len = strlen(str) + 1;
|
||||
if (!buffer || len > bufferSize) {
|
||||
return -len;
|
||||
}
|
||||
|
||||
strcpy((char *)buffer, str);
|
||||
return len;
|
||||
}
|
||||
|
||||
static EGLint rcGetNumConfigs(uint32_t* numAttribs)
|
||||
{
|
||||
if (numAttribs) {
|
||||
@@ -279,6 +314,7 @@ void initRenderControlContext(renderControl_decoder_context_t *dec)
|
||||
dec->set_rcGetRendererVersion(rcGetRendererVersion);
|
||||
dec->set_rcGetEGLVersion(rcGetEGLVersion);
|
||||
dec->set_rcQueryEGLString(rcQueryEGLString);
|
||||
dec->set_rcGetGLString(rcGetGLString);
|
||||
dec->set_rcGetNumConfigs(rcGetNumConfigs);
|
||||
dec->set_rcGetConfigs(rcGetConfigs);
|
||||
dec->set_rcChooseConfig(rcChooseConfig);
|
||||
|
||||
Reference in New Issue
Block a user