How to display SDL on PiTFT

EL Wire/Tape/Panels, LEDs, pixels and strips, LCDs and TFTs, etc products from Adafruit

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
ogrevorbis
 
Posts: 2
Joined: Sat Dec 13, 2014 7:53 pm

How to display SDL on PiTFT

Post by ogrevorbis »

I can't get any SDL programs to work on the PiTFT. They will only work after starting XWindows (startx). I tried changing the FRAMEBUFFER=/dev/fb1 and SDL_FBDEV=/dev/fb1 variables, but it will only output to the HDMI. How can I make SDL output to the PiTFT from the console?

(btw I'm using SDL 1.2)

Thanks.

User avatar
adafruit2
 
Posts: 22200
Joined: Fri Mar 11, 2005 7:36 pm

Re: How to display SDL on PiTFT

Post by adafruit2 »

PiTFT is def. SDL compatible, we use Pygame for sure, https://learn.adafruit.com/raspberry-pi ... adioplayer and also cupcade
https://learn.adafruit.com/cupcade-rasp ... ware-setup and the picamera https://learn.adafruit.com/diy-wifi-ras ... -touch-cam all use py/SDL
your SDL software may have some hardcoded framebuffer details.

User avatar
tdicola
 
Posts: 1074
Joined: Thu Oct 17, 2013 9:11 pm

Re: How to display SDL on PiTFT

Post by tdicola »

You might need to set a few more variables too like SDL_VIDEODRIVER. Take a look at how I enable SDL on the PiTFT for this FreqShow project code (which I just copied from the Pi camera project IIRC):

Code: Select all

	# Initialize pygame and SDL to use the PiTFT display and touchscreen.
	os.putenv('SDL_VIDEODRIVER', 'fbcon')
	os.putenv('SDL_FBDEV'      , '/dev/fb1')
	os.putenv('SDL_MOUSEDRV'   , 'TSLIB')
	os.putenv('SDL_MOUSEDEV'   , '/dev/input/touchscreen')

User avatar
ogrevorbis
 
Posts: 2
Joined: Sat Dec 13, 2014 7:53 pm

Re: How to display SDL on PiTFT

Post by ogrevorbis »

I tried changing those extra variables and I also examined the source code for fastdosbox (the SDL program I'm trying to use) and did not find anything related to framebuffer device. The best I could find was surface, opengl, overlay. I tied setting to fbcon, but I got a blank screen on both devices. What version of SDL does pygame use? I'm thinking maybe SDL 1.2 does not support changing the framebuffer. The main reason I purchased this display was for this purpose.

User avatar
tdicola
 
Posts: 1074
Joined: Thu Oct 17, 2013 9:11 pm

Re: How to display SDL on PiTFT

Post by tdicola »

Pygame actually uses SDL 1.2 IIRC. Make sure you're setting the environment variables before running the program, like by running 'export SDL_VIDEODRIVER=fbcon', etc. at the command prompt before running the program.

One thing though since you mentioned OpenGL, is the app you're running using 3D acceleration? If so unfortunately it won't work with the PiTFT because the GPU on the Pi can only write out to the HDMI port. The PiTFT works as a display connected to the SPI bus, so the GPU and programs that only use the GPU (like OpenGL-based games) won't be able to be displayed on the PiTFT.

If it's dosbox, check to see if there's a way to disable 3D acceleration and OpenGL in the configuration. It's been a little while since I've messed with dosbox's config but I believe it has a lot of options to enable & disable 3D acceleration. That should get the rendering off the GPU and let you display the program on the PiTFT.

Locked
Please be positive and constructive with your questions and comments.

Return to “Glowy things (LCD, LED, TFT, EL) purchased at Adafruit”