1. EuSDL2 on Linux

Hello all,

I recently got a new computer that came with Windows 11. As you may know, Windows 11 has WSLg which allows for the running of graphical linux apps. With that I was able to test my SDL2 library/wrapper under linux and should be able to test more libraries/wrappers under Linux more easily. I only had to change a little code. You will want to rename EuSDL2.ew to EuSDL2.e and BasicWin.exw to BasicWin.ex

--OS check 
ifdef WIN32 then 
  sdl2 = open_dll("SDL2.dll") 
 elsifdef LINUX or FREEBSD or OPENBSD then 
  sdl2 = open_dll("libSDL2.so") --just had to 'lib' in front of SDL2.so 
  elsifdef OSX then 
  sdl2 = open_dll("SDL2.dylib") 
end ifdef 

Run eui EuSDL2.e in the command line to make sure there are no errors.

--EuSDL2 Basic Window Example 
 
include std/machine.e 
include EuSDL2.e --change from .ew to .e 
include flags.e 
 
atom width = 640, height = 480 
 
--Init SDL2 
if SDL_Init(SDL_INIT_EVERYTHING) = -1 then 
	puts(1,"Could not init SDL2!\n") 
	abort(0) 
end if 
 
--Window creation 
atom win = SDL_CreateWindow("Basic Window - Will close after 3 Seconds",SDL_WINDOWPOS_CENTERED,SDL_WINDOWPOS_CENTERED,width,height,SDL_WINDOW_SHOWN) 
 
if win = -1 then 
	puts(1,"Failed to create window!\n") 
	abort(0) 
end if 
 
SDL_Delay(3000) -- make the window appear for three seconds 
 
--Cleanup 
SDL_DestroyWindow(win)  
 
SDL_Quit() 

Just run eui BasicWin.ex in the command line and the window should come up. You will need Windows 11 with WSL and WSLg for this to work. On Windows 10 you will need to have a X-server program to run graphical apps under WSL.

This is good news as I will be able to test under both Linux and Windows now.

new topic     » topic index » view message » categorize

2. Re: EuSDL2 on Linux

Where's the code? I've got WSLg and I want to fiddle!

-Bruce

new topic     » goto parent     » topic index » view message » categorize

3. Re: EuSDL2 on Linux

axtens_bruce said...

Where's the code? I've got WSLg and I want to fiddle!

-Bruce

My code repo here: https://github.com/gAndy50/EuSDL2

I use the Debian WSL distro. You'll need to install the libSDL2 libraries using the sudo apt install command. You'll need to install Euphoria too. Its all easy as long as you follow the instructions.

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu