[squeak-dev] 64 bit FFI (was: porting Croquet to Squeak6.0 alpha...)

gettimothy gettimothy at zoho.com
Wed Mar 18 11:58:48 UTC 2020


Quick update. (remember, this is a side project of mine, I am not on this full time, just on "wind-down" time from the PEG grammar I am working on)


Taking Bert's advice



Step 1: verify working on 32 bit machines.  Well, I do not have a 32 bit machine that can run squeak (old pentium laptop --the kind that catches on fire) and I tried running side-by-side on Ubuntu.

64 bit runs fine, 32 bit tries to launch and cannot find the display driver.  I could install 32 bit compat libs on my Slackware distro boot, but I prefer to keep that pristine.

I don't care for fighting with Ubuntu, so if anybody knows a quick fix, much appreciated. I can get the exact error if needed, just need to reboot and retry.





step 2: Make it work on 64 bits.



FFI calls crap out with the Croquet install so I attempted going from first principles as described here: http://pharo.gemtalksystems.com/book/LanguageAndLibraries/3DGraphicsAndOpenGL/

.



This example:



| ogl green canvas fade |

ogl := OpenGL newIn: (0 at 0 extent: 300 at 300).

canvas := OGLCanvas new initialize: ogl.

fade:= 0.



1000 timesRepeat: [

ogl glClearColor:0 with: fade with: 0 with: 1.

ogl glClear: 16r4000.

ogl swapBuffers.

fade := fade \+ 0.001.

].





after up a black square, dies here:



glClear: mask

"This method was automatically generated."

"void glClear(GLbitfield mask);"

<apicall: void 'glClear' (ulong) module: 'opengl32.dll'>

^self externalCallFailed





with the externalCallFailed. (why is it looking for a freaking .dll?)



My thought process is now:



1. Write a c openGL program and verify it works. (the mesa-gears linux example works fine)

2. Work through FFI in Squeak so I can debug at that level.











---- On Wed, 11 Mar 2020 18:57:39 -0400 Bert Freudenberg <bert at freudenbergs.de> wrote ----



I'd suggest to get OpenGL working outside of Croquet first:



http://www.squeaksource.com/CroquetGL.html



Step 1: Verify this works in 32 bits. (assuming you are doing this on Linux, you can run 32 bit Squeak side-by-side with the 64 bit one)

Step 2: Make it work in 64 bits.



The second step requires that you understand how FFI works, and how it handles e.g. pointers and integer sizes.

I am assuming we do have a working 64 bit FFI, at least for x86_64 machines.



E.g. the OGLUnix>>glExtGetProcAddress: method returns a pointer. On a 32 bit system, that fits into a 'ulong' which is 32 bits. On a 64 bit system, a pointer is 64 bits wide so it would not fit into a 32 bit word. Now I don't know how many bits 'ulong' has in our 64 bit FFI, but that declaration may have to change. Etc. pp.



If you have questions about FFI then those are best directed at the vm-dev list since it is dealing with VM-level interfaces. CC'ing, please follow up there.



- Bert -




On Wed, Mar 11, 2020 at 2:54 PM gettimothy via Squeak-dev <mailto:squeak-dev at lists.squeakfoundation.org> wrote:








Okey dokey,



Poking along, there is a stray glyph in OGLUnix openGLLibraryName after

openGLLibraryName

^Smalltalk osVersion = 'linux'

ifTrue: ['libGL.so.1']

ifFalse: ['GL']



I removed it in my install and got past that error.



Working exclusively with Croquet(Master)...







My next error is in OGLUnixX11LE(OpenGL)>>glMatrixMode: 

glMatrixMode: mode

"This method was automatically generated."

"void glMatrixMode(GLenum mode);"

<apicall: void 'glMatrixMode' (ulong) module: '#openGLLibraryName'>

^self externalCallFailed



The <apicall:...> fails



How to think about this?



Is Croquet behind OpenGL latest?

Would teaching myself OpenGL programming be of use to the Croquet project?



cheers,



tty
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20200318/34210625/attachment.html>


More information about the Squeak-dev mailing list