Hi,
Is it possible to integrate SFML Events to Cocos2d-x OpenGL window? I can't get it to work because I don't understand enough of OpenGL to initialize SFML. Can I somehow initialize SFML window with already created Cocos2d-x OpenGL window? I'm only interested in receiving Events from SFML to use as input in my game.
This is the main game loop in Cocos2d-x:
int Application::run()
{
PVRFrameEnableControlWindow(false);
// Main message loop:
MSG msg;
LARGE_INTEGER nFreq;
LARGE_INTEGER nLast;
LARGE_INTEGER nNow;
QueryPerformanceFrequency(&nFreq);
QueryPerformanceCounter(&nLast);
// Initialize instance and cocos2d.
if (!applicationDidFinishLaunching())
{
return 0;
}
EGLView* pMainWnd = EGLView::sharedOpenGLView();
pMainWnd->centerWindow();
ShowWindow(pMainWnd->getHWnd(), SW_SHOW);
while (1)
{
if (! PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
{
// Get current time tick.
QueryPerformanceCounter(&nNow);
//CCLog("MAIN LOOP: %lld",nNow.QuadPart);
// If it's the time to draw next frame, draw it, else sleep a while.
if (nNow.QuadPart - nLast.QuadPart > _animationInterval.QuadPart)
{
nLast.QuadPart = nNow.QuadPart;
Director::sharedDirector()->mainLoop();
}
else
{
Sleep(0);
}
continue;
}
if (WM_QUIT == msg.message)
{
// Quit message loop.
break;
}
// Deal with windows message.
if (! _accelTable || ! TranslateAccelerator(msg.hwnd, _accelTable, &msg))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
return (int) msg.wParam;
}
I tried to create the sf::RenderWindow like this:
sf::RenderWindow r_wnd;
r_wnd.create(pMainWnd->getHWnd());
But this only creates a black screen.
Any ideas?
Thanks.