Skip to main content
5 votes
Accepted

SDL2 mouse motion event keeps occurring

You're not checking the return value of SDL_PollEvent to see if there's a new event, which means that regardless of whether there is an event to handle, you're ...
wizzwizz4's user avatar
  • 165
3 votes
Accepted

SDL2 dragging a sprite with mouse

"Pressed" and "Released" are usually treated as events, rather than states. (ie. "Became Pressed" rather than "Is Still Pressed") So processing a drag can be as simple as: When the Pressed event ...
DMGregory's user avatar
  • 139k
3 votes

SDL_RenderPresent is writing over the previous frame

To get past this, you might be able to use a texture buffer which you render to before rendering to the window. This is accomplished with creating a texture with ...
Ray C's user avatar
  • 273
3 votes
Accepted

C++ SDL Vector of Textures Storing NULL Objects

From what I can tell, the SDL_Texture* taken from textureList and stored in tx is NULL, and ...
Quentin's user avatar
  • 1,188
3 votes

SDL/C++ Keyboard Input

You're mixing two methods of input detection SDL provides. There is the event API which lets you get input via events, and there is the keyboard state API, which allows you to get the state of the ...
Gaxio's user avatar
  • 51
3 votes
Accepted

OpenGL draw functions and multi-threading. How they work together?

It is definitely possible and useful to make your rendering multithreaded, but it wouldn't work the way you've proposed. Keep in mind that with OpenGL, you're drawing all the objects for a frame into ...
user1118321's user avatar
  • 2,642
3 votes
Accepted

C++ OpenGL texture warping

This looks like it could be an export issue. Some 3d modelling programs allow multiple uv co-ordinates per vertex. So if this is the case, you can map the three faces adjacent to that vertex with up ...
Jay's user avatar
  • 820
3 votes
Accepted

Should I bother with SDL_WaitEvent?

That's an interesting problem, I handle my SDL events like this, while (SDL_PollEvent(&e) != 0) { // handle events here } This will handle all the SDL ...
Tonia Sanzo's user avatar
3 votes

SDL2 memory leak

The problem is that you're calling TTF_OpenFont every frame, and you only need to load a font once. TTF_OpenFont is a very ...
Sciborg's user avatar
  • 604
3 votes
Accepted

Trouble with Transparent Pixel Blending in PNG

The problem was in a different part of my code where a new texture is created to represent a line of text collaged from a character map texture. I wasn't calling ...
AntumDeluge's user avatar
2 votes

How do I handle a lot of big textures for a visual novel?

Don't load all textures at once. Only load those you need for the current scene, and release the textures when the scene is over. Visual novels are slow-paced games, so a few milliseconds of load-time ...
Philipp's user avatar
  • 122k
2 votes

Where can I get correct pitch parameter for SDL_RenderReadPixels function in SDL2?

You should use the pitch parameter of the surface, otherwise you're guessing. This is because the pitch can be padded on different systems or video cards (for extra data or optimization purposes -- ...
Joe's user avatar
  • 121
2 votes
Accepted

C++ -- How could I create a list that contains functions, and would either run the top or iterate through and run all?

Using the STL, you can create a vector of function pointers. To do that, as I guess you want to do something like ...
jjimenezg93's user avatar
2 votes
Accepted

Creating a scrollable area

You need two checks, a scroll variable to move the items and enable clipping: ...
Stephane Hockenhull's user avatar
2 votes
Accepted

Loading texture from constructor doesn't work but does from function call

It seems that you implemented ~Player() to deallocate your texture. Anyway, it is rather bad style to copy objects which contain free able resources like here: <...
Cryptjar's user avatar
  • 210
2 votes
Accepted

SDL Mixer Strange Error Message

I solved the issue! Basically, I didn't have the latest form of SDL2. (I think I had 2.0.5 or something) By going to the SDL2 download page, I was able to get and install SDL-2.0.7, replacing the ...
Eyesight Technology's user avatar
2 votes

Weird issue with Member Initializers C++

With your first chunk of code, you use the initializer list to construct the class variables. So in this case, a copy of notHighlighted is passed to the constructor ...
Vaillancourt's user avatar
  • 16.4k
2 votes
Accepted

Change the image of sdl window with a new one

You will need to have the program keep track of which screen it is on and respond differently depending on the screen. You can do this similarly to the way your programs are keeping track of whether ...
Ryan1729's user avatar
  • 724
2 votes
Accepted

SDL2 only renders a single image

The problem was that the SDL_Rect objects that's supposed to hold position and size data for the textures were receiving incorrect data. Because of this, the textures were rendered outside the window ...
Daniel_1985's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible