December 09, 2019, 10:17:33 PM

Author Topic: C++ and SDL2  (Read 1181 times)

Offline cpsmith0191

  • Jr. Member
  • **
  • Posts: 60
    • caroleandcarl
C++ and SDL2
« on: June 13, 2019, 07:13:58 PM »
I'm using SDL2 with C++ for a point and click menu system.
Should I redraw the back buffer on every pass of the input loop or just redraw the back buffer on every change.
IE
'While prog is running, check for input, draw everything to back buffer , then flip.'
OR
'While prog is running, check for input, draw changes to back buffer if any are needed , then flip.'

It's a hang over from Blitz where you would redraw everything on every pass.
Any advice appreciated, have fun cps.

Offline Dabz

  • Sr. Member
  • ****
  • Posts: 261
  • Is it cos I is ginger?
    • dabzy.co.uk
Re: C++ and SDL2
« Reply #1 on: June 13, 2019, 07:47:47 PM »
I'd just draw every pass, I mean, it'll harm nothing, your main game loop will be doing it and will be more CPU/GPU intensive, basically, I wouldn't worry about it!

Dabz
Intel Core i5 6400 2.7GHz, NVIDIA GeForce GTX 1070 (8GB), 16Gig DDR4 RAM, 256GB SSD, 1TB HDD, Windows 10 64bit

Offline markcwm

  • Sr. Member
  • ****
  • Posts: 409
Re: C++ and SDL2
« Reply #2 on: June 13, 2019, 09:08:56 PM »
If it's not a game or virtual scene, then yes I believe the correct thing is to redraw only when something has changed, if you're multi-tasking this should reduce excess processing.

Offline cpsmith0191

  • Jr. Member
  • **
  • Posts: 60
    • caroleandcarl
Re: C++ and SDL2
« Reply #3 on: June 17, 2019, 08:57:14 PM »
Ummm. I've never seen any deviant pixels in SDL2 relying on the back buffer's stability, so I'll only redraw changes at the moment.
When I get onto complex interactions (games) or if back buffer proves unstable, I'll go for redraw everything.
Many thanks for input. 'The Deviant Pixels' nice name for a band (well maybe)? Have fun cps.