From 4daba0efa85862b1309525b5e6cf6a554825714a Mon Sep 17 00:00:00 2001 From: kumar8600 Date: Mon, 16 Mar 2015 12:56:14 +0900 Subject: [PATCH 1/3] Syntax highlight synopsis code in README.md --- README.md | 92 ++++++++++++++++++++++++++++--------------------------- 1 file changed, 47 insertions(+), 45 deletions(-) diff --git a/README.md b/README.md index 5fb3561..6db14b5 100644 --- a/README.md +++ b/README.md @@ -7,66 +7,68 @@ This library provides C++11 bindings/wrapper for SDL2 and satellite libraries. ## Synopsis ## - try { - using namespace SDL2pp; +```c++ +try { + using namespace SDL2pp; - // Init SDL; will be automatically deinitialized when the object is destroyed - SDL sdl(SDL_INIT_VIDEO); + // Init SDL; will be automatically deinitialized when the object is destroyed + SDL sdl(SDL_INIT_VIDEO); - // Likewise, init SDL_ttf library - SDLTTF sdl_ttf; + // Likewise, init SDL_ttf library + SDLTTF sdl_ttf; - // Straightforward wrappers around corresponding SDL2 objects - // These take full care of proper object destruction and error checking - Window window("libSDL2pp demo", - SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, - 640, 480, SDL_WINDOW_RESIZABLE); - Renderer renderer(window, -1, SDL_RENDERER_ACCELERATED); - Texture sprite1(renderer, SDL_PIXELFORMAT_ARGB8888, - SDL_TEXTUREACCESS_STATIC, 16, 16); - Texture sprite2(renderer, "sprite.png"); // SDL_image support + // Straightforward wrappers around corresponding SDL2 objects + // These take full care of proper object destruction and error checking + Window window("libSDL2pp demo", + SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, + 640, 480, SDL_WINDOW_RESIZABLE); + Renderer renderer(window, -1, SDL_RENDERER_ACCELERATED); + Texture sprite1(renderer, SDL_PIXELFORMAT_ARGB8888, + SDL_TEXTUREACCESS_STATIC, 16, 16); + Texture sprite2(renderer, "sprite.png"); // SDL_image support - Font font("Vera.ttf", 20); // SDL_ttf font + Font font("Vera.ttf", 20); // SDL_ttf font - // Create texture from surface containing text rendered by SDL_ttf - Texture text(renderer, font.RenderText_Solid("Hello, world!", - SDL_Color{255, 255, 255, 255})); + // Create texture from surface containing text rendered by SDL_ttf + Texture text(renderer, font.RenderText_Solid("Hello, world!", + SDL_Color{255, 255, 255, 255})); - unsigned char pixels[16 * 16 * 4]; + unsigned char pixels[16 * 16 * 4]; - // Note proper constructor for Rect - sprite1.Update(Rect(0, 0, 16, 16), pixels, 16 * 4); + // Note proper constructor for Rect + sprite1.Update(Rect(0, 0, 16, 16), pixels, 16 * 4); - // Most setter methods are chainable - renderer.SetLogicalSize(640, 480).SetRenderColor(0, 16, 32).Clear(); + // Most setter methods are chainable + renderer.SetLogicalSize(640, 480).SetRenderColor(0, 16, 32).Clear(); - // Also note a safe way to specify null rects and points - renderer.Copy(sprite1, NullOpt, NullOpt); + // Also note a safe way to specify null rects and points + renderer.Copy(sprite1, NullOpt, NullOpt); - // There are multiple convenient ways to construct e.g. a Rect; - // Objects provide extensive set of getters - renderer.Copy(text, NullOpt, Rect(Point(0, 0), text.GetSize())); + // There are multiple convenient ways to construct e.g. a Rect; + // Objects provide extensive set of getters + renderer.Copy(text, NullOpt, Rect(Point(0, 0), text.GetSize())); - // Copy() is overloaded, providing access to both SDL_RenderCopy and SDL_RenderCopyEx - renderer.Copy(sprite2, NullOpt, NullOpt, 45.0); + // Copy() is overloaded, providing access to both SDL_RenderCopy and SDL_RenderCopyEx + renderer.Copy(sprite2, NullOpt, NullOpt, 45.0); - renderer.Present(); + renderer.Present(); - // You can still access wrapped C SDL types - SDL_Renderer* sdl_renderer = renderer.Get(); + // You can still access wrapped C SDL types + SDL_Renderer* sdl_renderer = renderer.Get(); - // Of course, C SDL2 API is still perfectly valid - SDL_Delay(2000); + // Of course, C SDL2 API is still perfectly valid + SDL_Delay(2000); - // All SDL objects are released at this point or if an error occurs - } catch (SDL2pp::Exception& e) { - // Exception stores SDL_GetError() result and name of function which failed - std::cerr << "Error in: " << e.GetSDLFunction() << std::endl; - std::cerr << " Reason: " << e.GetSDLError() << std::endl; - } catch (std::exception& e) { - // This also works (e.g. "SDL_Init failed: No available video device") - std::cerr << e.what() << std::endl; - } + // All SDL objects are released at this point or if an error occurs +} catch (SDL2pp::Exception& e) { + // Exception stores SDL_GetError() result and name of function which failed + std::cerr << "Error in: " << e.GetSDLFunction() << std::endl; + std::cerr << " Reason: " << e.GetSDLError() << std::endl; +} catch (std::exception& e) { + // This also works (e.g. "SDL_Init failed: No available video device") + std::cerr << e.what() << std::endl; +} +``` ## Features ## From 325dc8abf4349297dea0f4b767389f3a9eb671b0 Mon Sep 17 00:00:00 2001 From: Dmitry Marakasov Date: Mon, 16 Mar 2015 22:44:36 +0300 Subject: [PATCH 2/3] Syntax highlight cmake code as well --- README.md | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 6db14b5..06c77ca 100644 --- a/README.md +++ b/README.md @@ -167,19 +167,23 @@ still recommended). Just place the library into dedicated directory in your project (for example, extlib/libSDL2pp) and add - SET(SDL2PP_WITH_IMAGE ON) # if you need SDL_image support - SET(SDL2PP_WITH_TTF ON) # if you need SDL_ttf support - ADD_SUBDIRECTORY(extlib/libSDL2pp) +```cmake +SET(SDL2PP_WITH_IMAGE ON) # if you need SDL_image support +SET(SDL2PP_WITH_TTF ON) # if you need SDL_ttf support +ADD_SUBDIRECTORY(extlib/libSDL2pp) +``` into your core CMakeLists.txt. This will act as similar to what FIND_PACKAGE usually does, and will provide ${SDL2PP_INCLUDE_DIRS} and ${SDL2PP_LIBRARIES} variables for your project. You will then be able to use them as usual: - INCLUDE_DIRECTORIES(${SDL2PP_INCLUDE_DIRS}) +```cmake +INCLUDE_DIRECTORIES(${SDL2PP_INCLUDE_DIRS}) - ADD_EXECUTABLE(mytarget ...) - TARGET_LINK_LIBRARIES(mytarget ${SDL2PP_LIBRARIES}) +ADD_EXECUTABLE(mytarget ...) +TARGET_LINK_LIBRARIES(mytarget ${SDL2PP_LIBRARIES}) +``` if bundled, libSDL2pp does not build examples and becomes a static library, providing required SDL2 includes/libs in the mentioned From d88370442fa8a7337328d34e1f2ba06c4d5c58b1 Mon Sep 17 00:00:00 2001 From: Dmitry Marakasov Date: Mon, 16 Mar 2015 23:32:40 +0300 Subject: [PATCH 3/3] Preprocess README.md for doxygen --- Doxyfile.in | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Doxyfile.in b/Doxyfile.in index 82d11d7..0b03349 100644 --- a/Doxyfile.in +++ b/Doxyfile.in @@ -859,7 +859,7 @@ IMAGE_PATH = # code is scanned, but not when the output code is generated. If lines are added # or removed, the anchors will not be placed correctly. -INPUT_FILTER = +INPUT_FILTER = "sed -e '/^\[!\[/d' -e '/^```/,/^```/ s|^| &|' -e '/^ ```/ d'" # The FILTER_PATTERNS tag can be used to specify filters on a per file pattern # basis. Doxygen will compare the file name with each pattern and apply the @@ -868,7 +868,7 @@ INPUT_FILTER = # filters are used. If the FILTER_PATTERNS tag is empty or if none of the # patterns match the file name, INPUT_FILTER is applied. -FILTER_PATTERNS = +FILTER_PATTERNS = *.md # If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using # INPUT_FILTER ) will also be used to filter the input files that are used for