Recent

Author Topic: SDL2 Software_Render  (Read 1751 times)

mosquito

  • Full Member
  • ***
  • Posts: 144
SDL2 Software_Render
« on: April 15, 2024, 11:31:26 am »

I want to run a window with a simple "Hello World" in SDL2, that doesn't touch the GPU. According to the documentation, I create the Render like this:


Code: Pascal  [Select][+][-]
  1.  
  2. //initilization of video subsystem
  3.   if SDL_Init(SDL_INIT_VIDEO) < 0 then Halt;
  4.  
  5.  
  6.   // full set up
  7.     sdlWindow1 := SDL_CreateWindow('Window1', 50, 50, 500, 500, SDL_WINDOW_SHOWN);
  8.     if sdlWindow1 = nil then Halt;
  9.  
  10.  
  11.     sdlRenderer := SDL_CreateRenderer(sdlWindow1, -1, SDL_RENDERER_SOFTWARE);
  12.      if sdlRenderer = nil then Halt;  
  13.  


But the window in question takes up 15-20% of my GPU, like any other hardware accelerated SDL2 window.


I'm on Debian12 with I3WM.
* I know I can force software rendering on Linux with environment variables, but that's not what I'm looking for


Thank you so much.
« Last Edit: April 15, 2024, 11:33:28 am by mosquito »

flowCRANE

  • Hero Member
  • *****
  • Posts: 901
Re: SDL2 Software_Render
« Reply #1 on: April 15, 2024, 03:41:48 pm »
Probably the reason is that SDL cannot create a software renderer. Use SDL_GetError function and check if the error is reported or not. SDL can ignore your request in the case of problems and create a renderer of the first supported type, which in your case is a hardware renderer.

SDL provides many functions to check various information. You should check if the error is reported but also you can check what is the type (name) of renderer that the SDL created.
Lazarus 3.6 with FPC 3.2.2, Windows 10 — all 64-bit

Working solo on a retro-style action/adventure game (pixel art), programming the engine from scratch, using Free Pascal and SDL3.

mosquito

  • Full Member
  • ***
  • Posts: 144
Re: SDL2 Software_Render
« Reply #2 on: April 15, 2024, 06:36:41 pm »
I'm going to test, thank you very much for the info

 

TinyPortal © 2005-2018