I write a little demo, not completed, but already can run, when I run into bSuccess = m_pRenderHAL->InitHAL(GL::HALInitParams()); a GL error came out,
Assert: GL error before GraphicsDeviceImmediate::Initialize (0x502).
what's the reason, is some setting not correct?
namespace SF = Scaleform;
using namespace Scaleform;
using namespace Render;
using namespace GFx;
void initHAL()
{
SF::SysAllocMalloc a;
SF::GFx::System gfxInit(&a);
SingleThreadCommandQueue* queue = new SingleThreadCommandQueue;
//m_pCommandQueue = queue;
Ptr<GL::HAL> m_pRenderHAL = *new GL::HAL(queue);
//assert(m_pRenderHAL != NULL);
queue-> pHAL = m_pRenderHAL;
bool bSuccess;
//GLenum error = glGetError();
bSuccess = m_pRenderHAL->InitHAL(GL::HALInitParams());
assert(bSuccess == true);
}
int main()
{
initHAL();
}
Under normal operation, Scaleform should not generate any OpenGL errors. When you call GL::HAL::InitHAL
, it checks for any existing GL error codes. This assert is warning you that an error has occurred in the current context before using Scaleform. As eluded to in your sample, you can simply call glGetError() before calling InitHAL
(and subsequently HAL::BeginScene
/HAL::Display
before rendering each scene) to avoid this assert.
However, Scaleform also expects that a GL context is initialized properly on the current thread - in your example, there is no code showing this. If it isn't initialized propertly, it's likely the call to glGetError
(internally in Scaleform) is failing. If this is the case, you will need to set a current context before calling GL::HAL::InitHAL
.