{"id":13534856,"url":"https://github.com/mika314/sdlpp","last_synced_at":"2025-08-20T04:31:40.981Z","repository":{"id":37082979,"uuid":"79884368","full_name":"mika314/sdlpp","owner":"mika314","description":"C++ wrapper for SDL2","archived":false,"fork":false,"pushed_at":"2024-10-27T03:42:37.000Z","size":70,"stargazers_count":51,"open_issues_count":1,"forks_count":10,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-12-07T15:12:01.313Z","etag":null,"topics":["c-plus-plus","c-plus-plus-11","c-plus-plus-14","c-plus-plus-17","c-plus-plus11","cplusplus","cplusplus-11","cplusplus-14","cpp","cpp11","cpp14","gamedev","gamedev-library","header-only","sdl","sdl2","wrapper"],"latest_commit_sha":null,"homepage":null,"language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mika314.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-01-24T06:14:36.000Z","updated_at":"2024-10-27T03:42:40.000Z","dependencies_parsed_at":"2022-08-18T23:21:50.066Z","dependency_job_id":"7c4f9f1e-91da-409e-85c5-5e6270075338","html_url":"https://github.com/mika314/sdlpp","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mika314%2Fsdlpp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mika314%2Fsdlpp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mika314%2Fsdlpp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mika314%2Fsdlpp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mika314","download_url":"https://codeload.github.com/mika314/sdlpp/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":230394228,"owners_count":18218707,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["c-plus-plus","c-plus-plus-11","c-plus-plus-14","c-plus-plus-17","c-plus-plus11","cplusplus","cplusplus-11","cplusplus-14","cpp","cpp11","cpp14","gamedev","gamedev-library","header-only","sdl","sdl2","wrapper"],"created_at":"2024-08-01T08:00:44.044Z","updated_at":"2024-12-19T07:05:54.883Z","avatar_url":"https://github.com/mika314.png","language":"C++","readme":"[![Build Status](https://travis-ci.org/mika314/sdlpp.svg?branch=master)](https://travis-ci.org/mika314/sdlpp)\n\n# sdlpp\nHeader only C++ wrapper for SDL2.\n\n[![C++ Wrapper for SDL2](https://img.youtube.com/vi/fD-bCQ20NRo/0.jpg)](https://www.youtube.com/watch?v=fD-bCQ20NRo)\n\nThe library leverages RAII and error handling with exceptions.\n\nOptional support for SDL2_gfx's graphic primitives is available. To turn it on, uncomment the\n`#define USE_SDLGFX` directive in `sdlpp.hpp`.\n\nSDL2 code\n```c++\n  int res = SDL_Init(SDL_INIT_EVERYTHING);\n  if (res \u003c 0)\n  {\n    // error handling\n  }\n  // your code\n  SDL_Quit();\n```\n\nsdlpp code\n```c++\n  try\n  {\n    sdl::Init init(SDL_INIT_EVERYTHING);\n    // your code\n  }\n  catch (sdl::Error \u0026e)\n  {\n    // error handling\n  }\n```\n\nAlso I mapped functions to methods.\n\n## Window\n|Method|SDL2 function|\n|------|-------------|\n|ctor|SDL_CreateWindow|\n|dtor|SDL_DestroyWindow|\n|glCreateContext|SDL_GL_CreateContext|\n|glGetDrawableSize|SDL_GL_GetDrawableSize|\n|glMakeCurrent|SDL_GL_MakeCurrent|\n|glSwap|SDL_GL_SwapWindow|\n|getBrightness|SDL_GetWindowBrightness|\n|getData|SDL_GetWindowData|\n|getDisplayIndex|SDL_GetWindowDisplayIndex|\n|getDisplayMode|SDL_GetWindowDisplayMode|\n|getFlags|SDL_GetWindowFlags|\n|getGammaRamp|SDL_GetWindowGammaRamp|\n|getGrab|SDL_GetWindowGrab|\n|getID|SDL_GetWindowID|\n|getMaximumSize|SDL_GetWindowMaximumSize|\n|getMinimumSize|SDL_GetWindowMinimumSize|\n|getPixelFormat|SDL_GetWindowPixelFormat|\n|getPosition|SDL_GetWindowPosition|\n|getSize|SDL_GetWindowSize|\n|getSurface|SDL_GetWindowSurface|\n|getTitle|SDL_GetWindowTitle|\n|hide|SDL_HideWindow|\n|maximize|SDL_MaximizeWindow|\n|minimize|SDL_MinimizeWindow|\n|raise|SDL_RaiseWindow|\n|restore|SDL_RestoreWindow|\n|setBordered|SDL_SetWindowBordered|\n|setBrightness|SDL_SetWindowBrightness|\n|setData|SDL_SetWindowData|\n|setDisplayMode|SDL_SetWindowDisplayMode|\n|setFullscreen|SDL_SetWindowFullscreen|\n|setGammaRamp|SDL_SetWindowGammaRamp|\n|setGrab|SDL_SetWindowGrab|\n|setHitTest|SDL_SetWindowHitTest|\n|setIcon|SDL_SetWindowIcon|\n|setMaximumSize|SDL_SetWindowMaximumSize|\n|setMinimumSize|SDL_SetWindowMinimumSize|\n|setPosition|SDL_SetWindowPosition|\n|setSize|SDL_SetWindowSize|\n|setTitle|SDL_SetWindowTitle|\n|show|SDL_ShowWindow|\n|updateSurface|SDL_UpdateWindowSurface|\n|updateSurfaceRects|SDL_UpdateWindowSurfaceRects|\n\n## Renderer\n|Method|SDL2 function|\n|------|-------------|\n|ctor|SDL_CreateRenderer|\n|dtor|SDL_DestroyRenderer|\n|getDrawBlendMode|SDL_GetRenderDrawBlendMode|\n|getDrawColor|SDL_GetRenderDrawColor|\n|getDriverInfo|SDL_GetRenderDriverInfo|\n|getTarget|SDL_GetRenderTarget|\n|getInfo|SDL_GetRendererInfo|\n|getOutputSize|SDL_GetRendererOutputSize|\n|clear|SDL_RenderClear|\n|copy|SDL_RenderCopy|\n|copyEx|SDL_RenderCopyEx|\n|drawLine|SDL_RenderDrawLine|\n|drawLines|SDL_RenderDrawLines|\n|drawPoint|SDL_RenderDrawPoint|\n|drawPoints|SDL_RenderDrawPoints|\n|drawRect|SDL_RenderDrawRect|\n|drawRects|SDL_RenderDrawRects|\n|fillRect|SDL_RenderFillRect|\n|fillRects|SDL_RenderFillRects|\n|getClipRect|SDL_RenderGetClipRect|\n|getLogicalSize|SDL_RenderGetLogicalSize|\n|getScale|SDL_RenderGetScale|\n|getViewport|SDL_RenderGetViewport|\n|isClipEnabled|SDL_RenderIsClipEnabled|\n|present|SDL_RenderPresent|\n|readPixels|SDL_RenderReadPixels|\n|setClipRect|SDL_RenderSetClipRect|\n|setLogicalSize|SDL_RenderSetLogicalSize|\n|setScale|SDL_RenderSetScale|\n|setViewport|SDL_RenderSetViewport|\n|targetSupported|SDL_RenderTargetSupported|\n|setDrawBlendMode|SDL_SetRenderDrawBlendMode|\n|setDrawColor|SDL_SetRenderDrawColor|\n|setTarget|SDL_SetRenderTarget|\n\n## Renderer if SDL2_gfx-support is enabled\n|Method|SDL2_gfx function|\n|------|-----------------|\n|pixelColor|pixelColor|\n|pixelRGBA|pixelRGBA|\n|hlineColor|hlineColor|\n|hlineRGBA|hlineRGBA|\n|vlineColor|vlineColor|\n|vlineRGBA|vlineRGBA|\n|rectangleColor|rectangleColor|\n|rectangleRGBA|rectangleRGBA|\n|roundedRectangleColor|roundedRectangleColor|\n|roundedRectangleRGBA|roundedRectangleRGBA|\n|boxColor|boxColor|\n|boxRGBA|boxRGBA|\n|roundedBoxColor|roundedBoxColor|\n|roundedBoxRGBA|roundedBoxRGBA|\n|lineColor|lineColor|\n|lineRGBA|lineRGBA|\n|aalineColor|aalineColor|\n|aalineRGBA|aalineRGBA|\n|thickLineColor|thickLineColor|\n|thickLineRGBA|thickLineRGBA|\n|circleColor|circleColor|\n|circleRGBA|circleRGBA|\n|arcColor|arcColor|\n|arcRGBA|arcRGBA|\n|aacircleColor|aacircleColor|\n|aacircleRGBA|aacircleRGBA|\n|filledCircleColor|filledCircleColor|\n|filledCircleRGBA|filledCircleRGBA|\n|ellipseColor|ellipseColor|\n|ellipseRGBA|ellipseRGBA|\n|aaellipseColor|aaellipseColor|\n|aaellipseRGBA|aaellipseRGBA|\n|filledEllipseColor|filledEllipseColor|\n|filledEllipseRGBA|filledEllipseRGBA|\n|pieColor|pieColor|\n|pieRGBA|pieRGBA|\n|filledPieColor|filledPieColor|\n|filledPieRGBA|filledPieRGBA|\n|trigonColor|trigonColor|\n|trigonRGBA|trigonRGBA|\n|aatrigonColor|aatrigonColor|\n|aatrigonRGBA|aatrigonRGBA|\n|filledTrigonColor|filledTrigonColor|\n|filledTrigonRGBA|filledTrigonRGBA|\n|polygonColor|polygonColor|\n|polygonRGBA|polygonRGBA|\n|aapolygonColor|aapolygonColor|\n|aapolygonRGBA|aapolygonRGBA|\n|filledPolygonColor|filledPolygonColor|\n|filledPolygonRGBA|filledPolygonRGBA|\n|texturedPolygon|texturedPolygon|\n|bezierColor|bezierColor|\n|bezierRGBA|bezierRGBA|\n|characterColor|characterColor|\n|characterRGBA|characterRGBA|\n|stringColor|stringColor|\n|stringRGBA|stringRGBA|\n\n## Texture\n|Method|SDL2 function|\n|------|-------------|\n|ctor|SDL_CreateTexture|\n|ctor|SDL_CreateTextureFromSurface|\n|dtor|SDL_DestroyRenderer|\n|glBind|SDL_GL_BindTexture|\n|glUnbind|SDL_GL_UnbindTexture|\n|getAlphaMod|SDL_GetTextureAlphaMod|\n|getBlendMode|SDL_GetTextureBlendMode|\n|getColorMod|SDL_GetTextureColorMod|\n|lock|SDL_LockTexture|\n|query|SDL_QueryTexture|\n|setAlphaMod|SDL_SetTextureAlphaMod|\n|setBlendMode|SDL_SetTextureBlendMode|\n|setColorMod|SDL_SetTextureColorMod|\n|unlock|SDL_UnlockTexture|\n|update|SDL_UpdateTexture|\n|updateYuv|SDL_UpdateYUVTexture|\n\n## Surface\n|Method|SDL2 function|\n|------|-------------|\n|ctor|SDL_CreateRGBSurface|\n|ctor|SDL_LoadBMP_RW|\n|ctor|SDL_LoadBMP|\n|ctor|SDL_ConvertSurface|\n|dtor|SDL_FreeSurface|\n|setPalette|SDL_SetSurfacePalette|\n|lock \\*|SDL_LockSurface|\n|unlock \\*|SDL_UnlockSurface|\n|setColorKey|SDL_SetColorKey|\n|getColorKey|SDL_GetColorKey|\n|setColorMode|SDL_SetSurfaceColorMod|\n|getColorMode|SDL_GetSurfaceColorMod|\n|setClipRect|SDL_SetClipRect|\n|getClipRect|SDL_GetClipRect|\n|fillRect|SDL_FillRect|\n|fillRects|SDL_FillRects|\n|blit|SDL_BlitSurface|\n|softStretch|SDL_SoftStretch|\n|blitScaled|SDL_BlitScaled|\n\n\\* Consider `sdl::Surface::Lock` RAII object instead.\n\n## Audio\n|Method|SDL2 function|\n|------|-------------|\n|ctor|SDL_OpenAudioDevice*|\n|dtor|SDL_CloseAudioDevice|\n|clearQueued|SDL_ClearQueuedAudio|\n|getStatus|SDL_GetAudioDeviceStatus|\n|getQueuedSize|SDL_GetQueuedAudioSize|\n|lock|SDL_LockAudioDevice|\n|pause|SDL_PauseAudioDevice|\n|queue|SDL_QueueAudio|\n|unlock|SDL_UnlockAudioDevice|\n\n*)\n```c++\nAudio(const char *device,\n          bool iscapture,\n          const SDL_AudioSpec *desired,\n          SDL_AudioSpec *obtained,\n          int allowed_changes,\n          std::function\u003cvoid(Uint8 *stream, int len)\u003e callback = nullptr);\n```\n\n## Event Handling\nExample code:\n```c++\n  auto done = false;\n  sdl::EventHandler e;\n  e.quit = [\u0026done](const SDL_QuitEvent \u0026)\n    {\n      done = true;\n    };\n  while (!done)\n  {\n    while (e.poll()) {}\n    // rendering\n  }\n\n```\n|SDL_Event::type|sdl::EventHandler member variable|\n|---------------|----------------------|\n|SDL_AUDIODEVICEADDED|audioDeviceAdded|\n|SDL_AUDIODEVICEREMOVED|audioDeviceRemoved|\n|SDL_CONTROLLERAXISMOTION|controllerAxisMotion|\n|SDL_CONTROLLERBUTTONDOWN|controllerButtonDown|\n|SDL_CONTROLLERBUTTONUP|controllerButtonUp|\n|SDL_CONTROLLERDEVICEADDED|controllerDeviceAdded|\n|SDL_CONTROLLERDEVICEREMOVED|controllerDeviceRemoved|\n|SDL_CONTROLLERDEVICEREMAPPED|controllerDeviceRemapped|\n|SDL_DOLLARGESTURE|dollarGesture|\n|SDL_DOLLARRECORD|dollarRecord|\n|SDL_DROPFILE|dropFile|\n|SDL_FINGERMOTION|fingerMotion|\n|SDL_FINGERDOWN|fingerDown|\n|SDL_FINGERUP|fingerUp|\n|SDL_KEYDOWN|keyDown|\n|SDL_KEYUP|keyUp|\n|SDL_JOYAXISMOTION|joyAxisMotion|\n|SDL_JOYBALLMOTION|joyBallMotion|\n|SDL_JOYHATMOTION|joyHatMotion|\n|SDL_JOYBUTTONDOWN|joyButtonDown|\n|SDL_JOYBUTTONUP|joyButtonUp|\n|SDL_JOYDEVICEADDED|joyDeviceAdded|\n|SDL_JOYDEVICEREMOVED|joyDeviceRemoved|\n|SDL_MOUSEMOTION|mouseMotion|\n|SDL_MOUSEBUTTONDOWN|mouseButtonDown|\n|SDL_MOUSEBUTTONUP|mouseButtonUp|\n|SDL_MOUSEWHEEL|mouseWheel|\n|SDL_MULTIGESTURE|multiGesture|\n|SDL_QUIT|quit|\n|SDL_SYSWMEVENT|sysWmEvent|\n|SDL_TEXTEDITING|textEditing|\n|SDL_TEXTINPUT|textInput|\n|SDL_USEREVENT|userEvent|\n|SDL_WINDOWEVENT|windowEvent|\n\nFunction poll() internally calls SDL_PollEvent and function wait() calls SDL_WaintEvent() or SDL_WaitEventTimeout().\n\n## Examples\n\nGo in the example directory examples/pong or examples/starfield and run make to build.\n","funding_links":[],"categories":["Bindings"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmika314%2Fsdlpp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmika314%2Fsdlpp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmika314%2Fsdlpp/lists"}