I am really just experimenting here. SDL is a well known C/C++ media library. https://www.libsdl.org/download-2.0.php It is possible to use SDL for all kinds of things, but it is often used for games and game prototyping. This is a well known series of tutorials for SDL: http://lazyfoo.net/tutorials/SDL/02_getting_an_image_on_the_screen/index.php These functions need to be called first: SDL_Init( SDL_INIT_VIDEO ); SDL_CreateWindow( "SDL Tutorial", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, SCREEN_WIDTH, SCREEN_HEIGHT, SDL_WINDOW_SHOWN ); SDL_GetWindowSurface( gWindow ); SDL_CreateWindow and SDL_GetWindowSurface return pointers to SDL objects. This is my J attempt at calling these functions:
load 'dll files' lib =: '/path/to/libSDL2.so' NB. takes an int, returns a pointer SDL_Init =: 'SDL_Init i i' NB. takes window title, dimensions and returns a pointer SDL_CreateWindow =: 'SDL_CreateWindow i *c i i i i i' NB. takes the previous pointer and returns a pointer to a window surface. SDL_GetWindowSurface =: 'SDL_GetWindowSurface i x' NB. Load a bitmap, needs the path to the bitmap SDL_LoadBMP =: 'SDL_LoadBMP i *c' initParams =: <0 cwParams =: 'DEMO';10;10;700;500;0 bmpParams =: <'path/to/bmp file' call1 =: lib, ' ',SDL_Init call2 =: lib,' ',SDL_CreateWindow call3 =: lib,' ',SDL_GetWindowSurface call4 =: lib,' ', SDL_LoadBMP Now I do call1 cd initParams NB. seems ok after calling this call2 cd cwParams NB. seems ok. Window should be created. On Mac / Linux it created a black window call3 cd 1292939 NB. the right argument is the previous result's returned pointer. The last call crashes J on Mac, but doesn't crash it on Linux (32-bit Ubuntu). So on Ubuntu I got this far, and it seems like it might just work, so I want to try putting a bitmap on the screen. First I need to load the bitmap. call4 cd bmpParams This is where I always get a domain error. I am not sure why. It sould be noted that you can't use PNG files with LoadBitmap, you need another library (SDL_image). Why call4 gives a domain error is difficult to understand. The path is correct, and it SDL_LoadBMP looks like this: https://wiki.libsdl.org/SDL_LoadBMP Any ideas how to proceed? Thanks in advance. As I said, I am really just experimenting so I do not know if this should work. Thanks, Jon ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
