Git Product home page Git Product logo

sdl_gfx's People

Contributors

ferzkopp avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

sdl_gfx's Issues

Where can I contribute to the code?

Hi,

I've searched here, on SourceForge and your site, but in none of the repos could I find an official way to submit a patch to SDL2_gfx. I've implemented a few basic gradient drawing primitives, and I think it might be useful to add them to the graphics primitives library. Where should I start if I'd like to contribute?

Thanks, Árpád

Unnecesary call to SDL_RenderPresent() in texturedPolygonMT()

Hi. I'm unsure if this is an issue or if I'm using it wrong, but there is a call to SDL_RenderPresent() at the end of texturedPolygonMT() (gfxPrimitives, latest Feb 2017 release). This makes it impossible to use, as the renderer will render the polygons drawn with this function one by one, rather than rendering the whole frame at once.

Function rotozoomSurfaceXY() incorrect vertical factor behavior.

The function rotozoomSurfaceXY() appears to be using the zoomx parameter for both horizontal and vertical scaling factor, incorrectly resulting in a behavior similar to rotozoomSurface(). The correct behavior, according to the documentation, is to use zoomx as horizontal scaling factor and zoomy as vertical scaling factor.

I tested the behavior with SDL_gfx version 2.0.25.

Here is a test code (an image named "sample.bmp" is required):

/* When a non-zero angle is specified, the zoomy factor
 * is ignored and zoomx is used as both horizontal and
 * vertical scaling factor
 * An image named "sample.bmp" is required. */

#include <stdio.h>
#include <stdlib.h>

#include <SDL/SDL.h>
#include <SDL/SDL_rotozoom.h>

int main(void)
{
	SDL_Init(SDL_INIT_VIDEO);
	SDL_Surface* window = SDL_SetVideoMode(800, 600, 0, 0);
	SDL_Surface* image = SDL_LoadBMP("sample.bmp");
	SDL_Rect pos = {window->w/2, window->h/2};

	int running = 1, flip=0;
	float angle=0, zoomx=1, zoomy=1;

	SDL_Event event;
	while(running)
	{
		if(SDL_PollEvent(&event))
		{
			if(event.type == SDL_QUIT)
				running = 0;

			if(event.type == SDL_KEYDOWN)
			{
				switch(event.key.keysym.sym)
				{
					case SDLK_UP:    pos.y -= 10; break;
					case SDLK_DOWN:  pos.y += 10; break;
					case SDLK_LEFT:  pos.x -= 10; break;
					case SDLK_RIGHT: pos.x += 10; break;

					case SDLK_r: angle += 1; break;
					case SDLK_t: angle -= 1; break;

					case SDLK_x: zoomx += 0.5; break;
					case SDLK_z: zoomx -= 0.5; break;

					case SDLK_q: zoomy += 0.5; break;
					case SDLK_a: zoomy -= 0.5; break;

					case SDLK_f: flip = 1; break;
					case SDLK_g: flip = 2; break;
					case SDLK_h: flip = 0; break;

					default: break;
				}
			}
		}

		SDL_FillRect(window, NULL, 0);
		SDL_Surface* transformedSurface = rotozoomSurfaceXY(
				image,
				angle,
				(flip==1? -zoomx : zoomx),
				(flip==2? -zoomy : zoomy),
				SMOOTHING_OFF);
		SDL_BlitSurface(transformedSurface, NULL, window, &pos);
		SDL_FreeSurface(transformedSurface);
		SDL_Flip(window);
	}

	return EXIT_SUCCESS;
}

Compiled with:
gcc main.c -o "test" `sdl-config --cflags --libs` -lSDL_gfx

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.