A library for high-performance, modern 2D graphics with SDL written in C.

Related tags

Game sdl-gpu
Overview

SDL_gpu, a library for making hardware-accelerated 2D graphics easy. by Jonathan Dearborn

Travis-ci Status Appveyor Status

SDL_gpu is licensed under the terms of the MIT License. See LICENSE.txt for details of the usage license granted to you for this code.

FEATURES

  • High performance (it automatically collects and submits batches instead of separate draw commands for each sprite and redundant state changes)
  • Shader API
  • Arbitrary geometry rendering (triangles)
  • Can be integrated with explicit OpenGL calls (mixed 2D and 3D)
  • Full blend state control
  • Built-in primitive shapes (points, lines, tris, rects, ellipses, polygons, even arcs)
  • Uses a style familiar to SDL 1.2 users
  • Compatible with either SDL 1.2 or 2.0
  • Loads BMP, TGA, and PNG files via stb-image
  • Rotates and scales about the center of images, making reasoning about the resulting corner coordinates more obvious (adjustable via anchor settings)

HELP OUT

SDL_gpu is free and open source! You can help either by contributing a pull request, filling out a bug report, sending an email, or give me a chance to put more time into it by donating:

paypal

Anything you can do to help is really appreciated!

LATEST SOURCE

SDL_gpu is hosted on Github (https://github.com/grimfang4/sdl-gpu). You can check out the latest version of the source code with Git:

git clone https://github.com/grimfang4/sdl-gpu.git sdl-gpu

DEPENDENCIES

SDL 1.2 or SDL 2.0 (www.libsdl.org)
A rendering backend
	Currently implemented:
		OpenGL 1.1, 2.0, 3.0, 4.0
		OpenGL ES 1.1, 2.0, 3.0

BUILDING

Automated Windows build status and prebuilt library files can be found at the Appveyor page:

Appveyor Status

Automated build status for Linux and MacOS can be found at the project page on Travis CI:

Build Status

SDL_gpu uses CMake (www.cmake.org) to coordinate the library build process. CMake is available as a GUI program or on the command line.

For Linux/UNIX systems, run CMake in the base directory:

cmake -G "Unix Makefiles"
make
sudo make install

For Linux/UNIX systems, changing the default installation directory can be done like so:

cmake -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX=/usr

For Windows systems, you can use cmake-gui and select appropriate options in there (warning: cmake-gui is messy!).

INCLUDING / LINKING

Add the include for SDL_gpu.h to your sources. Link to SDL2_gpu (libSDL2_gpu.a) or SDL_gpu (if you use the old SDL 1.2).

FULL DOCUMENTATION

Documentation is automatically generated with Doxygen (http://sourceforge.net/projects/doxygen).

Pre-generated documentation can be found on the Github.io page: https://grimfang4.github.io/sdl-gpu/

CONVERSION

SDL_gpu can be used to replace the SDL_Render subsystem of SDL2. SDL_gpu uses GPU_Target to represent a render target (a render destination, e.g. the screen) instead of an SDL_Renderer object. SDL_gpu also uses GPU_Image as a texture container (a render source) instead of SDL_Texture.

Here is a list of most of the comparable functions:

SDL_CreateWindow() : Either use GPU_SetInitWindow() or replace with GPU_Init()
SDL_CreateRenderer() : GPU_Init()
SDL_LoadBMP() : GPU_LoadImage() or GPU_LoadSurface()
SDL_CreateTextureFromSurface() : GPU_CopyImageFromSurface()
SDL_SetRenderDrawColor() : Pass color into rendering function (e.g. GPU_ClearRGBA(), GPU_Line())
SDL_RenderClear() : GPU_Clear(), GPU_ClearRGBA()
SDL_QueryTexture() : image->w, image->h
SDL_RenderCopy() : GPU_Blit() or GPU_BlitRect()
SDL_RenderPresent() : GPU_Flip()
SDL_DestroyTexture() : GPU_FreeImage()
SDL_DestroyRenderer() : GPU_FreeTarget() (but don't free the screen target yourself)

SDL_RenderDrawPoint() : GPU_Pixel()
SDL_RenderDrawLine() : GPU_Line()
SDL_RenderDrawRect() : GPU_Rectangle()
SDL_RenderFillRect() : GPU_RectangleFilled()
SDL_RenderCopyEx() : GPU_BlitRotate() or GPU_BlitScale() or GPU_BlitTransform()
SDL_SetRenderDrawBlendMode() : GPU_SetShapeBlendMode()
SDL_SetTextureBlendMode() : GPU_SetBlendMode()
SDL_SetTextureColorMod() : GPU_SetRGBA() or GPU_SetColor()
SDL_SetTextureAlphaMod() : GPU_SetRGBA() or GPU_SetColor()
SDL_UpdateTexture() : GPU_UpdateImage() or GPU_UpdateImageBytes()
SDL_RenderSetClipRect() : GPU_SetClip() or GPU_SetClipRect()
SDL_RenderReadPixels() : GPU_CopySurfaceFromTarget() or GPU_CopySurfaceFromImage()
SDL_RenderSetViewport() : GPU_SetViewport()
SDL_SetRenderTarget() : GPU_LoadTarget()

Some SDL functions use a rectangular region passed as an SDL_Rect. SDL_gpu uses floating point coordinates for subpixel precision, so you may have to use GPU_Rect for some SDL_gpu functions.

Comments
  • What else would be good for v0.12.0?

    What else would be good for v0.12.0?

    There are already a lot of good changes and new features in 0.11.0 that will be released as 0.12.0, but here are some more possibilities:

    Direct VBO support GLES 3 renderer GL 4 renderer

    question 
    opened by grimfang4 27
  • GPU_CopyImage Target Memory Leak

    GPU_CopyImage Target Memory Leak

    After copying an image with GPU_CopyImage and then changing its target, such as with GPU_LoadTarget, there is a memory leak. gpu_copy_image_pixels_only creates a target for the newly copied image but does not free it. The user is not told that the copied image has a target that needs to be freed before creating a new one.

    opened by DiegoAce 12
  • is there win32/x86 support? (couldn't find any info anywhere)

    is there win32/x86 support? (couldn't find any info anywhere)

    Hi,

    It has been a big hassle to make it work on windows (with visual studio 2019) , hell I didn't even make it work, I just found a project that used sdl_gpu with an sln file in the repository and am testing that, but I saw there is only x64 compiler options, so I was wondering is it due sdl_gpu not supporting x86?

    thank you

    opened by idbxy 10
  • Cygwin support

    Cygwin support

    I'm trying to build the library on Cygwin:

    mkdir build-cygwin
    cd build-cygwin
    cmake -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX="$(PREFIX)" -DSDL_gpu_DEFAULT_BUILD_DEMOS=OFF ..
    make
    

    This fails with errors about CALLBACK macro not being defined. It's defined in bundled GLEW/gl.h only if both _WIN32 and __CYGWIN__ macros are present, so I added this switch to cmake commandline:

     -DCMAKE_C_FLAGS="-D_WIN32"
    

    The library now compiles, but linking step fails:

    [  9%] Linking C shared library cygSDL2_gpu.dll
    cd /cygdrive/c/Users/User/.../sdl-gpu/build-cygwin/src && /usr/bin/cmake.exe -E cmake_link_script CMakeFiles/SDL_gpu_shared.dir/link.txt --verbose=1
    /usr/bin/cc  -D_WIN32   -shared -Wl,--enable-auto-import -o cygSDL2_gpu.dll -Wl,--out-implib,libSDL2_gpu.dll.a -Wl,--major-image-version,0,--minor-image-version,0 CMakeFiles/SDL_gpu_shared.dir/externals/glew/glew.c.o 
    [skipped]
    CMakeFiles/SDL_gpu_shared.dir/externals/stb_image_write/stb_image_write.c.o /cygdrive/c/Users/User/.../libroot/cygwin/lib/libSDL2.dll.a -Wl,-Bstatic -lm -Wl,-Bdynamic -lGL 
    CMakeFiles/SDL_gpu_shared.dir/externals/glew/glew.c.o:glew.c:(.text+0x4ff): undefined reference to `__imp_wglGetProcAddress'
    CMakeFiles/SDL_gpu_shared.dir/externals/glew/glew.c.o:glew.c:(.text+0x4ff): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `__imp_wglGetProcAddress'
    CMakeFiles/SDL_gpu_shared.dir/externals/glew/glew.c.o:glew.c:(.text+0x537): undefined reference to `__imp_wglGetProcAddress'
    CMakeFiles/SDL_gpu_shared.dir/externals/glew/glew.c.o:glew.c:(.text+0x537): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `__imp_wglGetProcAddress'
    

    I've tried adding -lopengl32 to linker flags, but this didn't change anything. Any pointers are appreciated! I'm trying to link against native OpenGL, not the Cygwin's X11 OpenGL.

    opened by zmeyc 10
  • GPU_Init - transparent window background?

    GPU_Init - transparent window background?

    Is there a way to have a transparent main opengl window background that one can see what is behind the window? I checked the flags for GPU_Init but didn't found something regarding this.

    I'm using Ubuntu 20.04 and have a project which currently already creates a native transparent xlib/xwindow opengl enabled and use SDL_CreateWindowFrom to be able to use SDL2 with it but now I want to integrate sdl-gpu. So I see two possibilities:

    1. Passing gl context of this xwindow to sdl-gpu which should be used by this library.
    2. Let do transparent background via GPU_Init / sdl-gpu without xwindow (should be preferred).

    I would like to use option two because currently I have to manage events in XPending/XNextEvent but I would prefer to use SDLs SDL_PollEvent How can I manage this with sdl-gpu?

    opened by meuchel 9
  • Differentiate naming of static and shared libraries

    Differentiate naming of static and shared libraries

    I'm building my project for 'Release' in vs2015. I'm using the libs generated from building SDL_gpu_shared for 'Release.' Using the latest SDL_gpu commit, building my project for 'Release' gets a lot of unresolved external errors for OpenGL functions. I must link opengl32.lib for my project to build. This is not the case when using the May 14th commit 7c3d8fa612465a452fe9baf4463db0fb422746c7. I do not need to link opengl32.lib in my project for the older commit. I'm not sure if this is desired behavior, but I wanted to let you know of the change.

    opened by DiegoAce 8
  • Fix camera matrix multiplication order (again?)

    Fix camera matrix multiplication order (again?)

    Commit https://github.com/grimfang4/sdl-gpu/commit/d4a4b39e7defb2ff9728373d5f204d1dbe486a90 breaks our existing code, because the "fixed" order in that PR fails to scale the translate component of our MV matrices. So after the transforms we end up with a MVP matrix that looks something like this:

    | | | | | | ---- | ---- | ---- | ---- | | tiny | 0 | 0 | 0 | | 0 | tiny | 0 | 0 | | 0 | 0 | tiny | 0 | | huge | huge | 0 | 1 |

    ... meaning all of our content is presumably rendered perfectly, but hundreds of screen-widths away.

    The issue doesn't occur in the old version, or when we reverse the order of the matrix multiplication, as in this PR. Not sure if the old version was causing bugs, but we certainly get a blank screen on the latest master without the change in this PR.

    opened by ephemer 7
  • Added Polygon2, patched get_complete_color_mod

    Added Polygon2, patched get_complete_color_mod

    Added GPU_Polygon2 function which draws optionally open polygons using line strips. Patched get_complete_color_mod to allow image = NULL.

    Please accept my humble contribution.

    opened by kirilledelman 7
  • Unable to initialize a renderer on an external window

    Unable to initialize a renderer on an external window

    SDL2 allows you to call SDL_CreateWindowFrom() on an existing GUI object's window handle, and then create a renderer on it. This technique doesn't appear to migrate well to SDL_GPU.

    • Create a Windows form
    • Create a control on it and obtain its HWND
    • Create an SDL_Window on that HWND with SDL_CreateWindowFrom.
    • Call SDL_GetWindowID on this window and GPU_SetInitWindow on the result
    • Call GPU_Init

    Expected: A working renderer Observed: GPU_Init fails. Could not initialize.

    A bit of digging reveals that this happens because GLEW could not retrieve the version string, because SDL_GPU failed to initialize the first GL context before calling glewInit. After doing this manually on my end, GPU_Init now throws an access violation in the call to applyTargetCamera because GPU_GetContextTarget returns null.

    As near as I can tell, this is returning null because earlier on, in the call to MakeCurrent, target->context->context is null and so the required initialization never takes place. I haven't been able to determine yet what's missing that's causing target->context->context to be null at this point.

    opened by masonwheeler 7
  • Drawing a circle show a ellipse when draw the circle in a image target and blit it to another target

    Drawing a circle show a ellipse when draw the circle in a image target and blit it to another target

    image

    ~/sdl-gpu/tests/render-target/main.c:

    #include "SDL.h"
    #include "SDL_gpu.h"
    #include <math.h>
    #include "compat.h"
    #include "common.h"
    #include "demo-font.h"
    
    
    int main(int argc, char* argv[])
    {
    	GPU_Target* screen;
    
    	screen = initialize_demo(argc, argv, 800, 600);
    	if(screen == NULL)
    		return 1;
    
    	{
    		GPU_Image* image2;
    		GPU_Image* image3;
    		SDL_Surface* font_surface;
    		DemoFont* font;
    		GPU_Image* mode1image;
    		GPU_Image* mode2image;
    		SDL_Color circleColor = { 255, 0, 0, 128 };
    		SDL_Color circleColor2 = { 0, 0, 255, 128 };
    		Uint32 startTime;
    		long frameCount;
    		const Uint8* keystates;
    		int mode;
    		int x;
    		int y;
    		Uint8 done;
    		SDL_Event event;
    
    		image2 = GPU_LoadImage("data/test2.bmp");
    		if (image2 == NULL)
    			return 2;
    
    		image3 = GPU_LoadImage("data/test.bmp");
    		if (image3 == NULL)
    			return 3;
    
    		font_surface = GPU_LoadSurface("data/comic14.png");
    		font = FONT_Alloc(font_surface);
    		if(font == NULL)
            {
                GPU_LogError("Failed to load font.\n");
                return 4;
            }
    		GPU_SetRGB(font->image, 255, 0, 0);
    		SDL_FreeSurface(font_surface);
    
    		mode1image = GPU_CreateImage(300, 300, GPU_FORMAT_RGBA);
    		if (mode1image == NULL)
    			return 5;
    
    		mode2image = GPU_CreateImage(400, 400, GPU_FORMAT_RGBA);
    		if (mode2image == NULL)
    			return 6;
    
    		GPU_LoadTarget(mode1image);
    		GPU_LoadTarget(mode2image);
    
            int height = 400;
    		GPU_Image* light = GPU_CreateImage(height, height, GPU_FORMAT_RGBA);
            GPU_SetBlending(light, true);
    		GPU_LoadTarget(light);
            GPU_ClearRGBA(light->target, 0, 0, 0, 128);
    
            float centerX = height / 2.0f;
            float centerY = height / 2.0f;
            float radius = height/ 2.0f;
            SDL_Color color = {255,255,0, 128};
            GPU_CircleFilled(light->target, centerX, centerY, radius, color);
    
    		startTime = SDL_GetTicks();
    		frameCount = 0;
    
    		keystates = SDL_GetKeyState(NULL);
    
    		mode = 0;
    		x = 0;
    		y = 0;
    
    		done = 0;
    		while (!done)
    		{
    			while (SDL_PollEvent(&event))
    			{
    				if (event.type == SDL_QUIT)
    					done = 1;
    				else if (event.type == SDL_KEYDOWN)
    				{
    					if (event.key.keysym.sym == SDLK_ESCAPE)
    						done = 1;
    					else if (event.key.keysym.sym == SDLK_SPACE)
    					{
    						mode++;
    						if (mode > 1)
    							mode = 0;
    					}
    					else if (event.key.keysym.sym == SDLK_f)
    						GPU_SetFullscreen(!GPU_GetFullscreen(), 0);
    					else if (event.key.keysym.sym == SDLK_g)
    						GPU_SetFullscreen(!GPU_GetFullscreen(), 1);
    					else if (event.key.keysym.sym == SDLK_1)
    						GPU_UnsetVirtualResolution(screen);
    					else if (event.key.keysym.sym == SDLK_2)
    						GPU_SetVirtualResolution(screen, 1200, 800);
    				}
    			}
    
    			if (keystates[KEY_UP])
    				y -= 1;
    			else if (keystates[KEY_DOWN])
    				y += 1;
    			if (keystates[KEY_LEFT])
    				x -= 1;
    			else if (keystates[KEY_RIGHT])
    				x += 1;
    
    			GPU_Clear(screen);
    
    			if (mode == 0)
    			{
    				GPU_Target* mode1target = mode1image->target;
    				SDL_Color red = { 255, 0, 0, 255 };
    
    				GPU_ClearRGBA(mode1target, 0, 255, 0, 255);
    				GPU_Blit(image3, NULL, mode1target, image3->w / 2, image3->h / 2);
    
    
    				//GPU_BlitScale(image2, NULL, mode1target, mode1target->w/2, mode1target->h/2, 0.7f, 0.7f);
    				//GPU_BlitScale(image2, NULL, mode1target, x, y, 0.7f, 0.7f);
    
    				GPU_BlitTransform(image2, NULL, mode1target, x, y, 360 * sin(SDL_GetTicks() / 1000.0f), 0.7f*sin(SDL_GetTicks() / 2000.0f), 0.7f*sin(SDL_GetTicks() / 2000.0f));
    
    				//GPU_Line(mode1target, 0, 0, mode1target->w, mode1target->h, red);
    				//GPU_CircleFilled(mode1target, 70, 70, 20, circleColor);
    
                    GPU_Rect srcRect = GPU_MakeRect(0, 0, light->w, light->h);
                    GPU_Rect destRect = GPU_MakeRect(0, 0, light->w, light->h);
                    GPU_BlitRect(light, &srcRect, mode1target, &destRect);
    
    				GPU_Blit(mode1image, NULL, screen, mode1image->w / 2 + 50, mode1image->h / 2 + 50);
    				GPU_BlitScale(mode1image, NULL, screen, mode1image->w * 2 + 50, mode1image->h / 2 + 50, 0.7f, 0.7f);
    
    				GPU_CircleFilled(screen, 50 + 70, 50 + 70, 20, circleColor2);
    
    				GPU_Blit(image2, NULL, screen, screen->w - image3->w - image2->w / 2, screen->h - image2->h / 2);
    				GPU_Blit(image3, NULL, screen, screen->w - image3->w / 2, screen->h - image3->h / 2);
    			}
    			else if (mode == 1)
    			{
    				GPU_Target* mode2target = mode2image->target;
    				SDL_Color red = { 255, 0, 0, 255 };
    				SDL_Color blue = { 0, 0, 255, 255 };
    
    				GPU_ClearRGBA(mode2target, 255, 255, 255, 255);
    
    
    				GPU_Line(mode2target, 0, 0, mode2target->w, mode2target->h, red);
    				GPU_Line(mode2target, 0, mode2target->h, mode2target->w, 0, red);
    				GPU_TriFilled(mode2target, mode2target->w / 2, mode2target->h / 2 + 10, mode2target->w / 2 - 10, mode2target->h / 2 + 20, mode2target->w / 2 + 10, mode2target->h / 2 + 20, red);
    
    				GPU_Blit(image2, NULL, mode2target, x, y);
    
    
    
    				GPU_Line(screen, 0, 0, screen->w, screen->h, blue);
    				GPU_Line(screen, 0, screen->h, screen->w, 0, blue);
    
    				GPU_Blit(mode2image, NULL, screen, mode2image->w / 2, mode2image->h / 2);
    			}
    
    			FONT_Draw(font, screen, 20, 20, "Testing");
    
    			GPU_Flip(screen);
    
    			frameCount++;
    			if (frameCount % 500 == 0)
    			{
    				printf("Average FPS: %.2f\n", 1000.0f*frameCount / (SDL_GetTicks() - startTime));
    				printf("x,y: (%d, %d)\n", x, y);
    			}
    		}
    
    		printf("Average FPS: %.2f\n", 1000.0f*frameCount / (SDL_GetTicks() - startTime));
    
    		FONT_Free(font);
    		GPU_FreeImage(mode2image);
    		GPU_FreeImage(mode1image);
    	}
    
    	GPU_Quit();
    
    	return 0;
    }
    
    opened by ryancheung 6
  • Expose texture handles with a function

    Expose texture handles with a function

    Since SDL_gpu does my image loading, I was wondering if a convenient GetHandle function could be added to get a texture handle without me depending on an IMAGE_DATA structure cast.

    opened by Wizzard033 6
  • Memory leak in GPU_Flip()

    Memory leak in GPU_Flip()

    Hi, when I was trying your demosI saw an increase in RAM usage per frame and I realized that the problem was caused by GPU_Flip().

    I am using the latest version (0.12) and the SDL version is 2.24.2.

    opened by EuropaYou 0
  • Fixing rendering of primitives

    Fixing rendering of primitives

    Should resolve issues addressed in https://github.com/grimfang4/sdl-gpu/issues/220

    • GPU_Pixel now renders on the center of the pixel
    • GPU_Line renders from the center of pixels
    • GPU_Rectangle borders are now rendered inside the rectangle instead of being centered on the bounds

    If any of these behavioral changes are unwanted, maybe we can introduce a way to allow the users to decide on the behavior. E.g. enums/booleans, new functions, etc.

    Here's an illustration of the changes made to GPU_Rectangle:

    image

    • The outer black rectangle represents the outer edges of the pixels
    • The inner red rectangle represents the inner edges of the pixels
    • The numbers are the indices of the vertexes of the triangles used to draw the rectangle sides
    opened by avahe-kellenberger 0
  • Failed to create GL context on mac when attempting to initalize

    Failed to create GL context on mac when attempting to initalize

    Hello, Im trying to use SDL2_gpu to draw a few primitive shapes but I'm running into some issues. Mainly that I just get a blank screen with the draw color and none of the shapes. I turned on debugging with GPU_SetDebugLevel(GPU_DEBUG_LEVEL_MAX); and I get:

    GPU_CreateTargetFromWindow: BACKEND ERROR - Failed to create GL context.
    GPU_InitRendererByID: BACKEND ERROR - Renderer OpenGL 4 failed to initialize properly
    

    I think this has something todo with me needing to add:

    find_package(OpenGL REQUIRED)
    include_directories( ${OPENGL_INCLUDE_DIRS}  ${GLUT_INCLUDE_DIRS} )
    target_link_libraries(flame_engine ${OPENGL_LIBRARIES} ${GLUT_LIBRARY} )
    

    to my cmake file to avoid getting a bunch of symbol errors about OpenGL not being found. Does anybody know what might be causing this? Full CMake:

    cmake_minimum_required(VERSION 3.22)
    project(flame_engine)
    
    set(CMAKE_CXX_STANDARD 14)
    
    link_directories(/opt/homebrew/Cellar/sdl2/2.0.22/lib/)
    
    add_executable(flame_engine main.cpp)
    
    find_package(OpenGL REQUIRED)
    include_directories( ${OPENGL_INCLUDE_DIRS}  ${GLUT_INCLUDE_DIRS} )
    target_link_libraries(flame_engine ${OPENGL_LIBRARIES} ${GLUT_LIBRARY} )
    
    target_link_libraries(flame_engine SDL2)
    target_link_libraries(flame_engine SDL2_gpu)
    
    target_include_directories(flame_engine
            PRIVATE
            /opt/homebrew/Cellar/sdl2/2.0.22/include/)
    

    System: macOS Monterey MacBook Pro 14 inch (M1 Max) With 32GB of memory

    opened by maxall41 0
  • Feature request: PrimitiveBatch with subbuffers

    Feature request: PrimitiveBatch with subbuffers

    I'm not sure how much work it would be to add this feature but it's something I had on my mind.

    The way PrimitiveBatch currently works is by taking a single pointer to an interleaved buffer.

    I would like if PrimitiveBatch also had a way to take multiple pointers to distinct subbuffers of packed data instead (implemented with glBufferSubData).

    If this is the current PrimitiveBatch API

    DECLSPEC void SDLCALL
    GPU_PrimitiveBatch(
        GPU_Image* image,
        GPU_Target* target,
        GPU_PrimitiveEnum primitive_type,
        unsigned int num_vertices,
        float* values,
        unsigned int num_indices,
        unsigned int* indices,
        GPU_BatchFlagEnum flags);
    

    This is what I imagine this new API could look like

    typedef struct GPU_SubBuffers {
           float *x_values;
           float *y_values;
           float *z_values;
           float *s_values;
           float *t_values;
           float *r_values;
           float *g_values;
           float *b_values;
           float *a_values;
           uint8_t *r8_values;
           uint8_t *g8_values;
           uint8_t *b8_values;
           uint8_t *a8_values;
    } GPU_SubBuffers;
    
    DECLSPEC void SDLCALL
    GPU_PrimitiveBatchSub(
        GPU_Image* image,
        GPU_Target* target,
        GPU_PrimitiveEnum primitive_type,
        unsigned int num_vertices,
        const GPU_SubBuffers *values,
        unsigned int num_indices,
        unsigned int* indices,
        GPU_BatchFlagEnum flags);
    
    opened by aganm 0
  • Image stops rendering in window after closing another

    Image stops rendering in window after closing another

    I'm running into an issue where one window stops showing blitted images after closing another one. What's strange is that this only happens when the first opened window is closed that the second's images disappear, and not the other way around.

    To close windows, I'm calling SDL_DestroyWindow and GPU_FreeTarget on the target. And I've made sure to call GPU_MakeCurrent on the correct window before loading each GPU_Image. The loaded matrix appears to be unaffected at this point. Images are rendered with GPU_BlitRectX, and it appears that the parameters I'm passing are unchanged.

    (Also the secondary window is opened using SDL_CreateWindow and GPU_CreateTargetFromWindow, although I've tried opening both this way after creating a dummy window with GPU_InitRenderer, but the problem persists.)

    I'm out of ideas. Would anyone have any clue what might be causing this? Thank you.

    opened by tadashibashi 4
Releases(v0.12.0)
Owner
Jonathan Dearborn
Jonathan Dearborn
Minecraft 4k: decompiled, translated to C using SDL for graphics and input, and improved upon

M4KC Minecraft 4K - C Rewrite For those who don't know, Minecraft 4K was a stripped down version of Minecraft submitted by Notch to the Java 4K Game P

Sasha Koshka 38 Oct 9, 2022
High Performance 3D Game Engine, with a high emphasis on Rendering

Electro High Performance 3D Game Engine, with a high emphasis on Rendering MainFeatures Rendering PBR Renderer (Cook–Torrance GGX) IBL (Image Based Li

Surge 45 Sep 27, 2022
A simple game framework written in C++ using SDL

SGF SGF (Simple Game Framework) is, as the name implies; a very simple and easy to use game framework written in C++ using SDL. Currently the project

Cam K. 1 Nov 4, 2021
A very simple 2D game engine written in C++, using SDL and Lua.

2D Game Engine written in C++, SDL, and Lua. This is a simple 2D game engine written in C++ and using SDL and Lua scripting

Gustavo Pezzi 22 Oct 31, 2022
A Binary Clock. Written 3 different ways. C and SDL, Python and PyGame, Python and PyGame Zero.

Super Clock A Binary Clock. Written 3 different ways. Python with PyGame Zero, Python with PyGame and C with SDL2. Time is displayed in 3 groups of 8

null 3 Dec 8, 2021
Simple Directmedia Layer, 1.2 branch ... ***DEPRECATED***, please use https://github.com/libsdl-org/SDL for new projects!

DEPRECATED The 1.2 branch of SDL is deprecated. While we occasionally collect fixes in revision control, there has not been a formal release since 201

Simple Directmedia Layer 50 Nov 22, 2022
Cross-platform version of Heboris C7EX using a hardware-accelerated SDL 2.0 renderer

Heboris C7EX - unofficial version (YGS2K EX) This version contains the source code for Heboris C7EX. It requires a C compiler, SDL 2.0, SDL 2.0 mixer,

Brandon McGriff 14 Nov 27, 2022
sdl based game framework

Hallow Engine an sdl-based game framework Install Procedure Install SDL2[https://libsdl.org] and take the .h(header) files from the include/ folder, t

Hallow - The Game Framework 6 Nov 24, 2021
Raycaster demo in SDL, inspired by 3DSage

raycastersdl -Coded following 3DSage's tutorial. Part 1 -> https://www.youtube.com/watch?v=gYRrGTC7GtA Remeber to install SDL2 libraries first: sudo a

Velorek1 1 Oct 30, 2021
Simple DirectMedia Layer (SDL) 1.2 for Symbian S60v1 devices such as the Nokia N-Gage.

SDL 1.2 Even though SDL 1.2 is outdated and officially no longer supported, this is an attempt to get it running on Symbian S60v1 devices such as the

N-Gage SDK. 4 Apr 4, 2022
A demo test game made from scratch using C++ and SDL

Dethroning Table of contents About This Game How to Compile the game About This Game This is a Cross-Platform Game Demo. How to Compile the game Run t

Haider Mirza 1 Jan 21, 2022
A lightweight game engine written in modern C++

Halley Game Engine A lightweight game engine written in C++17. It has been used to ship Wargroove, a turn-based strategy game, on Windows, Mac (experi

Rodrigo Braz Monteiro 3.2k Nov 23, 2022
📽 Highly Optimized Graphics Math (glm) for C

?? OpenGL Mathematics (glm) for C Documentation Almost all functions (inline versions) and parameters are documented inside the corresponding headers.

Recep Aslantas 1.5k Nov 20, 2022
Mach is a game engine & graphics toolkit for the future.

Mach engine ⚠️ Project status: in-development ⚠️ Under heavy development, not ready for use currently. Follow @machengine on Twitter for updates. Zero

Hexops 1.4k Nov 25, 2022
Engine-3D is a 3D-Graphics Renderer built from scratch in C++

Engine3D Engine-3D is a 3D-Graphics Renderer built from scratch in C++, as an Undergraduate Computer Engineering Project for 5th Semester, assigned by

Chirag Lamsal 3 Oct 24, 2022
Care race game built in c++ with sfml. this project is done in 3rd semester of csit for demonstration of computer graphics.

Car Race Car race is simple game which has been built by using SFML in c++ implementing concepts of Computer Graphics for project Work of 3rd semester

subash kc 4 Dec 18, 2021
A minecraft clone built in c++ opengl for the purpose of prefecting graphics programming skills.

LearnOpenGL - CLion This is a project template for OpenGL development with JetBrains CLion IDE. It was created mainly for LearnOpenGL tutorials. Inclu

Jeremy Dellock 1 Dec 28, 2021
VTK is an open-source software system for image processing, 3D graphics, volume rendering and visualization

Introduction VTK is an open-source software system for image processing, 3D graphics, volume rendering and visualization. VTK includes many advanced a

Kitware, Inc. 2k Nov 28, 2022
Yet another approach to developing a personal 3D graphics engine. Windows + Direct3D 12.

RegEngine Yet another approach to developing a personal 3D graphics engine. Windows + Direct3D 12. Work in progress... Nothing to see here. I just ren

Adam Sawicki 21 Nov 3, 2022