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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 -- ...
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 ...
2
votes
Accepted
Creating a scrollable area
You need two checks, a scroll variable to move the items and enable clipping:
...
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:
<...
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 ...
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 ...
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 ...
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 ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
sdl × 436c++ × 232
opengl × 95
sdl2 × 67
c × 42
rendering × 23
textures × 21
2d × 20
input × 16
collision-detection × 15
game-loop × 15
sprites × 10
movement × 10
linux × 10
graphics × 9
keyboard × 9
physics × 8
windows × 8
pixel × 8
macos × 8
c# × 7
animation × 7
software-engineering × 7
mouse × 7
android × 6