Posts

Showing posts with the label sdl

SDL memory leak

SDL memory leak So I tryed to make something on SDL, but on first programm I have memory lear (idk leak or not) so there is some code: #include <stdio.h> #include <SDL.h> #include <SDL_image.h> #include <SDL_ttf.h> #define SCREENSIZEX 180 #define SCREENSIZEY 300 SDL_Window* mainwind = NULL; SDL_Renderer* rend = NULL; TTF_Font* Usefont = NULL; int main(int argc, char* argv) { SDL_Init(SDL_INIT_EVERYTHING); Uint32 windowflags; windowflags = SDL_WINDOW_SHOWN; mainwind = SDL_CreateWindow("FooBar", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, SCREENSIZEX, SCREENSIZEY, windowflags); rend = SDL_CreateRenderer(mainwind, -1, SDL_RENDERER_ACCELERATED); SDL_SetRenderDrawColor(rend, 255, 255, 255, 255); int imgFlags = IMG_INIT_PNG; IMG_Init(imgFlags); TTF_Init(); U...

SDL layered rendering system

SDL layered rendering system I would like help with building a layered rendering system in SDL2. I have a first layer containing a map of Paris with its roads. I need to draw a line between two points on this map - the problem occurs when the before state of this line does not disappear. I need to draw this line over the map and keep this. How do I make s a system to save the map state whithout any overlaid lines drawn, and such that frame by frame I can show the map with the new state of the line overlaid on top of this? Buffering. Render each layer to its own buffer then blit the buffers to the final render surface preserving transparency and perhaps using an alternative blending mode. You may take advantage of optimizations for 2D scrolling if present in the available hardware (I'm not familiar with the SDL API for that, though). – Dai Jul 1 at 8:01 ...

cpp - SDL_JOYHATMOTION different when using Windows?

cpp - SDL_JOYHATMOTION different when using Windows? I'm using SDL2 in my programm. The Gamepad is initialised using: SDL_Joystick* Pad1 = NULL; Pad1 = SDL_JoystickOpen( 0 ); In my Event-Handling function, i included this thing: switch( event.type ){ //Button-Event, as an example: case SDL_JOYBUTTONDOWN: //printf("Button: %d", event.jbutton.button, " "); if(event.jbutton.button==ControllP1.MoveLeftButton) MoveLeft=true; //lot of other cases case SDL_JOYHATMOTION: if(event.jhat.value==SDL_HAT_UP){MoveUp=true;MoveLeft=false; MoveRight=false; MoveDown=false;} if(event.jhat.value==SDL_HAT_DOWN){MoveDown=true;MoveUp=false; MoveLeft=false; MoveRight=false;} if(event.jhat.value==SDL_HAT_LEFT){MoveLeft=true; MoveDown=false; MoveUp=false; MoveRight=false;} if(event.jhat.value==SDL_HAT_RIGHT){MoveRight=true;MoveDown=false; MoveUp=false; MoveLeft=false; } if(event.jhat.va...