diff --git a/demos/src/SPKCollision.cpp b/demos/src/SPKCollision.cpp index b8f10ff..13bcbf8 100644 --- a/demos/src/SPKCollision.cpp +++ b/demos/src/SPKCollision.cpp @@ -28,8 +28,14 @@ #if defined(WIN32) || defined(_WIN32) #include #endif + +#if defined(__APPLE__) +#include +#include +#else #include #include +#endif #include #include @@ -228,22 +234,29 @@ int main(int argc, char *argv[]) { // Inits SDL SDL_Init(SDL_INIT_VIDEO); - SDL_WM_SetCaption("SPARK Collision 2 Demo",NULL); + + SDL_Window* window = SDL_CreateWindow("SPARK Collision 2 Demo", + SDL_WINDOWPOS_UNDEFINED, + SDL_WINDOWPOS_UNDEFINED, + 0, 0, + SDL_WINDOW_FULLSCREEN_DESKTOP | SDL_WINDOW_OPENGL); + + SDL_GL_CreateContext(window); + SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER,1); - SDL_GL_SetAttribute(SDL_GL_SWAP_CONTROL,0); // vsync + SDL_GL_SetSwapInterval(0); - SDL_SetVideoMode(0,0,32,SDL_OPENGL | SDL_FULLSCREEN); SDL_ShowCursor(0); - - SDL_Surface& screen = *SDL_GetVideoSurface(); + SDL_SetRelativeMouseMode(SDL_TRUE); // Inits openGL - int screenWidth = screen.w; - int screenHeight = screen.h; - float screenRatio = (float)screen.w / (float)screen.h; + int screenWidth; + int screenHeight; + SDL_GetWindowSize(window, &screenWidth, &screenHeight); + float screenRatio = (float)screenWidth / (float)screenHeight; glClearColor(0.0f,0.0f,0.0f,1.0f); - glViewport(0,0,screen.w,screen.h); + glViewport(0,0,screenWidth,screenHeight); glMatrixMode(GL_PROJECTION); glLoadIdentity(); @@ -430,7 +443,7 @@ int main(int argc, char *argv[]) particleSystem->renderParticles(); SPK::GL::GLRenderer::restoreGLStates(); - SDL_GL_SwapBuffers(); + SDL_GL_SwapWindow(window); // Computes delta time clock_t currentTick = clock(); @@ -446,8 +459,9 @@ int main(int argc, char *argv[]) SDL_Quit(); +#ifdef _WIN32 system("pause"); - +#endif return 0; } diff --git a/demos/src/SPKExplosion.cpp b/demos/src/SPKExplosion.cpp index 2ee95bd..b33bf9d 100644 --- a/demos/src/SPKExplosion.cpp +++ b/demos/src/SPKExplosion.cpp @@ -28,8 +28,14 @@ #if defined(WIN32) || defined(_WIN32) #include #endif + +#if defined(__APPLE__) +#include +#include +#else #include #include +#endif #include #include @@ -171,7 +177,7 @@ void drawBoundingBox(const SPK::System& system) } // Renders the scene -void render() +void render(SDL_Window* window) { glEnable(GL_DEPTH_TEST); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); @@ -194,7 +200,7 @@ void render() (*it)->renderParticles(); } - SDL_GL_SwapBuffers(); + SDL_GL_SwapWindow(window); } // Creates the base system and returns its ID @@ -457,24 +463,29 @@ int main(int argc, char *argv[]) // inits SDL SDL_Init(SDL_INIT_VIDEO); - SDL_WM_SetCaption("SPARK Explosion demo",NULL); + + SDL_Window* window = SDL_CreateWindow("SPARK Explosion demo", + SDL_WINDOWPOS_UNDEFINED, + SDL_WINDOWPOS_UNDEFINED, + 0, 0, + SDL_WINDOW_FULLSCREEN_DESKTOP | SDL_WINDOW_OPENGL); + + SDL_GL_CreateContext(window); + SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER,1); // vsync - SDL_GL_SetAttribute(SDL_GL_SWAP_CONTROL,0); + SDL_GL_SetSwapInterval(0); - SDL_SetVideoMode(0,0,32,SDL_OPENGL | SDL_FULLSCREEN); SDL_ShowCursor(0); - - SDL_Surface& screen = *SDL_GetVideoSurface(); + SDL_SetRelativeMouseMode(SDL_TRUE); // inits openGL - screenWidth = screen.w; - screenHeight = screen.h; - screenRatio = (float)screen.w / (float)screen.h; + SDL_GetWindowSize(window, &screenWidth, &screenHeight); + screenRatio = (float)screenWidth / (float)screenHeight; glClearColor(0.0f,0.0f,0.0f,1.0f); - glViewport(0,0,screen.w,screen.h); + glViewport(0,0,screenWidth,screenHeight); // Loads particle texture GLuint textureExplosion; @@ -553,12 +564,12 @@ int main(int argc, char *argv[]) } // Zoom in and out - if (event.type == SDL_MOUSEBUTTONDOWN) + if(event.type == SDL_MOUSEWHEEL) { - if (event.button.button == SDL_BUTTON_WHEELDOWN) - camPosZ = min(10.0f,camPosZ + 0.5f); - if (event.button.button == SDL_BUTTON_WHEELUP) - camPosZ = max(0.5f,camPosZ - 0.5f); + if (event.wheel.y > 0) + camPosZ = fmax(0.5f,camPosZ - 0.5f); + if (event.wheel.y < 0) + camPosZ = fmax(0.5f,camPosZ - 0.5f); } if ((event.type == SDL_KEYDOWN)&&(event.key.keysym.sym == SDLK_F2)) @@ -611,7 +622,7 @@ int main(int argc, char *argv[]) } // Renders scene - render(); + render(window); // Computes delta time int time = SDL_GetTicks(); @@ -633,7 +644,9 @@ int main(int argc, char *argv[]) SDL_Quit(); +#ifdef _WIN32 system("pause"); // Waits for the user to close the console +#endif return 0; -} \ No newline at end of file +} diff --git a/demos/src/SPKFlakes.cpp b/demos/src/SPKFlakes.cpp index e37477a..b7e7065 100644 --- a/demos/src/SPKFlakes.cpp +++ b/demos/src/SPKFlakes.cpp @@ -28,8 +28,14 @@ #if defined(WIN32) || defined(_WIN32) #include #endif + +#if defined(__APPLE__) +#include +#include +#else #include #include +#endif #include #include @@ -110,24 +116,32 @@ int main(int argc, char *argv[]) { // Inits SDL SDL_Init(SDL_INIT_VIDEO); - SDL_WM_SetCaption("SPARK Flakes Demo",NULL); + + SDL_Window* window = SDL_CreateWindow("SPARK Flakes Demo", + SDL_WINDOWPOS_UNDEFINED, + SDL_WINDOWPOS_UNDEFINED, + 0, 0, + SDL_WINDOW_FULLSCREEN_DESKTOP | SDL_WINDOW_OPENGL); + + SDL_GL_CreateContext(window); + + SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER,1); // vsync - SDL_GL_SetAttribute(SDL_GL_SWAP_CONTROL,0); + SDL_GL_SetSwapInterval(0); - SDL_SetVideoMode(0,0,32,SDL_OPENGL | SDL_FULLSCREEN); SDL_ShowCursor(0); - - SDL_Surface& screen = *SDL_GetVideoSurface(); + SDL_SetRelativeMouseMode(SDL_TRUE); // Inits openGL - int screenWidth = screen.w; - int screenHeight = screen.h; - float screenRatio = (float)screen.w / (float)screen.h; + int screenWidth; + int screenHeight; + SDL_GetWindowSize(window, &screenWidth, &screenHeight); + float screenRatio = (float)screenWidth / (float)screenHeight; glClearColor(0.0f,0.0f,0.0f,1.0f); - glViewport(0,0,screen.w,screen.h); + glViewport(0,0,screenWidth,screenHeight); glMatrixMode(GL_PROJECTION); glLoadIdentity(); @@ -298,7 +312,7 @@ int main(int argc, char *argv[]) particleSystem->renderParticles(); SPK::GL::GLRenderer::restoreGLStates(); - SDL_GL_SwapBuffers(); + SDL_GL_SwapWindow(window); // Computes delta time clock_t currentTick = clock(); @@ -315,4 +329,4 @@ int main(int argc, char *argv[]) SDL_Quit(); return 0; -} \ No newline at end of file +} diff --git a/demos/src/SPKTest.cpp b/demos/src/SPKTest.cpp index c74017c..82335d9 100644 --- a/demos/src/SPKTest.cpp +++ b/demos/src/SPKTest.cpp @@ -26,8 +26,14 @@ #if defined(WIN32) || defined(_WIN32) #include #endif + +#if defined(__APPLE__) +#include +#include +#else #include #include +#endif #include #include @@ -157,22 +163,28 @@ void drawBoundingBox(const SPK::System& system) int main(int argc, char *argv[]) { SDL_Init(SDL_INIT_VIDEO); - SDL_WM_SetCaption("SPARK 2 test",NULL); + SDL_Window* window = SDL_CreateWindow("SPARK 2 test", + SDL_WINDOWPOS_UNDEFINED, + SDL_WINDOWPOS_UNDEFINED, + 800, + 600, + SDL_WINDOW_OPENGL); + + SDL_GL_CreateContext(window); + SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER,1); // double buffering // vsync - SDL_GL_SetAttribute(SDL_GL_SWAP_CONTROL,0); + SDL_GL_SetSwapInterval(0); // AA SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS,1); SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES,4); - SDL_SetVideoMode(800,600,32,SDL_OPENGL); - - SDL_Surface& screen = *SDL_GetVideoSurface(); - int screenWidth = screen.w; - int screenHeight = screen.h; - float screenRatio = (float)screen.w / (float)screen.h; + int screenWidth; + int screenHeight; + SDL_GetWindowSize(window, &screenWidth, &screenHeight); + float screenRatio = (float)screenWidth / (float)screenHeight; // Loads particle texture GLuint textureParticle; @@ -286,7 +298,7 @@ int main(int argc, char *argv[]) system->renderParticles(); SPK::GL::GLRenderer::restoreGLStates(); - SDL_GL_SwapBuffers(); + SDL_GL_SwapWindow(window); clock_t currentTick = clock(); deltaTime = (float)(currentTick - frameFPS.back()) / CLOCKS_PER_SEC; @@ -330,7 +342,10 @@ int main(int argc, char *argv[]) SPK_DUMP_MEMORY SDL_Quit(); + +#ifdef _WIN32 std::system("pause"); +#endif return 0; -} \ No newline at end of file +} diff --git a/demos/src/SPKTestIrrlicht.cpp b/demos/src/SPKTestIrrlicht.cpp index 2ac1172..b70b1aa 100644 --- a/demos/src/SPKTestIrrlicht.cpp +++ b/demos/src/SPKTestIrrlicht.cpp @@ -102,7 +102,7 @@ int main(int argc, char *argv[]) SPK::Ref quadRenderer = SPK::IRR::IRRQuadRenderer::create(device); quadRenderer->setBlendMode(SPK::BLEND_MODE_ADD); quadRenderer->enableRenderingOption(SPK::RENDERING_OPTION_DEPTH_WRITE,false); - quadRenderer->setTexture(driver->getTexture("res\\flare.bmp")); + quadRenderer->setTexture(driver->getTexture("res/flare.bmp")); quadRenderer->setTexturingMode(SPK::TEXTURE_MODE_2D); SPK::Ref emitter1 = SPK::RandomEmitter::create(SPK::Point::create()); @@ -165,7 +165,7 @@ int main(int argc, char *argv[]) // Renders scene smgr->drawAll(); - irr::core::stringw infos; infos+="FPS: "; infos+=driver->getFPS(); infos+=" - Nb Particles: "; infos+=system->getNbParticles(); + irr::core::stringw infos; infos+="FPS: "; infos+=driver->getFPS(); infos+=" - Nb Particles: "; infos+=static_cast(system->getNbParticles()); guienv->getBuiltInFont()->draw(infos.c_str(),irr::core::rect(0,0,170,20),irr::video::SColor(255,255,255,255)); driver->endScene(); @@ -177,4 +177,4 @@ int main(int argc, char *argv[]) SPK_DUMP_MEMORY return 0; -} \ No newline at end of file +} diff --git a/demos/src/SPKTestIrrlicht_Controllers.cpp b/demos/src/SPKTestIrrlicht_Controllers.cpp index a90208b..2296982 100644 --- a/demos/src/SPKTestIrrlicht_Controllers.cpp +++ b/demos/src/SPKTestIrrlicht_Controllers.cpp @@ -164,7 +164,7 @@ int main(int argc, char *argv[]) SPK::Ref quadRenderer = SPK::IRR::IRRQuadRenderer::create(device); quadRenderer->setBlendMode(SPK::BLEND_MODE_ADD); quadRenderer->enableRenderingOption(SPK::RENDERING_OPTION_DEPTH_WRITE,false); - quadRenderer->setTexture(driver->getTexture("res\\flare.bmp")); + quadRenderer->setTexture(driver->getTexture("res/flare.bmp")); quadRenderer->setTexturingMode(SPK::TEXTURE_MODE_2D); SPK::Ref emitpt = SPK::Point::create(); @@ -247,7 +247,7 @@ int main(int argc, char *argv[]) // Renders scene smgr->drawAll(); - irr::core::stringw infos; infos+="FPS: "; infos+=driver->getFPS(); infos+=" - Nb Particles: "; infos+=system->getNbParticles(); + irr::core::stringw infos; infos+="FPS: "; infos+=driver->getFPS(); infos+=" - Nb Particles: "; infos+=static_cast(system->getNbParticles()); guienv->getBuiltInFont()->draw(infos.c_str(),irr::core::rect(0,0,170,20),irr::video::SColor(255,255,255,255)); driver->endScene();