int TW_CALL TwEventSDL(const void *sdlEvent, unsigned char majorVersion, unsigned char minorVersion) { if (majorVersion < 1 || (majorVersion == 1 && minorVersion < 2)) { static const char *g_ErrBadSDLVersion = "Unsupported SDL version"; TwSetLastError(g_ErrBadSDLVersion); return 0; } else if (majorVersion == 1 && minorVersion == 2) return TwEventSDL12(sdlEvent); else if( majorVersion == 1 && minorVersion == 3 ) return TwEventSDL13(sdlEvent); // will probably not work for version > 1.3, but give it a chance else return TwEventSDL20(sdlEvent); }
// TwEventSDL returns zero if msg has not been handled or the SDL version // is not supported, and a non-zero value if it has been handled by the // AntTweakBar library. int TW_CALL TwEventSDL(const void *sdlEvent, unsigned char majorVersion, unsigned char minorVersion) { if (majorVersion < 1 || (majorVersion == 1 && minorVersion < 2)) { static const char *g_ErrBadSDLVersion = "Unsupported SDL version"; TwSetLastError(g_ErrBadSDLVersion); return 0; } else if (majorVersion == 1 && minorVersion == 2) return TwEventSDL12(sdlEvent); else if( majorVersion==1 && minorVersion==3 ) return TwEventSDL13(sdlEvent); else return TwEventSDL20(sdlEvent); }
void Engine::RenderEngine() { SDL_GetMouseState(&x, &y); if (SDL_PollEvent(&(EngineEvent)) != 0) { int uiEvent = TwEventSDL20(&(EngineEvent)); if (!uiEvent) { if (EngineEvent.type == SDL_QUIT) { } //If a mouse button was pressed if (EngineEvent.button.button == SDL_BUTTON_LEFT) { mfRot[0] = rotRef.y - y; mfRot[1] = rotRef.x - x; mfRot[2] = 0; glMatrixMode(GL_MODELVIEW); glLoadMatrixd(EngineRenderer.ObjectOrientation); glRotated(mfRot[0], 1.0f, 0, 0); glRotated(mfRot[1], 0, 1.0f, 0); glRotated(mfRot[2], 0, 0, 1.0f); glGetDoublev(GL_MODELVIEW_MATRIX, EngineRenderer.ObjectOrientation); glLoadIdentity(); } } } rotRef.x = x; rotRef.y = y; glClearColor(0.0f, 0.0f, 0.0f, 1.0f); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); if (enableRendering) RenderTexture(EngineRenderer.ObjectOrientation, RenderLayerCount, this->OCT); TwDraw(); SDL_GL_SwapWindow(this->EngineRenderer.EngineWindow); }