porting Croquet to Squeak6.0 alpha...

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
13 messages Options
Reply | Threaded
Open this post in threaded view
|

porting Croquet to Squeak6.0 alpha...

Squeak - Dev mailing list
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



Reply | Threaded
Open this post in threaded view
|

64 bit FFI (was: porting Croquet to Squeak6.0 alpha...)

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


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 <[hidden email]> 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




Reply | Threaded
Open this post in threaded view
|

Re: 64 bit FFI (was: porting Croquet to Squeak6.0 alpha...)

Nicolas Cellier


Le jeu. 12 mars 2020 à 13:21, Nicolas Cellier <[hidden email]> a écrit :
Hi all,
beware of FFI 'long' and 'ulong'.
They are currently meaning (32 bits) int and unsigned int!
This dates back from the 80s when there were still odd OS with segmented memory and 16-bits int.
long was thought as a safe int32_t at that time... and still means just that in current FFI.

I'd like to replace them with 'int' and 'uint', but we need to ensure backward compatibility etc...

FFI has ExternalType signedLongLong or just 'longlong' and ExternalType unsignedLongLong or 'ulonglong' which are 64 bits on all architectures.
See implementors of #initializeAtomicTypes #initializeFFIConstants

If you want a type that can hold a pointer on both 32 and 64bits arch, then it's doable with a FFI type alias
For example I have things like this in HDF5 module
Notice the single #(fieldName fieldType) which defines an alias, while ordinary FFI struct gets an array of #(fieldName fieldType)
(and replace Size_t with Intptr_t if the purpose is hodling a pointer, otherwise the ayatollahs of C standard will lash you)

ExternalStructure subclass: #'Size_t'
    instanceVariableNames: ''
    classVariableNames: ''
    poolDictionaries: ''
    category: 'HDF5-External-atomic'

Size_t class >>fields
    "Size_t defineFields"
    ^Smalltalk wordSize = 4
        ifTrue: [#( value 'ulong')]
        ifFalse: [#( value 'ulonglong')]

However the "fields" must be re-generated when platform changes...
I tried to automate that sometimes ago, see:

ExternalStructure class>>install
     "Resuming the image on another architecture may require a re-compilation of structure layout."
     | newPlatform |
     newPlatform := Smalltalk platformName.
     PreviousPlatform = newPlatform
         ifFalse:
             [self recompileStructures.
            PreviousPlatform := newPlatform]

It works if you switch from Win64 to MacOS64 for example...
However, this mechanism is not used yet at time of code loading, so importing code generated on a different platform won't automatically update the structures (or alias) - the FFI package has no mechanism for that (maybe we could add a hook in MC?).

Hmm, there is already a MC hook that recompiles the field spec (it sends #compileFields).
But it does not re-generate field accessors (self compileFields: fieldSpec withAccessors: #never.)
Further calls to checkFieldLayoutChange don't recompile the fields either, because the compiledSpec is now up-to-date "thanks" to MC hook.

I think I did that purposedly for avoiding a bunch of 'only timestamp changed', but this was not the right solution for cross-platform support.
Since Eliot has also protected spurious recompilation thru #maybeCompileAccessor:withSelector: it's safer to regenerate the accessors.
 
Le mer. 11 mars 2020 à 23:58, Bert Freudenberg <[hidden email]> a écrit :
I'd suggest to get OpenGL working outside of Croquet first:


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 <[hidden email]> 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





Reply | Threaded
Open this post in threaded view
|

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

Jakob Reschke-2
In reply to this post by Bert Freudenberg
Would it be possible to include an opaque "pointer" basic type in the FFI, to prevent reinventing the wheel in each project? It should reshape accordingly with the platform. If not possible, what are the hurdles?


Nicolas Cellier <[hidden email]> schrieb am Do., 12. März 2020, 13:21:
 
Hi all,
beware of FFI 'long' and 'ulong'.
They are currently meaning (32 bits) int and unsigned int!
This dates back from the 80s when there were still odd OS with segmented memory and 16-bits int.
long was thought as a safe int32_t at that time... and still means just that in current FFI.

I'd like to replace them with 'int' and 'uint', but we need to ensure backward compatibility etc...

FFI has ExternalType signedLongLong or just 'longlong' and ExternalType unsignedLongLong or 'ulonglong' which are 64 bits on all architectures.
See implementors of #initializeAtomicTypes #initializeFFIConstants

If you want a type that can hold a pointer on both 32 and 64bits arch, then it's doable with a FFI type alias
For example I have things like this in HDF5 module
Notice the single #(fieldName fieldType) which defines an alias, while ordinary FFI struct gets an array of #(fieldName fieldType)
(and replace Size_t with Intptr_t if the purpose is hodling a pointer, otherwise the ayatollahs of C standard will lash you)

ExternalStructure subclass: #'Size_t'
    instanceVariableNames: ''
    classVariableNames: ''
    poolDictionaries: ''
    category: 'HDF5-External-atomic'

Size_t class >>fields
    "Size_t defineFields"
    ^Smalltalk wordSize = 4
        ifTrue: [#( value 'ulong')]
        ifFalse: [#( value 'ulonglong')]

However the "fields" must be re-generated when platform changes...
I tried to automate that sometimes ago, see:

ExternalStructure class>>install
     "Resuming the image on another architecture may require a re-compilation of structure layout."
     | newPlatform |
     newPlatform := Smalltalk platformName.
     PreviousPlatform = newPlatform
         ifFalse:
             [self recompileStructures.
            PreviousPlatform := newPlatform]

It works if you switch from Win64 to MacOS64 for example...
However, this mechanism is not used yet at time of code loading, so importing code generated on a different platform won't automatically update the structures (or alias) - the FFI package has no mechanism for that (maybe we could add a hook in MC?).

Le mer. 11 mars 2020 à 23:58, Bert Freudenberg <[hidden email]> a écrit :
I'd suggest to get OpenGL working outside of Croquet first:


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 <[hidden email]> 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





Reply | Threaded
Open this post in threaded view
|

Re: 64 bit FFI (was: porting Croquet to Squeak6.0 alpha...)

Squeak - Dev mailing list
In reply to this post by Bert Freudenberg
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@0 extent: 300@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 <[hidden email]> wrote ----

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


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 <[hidden email]> 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






Reply | Threaded
Open this post in threaded view
|

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

Nicolas Cellier
In reply to this post by Jakob Reschke-2
Well, we have void *, it's opaque enough.
In this case, the storage area must be allocated on heap by some foreign function, and a pointer to it passed back as handle.
The problem with void * is that it is not specific enough.
We thus generally create a type alias. A type alias is a subclass of ExternalStructure. As such, the class name can be used as a type specification in external function interface.
An aliased type differs from a regular struct by the fields definition at class side.
While structure has fields made of an array of pairs #( #(memberName ffiType) ),  an aliased type as a single array #( nil ffiType ).
Using nil avoids creating an accessor. The ffiType can be an integer large enough to hold a pointer (intptr_t, but we do not support that in FFI) - See WinHandle in the FFI-Win32 examples - or 'void *' (I think it may work, but it's a long time since I did not test).

Le jeu. 12 mars 2020 à 15:21, Jakob Reschke <[hidden email]> a écrit :
Would it be possible to include an opaque "pointer" basic type in the FFI, to prevent reinventing the wheel in each project? It should reshape accordingly with the platform. If not possible, what are the hurdles?


Nicolas Cellier <[hidden email]> schrieb am Do., 12. März 2020, 13:21:
 
Hi all,
beware of FFI 'long' and 'ulong'.
They are currently meaning (32 bits) int and unsigned int!
This dates back from the 80s when there were still odd OS with segmented memory and 16-bits int.
long was thought as a safe int32_t at that time... and still means just that in current FFI.

I'd like to replace them with 'int' and 'uint', but we need to ensure backward compatibility etc...

FFI has ExternalType signedLongLong or just 'longlong' and ExternalType unsignedLongLong or 'ulonglong' which are 64 bits on all architectures.
See implementors of #initializeAtomicTypes #initializeFFIConstants

If you want a type that can hold a pointer on both 32 and 64bits arch, then it's doable with a FFI type alias
For example I have things like this in HDF5 module
Notice the single #(fieldName fieldType) which defines an alias, while ordinary FFI struct gets an array of #(fieldName fieldType)
(and replace Size_t with Intptr_t if the purpose is hodling a pointer, otherwise the ayatollahs of C standard will lash you)

ExternalStructure subclass: #'Size_t'
    instanceVariableNames: ''
    classVariableNames: ''
    poolDictionaries: ''
    category: 'HDF5-External-atomic'

Size_t class >>fields
    "Size_t defineFields"
    ^Smalltalk wordSize = 4
        ifTrue: [#( value 'ulong')]
        ifFalse: [#( value 'ulonglong')]

However the "fields" must be re-generated when platform changes...
I tried to automate that sometimes ago, see:

ExternalStructure class>>install
     "Resuming the image on another architecture may require a re-compilation of structure layout."
     | newPlatform |
     newPlatform := Smalltalk platformName.
     PreviousPlatform = newPlatform
         ifFalse:
             [self recompileStructures.
            PreviousPlatform := newPlatform]

It works if you switch from Win64 to MacOS64 for example...
However, this mechanism is not used yet at time of code loading, so importing code generated on a different platform won't automatically update the structures (or alias) - the FFI package has no mechanism for that (maybe we could add a hook in MC?).

Le mer. 11 mars 2020 à 23:58, Bert Freudenberg <[hidden email]> a écrit :
I'd suggest to get OpenGL working outside of Croquet first:


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 <[hidden email]> 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






Reply | Threaded
Open this post in threaded view
|

Re: 64 bit FFI

K K Subbu
In reply to this post by Squeak - Dev mailing list
On 18/03/20 5:28 PM, gettimothy via Squeak-dev wrote:

>
> 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.
Have you tried booting 32-bit Ubuntu from a live USB (4GB+) drive for
your experiments?

Regards .. Subbu

Reply | Threaded
Open this post in threaded view
|

Re: 64 bit FFI

Squeak - Dev mailing list

Hi Subbu,

I will keep it in mind. My focus now is on building openGL tutorial programs such as this: https://paroj.github.io/gltut/index.html
or this: https://www.linuxjournal.com/content/introduction-opengl-programming


the exercise is already giving me insight into the Squeak openGL and should be of use when I get to the FFI part.

cheers,

t

---- On Thu, 19 Mar 2020 04:00:06 -0400 K K Subbu <[hidden email]> wrote ----

On 18/03/20 5:28 PM, gettimothy via Squeak-dev wrote:

>
> 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.
Have you tried booting 32-bit Ubuntu from a live USB (4GB+) drive for
your experiments?

Regards .. Subbu





Reply | Threaded
Open this post in threaded view
|

Re: 64 bit FFI

Bert Freudenberg
The OpenGL class has two example methods on the class side. Trying these is what I meant with "make sure it works in 32 bits":

example	"OpenGL example"
	"A very simple OpenGL example"

	| ogl frames startTime deltaTime framesPerSec bounds font |
	font := StrikeFont familyName: 'Atlanta' pointSize: 11.
	bounds := 0@0 extent: 400@400.
	ogl := OpenGL newIn: bounds.
	ogl ifNil:[^self error: 'Unable to create renderer'].
	[frames := 0.
	startTime := Time millisecondClockValue.
	[Sensor anyButtonPressed] whileFalse:[
		"start counting at second frame since first frame is penalized
		by the upload of the bitmap font outside of ogl."
		frames = 1 ifTrue:[startTime := Time millisecondClockValue].
		ogl beginFrame.

	"--- this is the actual scene content ---"

		ogl glDisable: GLDepthTest.	"for the simple example only"
		ogl glDisable: GLLighting.		"for the simple example only"

		ogl glClearColor: 1.0 with: 1.0 with: 1.0 with: 1.0.
		ogl glClear: GLColorBufferBit.

		ogl glRotatef: 5.0 with: 0.0 with: 0.0 with: 1.0.
		ogl glColor3f: 1.0 with: 0.0 with: 0.0.

		ogl glBegin: GLPolygon.
			ogl glVertex2f: -0.7 with: -0.7.
			ogl glVertex2f:  0.7 with: -0.7.
			ogl glVertex2f:  0.7 with:  0.7.
			ogl glVertex2f: -0.7 with:  0.7.
		ogl glEnd.

	"--- here is the 2d overlay setup ---"

		ogl glMatrixMode: GLProjection.
		ogl glPushMatrix.
		ogl glLoadIdentity.
		ogl glMatrixMode: GLModelview.
		ogl glPushMatrix.
		ogl glLoadIdentity.
		ogl glTranslated: -1 with: 1 with: 0.0.
		ogl glScaled: (2.0 / bounds width) with: (-2.0 / bounds height) with: 1.0.
		ogl glDisable: GLDepthTest.
		ogl glEnable: GLBlend.
		ogl glBlendFunc: GLOne with: GLOneMinusSrcAlpha.

	"--- here is the 2d overlay rendering ---"
		deltaTime := Time millisecondsSince: startTime.
		framesPerSec := frames * 1000 / (deltaTime max: 1) asFloat.
		
		"@@@@: Fixme. It appears as if #drawString: depends on glColor being set.
		Makes no sense but I'm not going to figure this out - probably some mishap
		wrt. GLLighting being disabled."
		ogl glColor3f: 0.0 with: 0.0 with: 0.0.
		ogl drawString: frames printString, ' frames: ', (framesPerSec truncateTo: 0.1), ' fps'
			at: 0@font height@0 font: font color: Color black.

		ogl glDisable: GLBlend.
		ogl glMatrixMode: GLModelview.
		ogl glPopMatrix.
		ogl glMatrixMode: GLProjection.
		ogl glPopMatrix.
		ogl glMatrixMode: GLModelview.

	"--- end the end frame operations"

		ogl endFrame.
		ogl swapBuffers.
		frames := frames + 1.
	].
	] ensure:[ogl destroy].

- Bert -


On Thu, Mar 19, 2020 at 5:57 AM gettimothy via Squeak-dev <[hidden email]> wrote:

Hi Subbu,

I will keep it in mind. My focus now is on building openGL tutorial programs such as this: https://paroj.github.io/gltut/index.html
or this: https://www.linuxjournal.com/content/introduction-opengl-programming


the exercise is already giving me insight into the Squeak openGL and should be of use when I get to the FFI part.

cheers,

t

---- On Thu, 19 Mar 2020 04:00:06 -0400 K K Subbu <[hidden email]> wrote ----

On 18/03/20 5:28 PM, gettimothy via Squeak-dev wrote:

>
> 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.
Have you tried booting 32-bit Ubuntu from a live USB (4GB+) drive for
your experiments?

Regards .. Subbu






Reply | Threaded
Open this post in threaded view
|

Re: 64 bit FFI

Squeak - Dev mailing list
Squeak 32 does not run 'seamlessly'  on ubuntu 18 .  After a day of wrangling it, It starts and I can set the preferences wizard up to rhe point where it must connect to the Internet to download and install ffi, osprocess, git, etc ..at that point, what should be  the 'ok' button says 'you dont have internet access' or something to that effect.


Tldr; could not get to OpenGL example on 32 bit install on 64 bit Ubuntu 18 with i386 libs installed.

I got tired of trying and moved to another approach.


If you know of a fix for the internet stuff, I can try again come Tuesday

Fwiw, the 64 bit squeak installs fine as does the CroquetGL stuff and OpenGL example does not work. The ffi? primitives fail.

On a happy note, I was able to build a simple c example after a day, today, of wrangling, and displai a triangle.

Linking libraries was huge issue, which I grok now, and it leads ne to wonder how the Squeak  OpenGL is even aware of the existing libraries.. (i doubt it is)

For example -lGL had to be xhanged to -lOpenGL in my program as did the -L path to get C to talk to the graphics card via the OpenGL stuff.

Cheers

t







---- On Thu, 19 Mar 2020 19:06:37 -0400 [hidden email] wrote ----

The OpenGL class has two example methods on the class side. Trying these is what I meant with "make sure it works in 32 bits":

example	"OpenGL example"
	"A very simple OpenGL example"

	| ogl frames startTime deltaTime framesPerSec bounds font |
	font := StrikeFont familyName: 'Atlanta' pointSize: 11.
	bounds := 0@0 extent: 400@400.
	ogl := OpenGL newIn: bounds.
	ogl ifNil:[^self error: 'Unable to create renderer'].
	[frames := 0.
	startTime := Time millisecondClockValue.
	[Sensor anyButtonPressed] whileFalse:[
		"start counting at second frame since first frame is penalized
		by the upload of the bitmap font outside of ogl."
		frames = 1 ifTrue:[startTime := Time millisecondClockValue].
		ogl beginFrame.

	"--- this is the actual scene content ---"

		ogl glDisable: GLDepthTest.	"for the simple example only"
		ogl glDisable: GLLighting.		"for the simple example only"

		ogl glClearColor: 1.0 with: 1.0 with: 1.0 with: 1.0.
		ogl glClear: GLColorBufferBit.

		ogl glRotatef: 5.0 with: 0.0 with: 0.0 with: 1.0.
		ogl glColor3f: 1.0 with: 0.0 with: 0.0.

		ogl glBegin: GLPolygon.
			ogl glVertex2f: -0.7 with: -0.7.
			ogl glVertex2f:  0.7 with: -0.7.
			ogl glVertex2f:  0.7 with:  0.7.
			ogl glVertex2f: -0.7 with:  0.7.
		ogl glEnd.

	"--- here is the 2d overlay setup ---"

		ogl glMatrixMode: GLProjection.
		ogl glPushMatrix.
		ogl glLoadIdentity.
		ogl glMatrixMode: GLModelview.
		ogl glPushMatrix.
		ogl glLoadIdentity.
		ogl glTranslated: -1 with: 1 with: 0.0.
		ogl glScaled: (2.0 / bounds width) with: (-2.0 / bounds height) with: 1.0.
		ogl glDisable: GLDepthTest.
		ogl glEnable: GLBlend.
		ogl glBlendFunc: GLOne with: GLOneMinusSrcAlpha.

	"--- here is the 2d overlay rendering ---"
		deltaTime := Time millisecondsSince: startTime.
		framesPerSec := frames * 1000 / (deltaTime max: 1) asFloat.
		
		"@@@@: Fixme. It appears as if #drawString: depends on glColor being set.
		Makes no sense but I'm not going to figure this out - probably some mishap
		wrt. GLLighting being disabled."
		ogl glColor3f: 0.0 with: 0.0 with: 0.0.
		ogl drawString: frames printString, ' frames: ', (framesPerSec truncateTo: 0.1), ' fps'
			at: 0@font height@0 font: font color: Color black.

		ogl glDisable: GLBlend.
		ogl glMatrixMode: GLModelview.
		ogl glPopMatrix.
		ogl glMatrixMode: GLProjection.
		ogl glPopMatrix.
		ogl glMatrixMode: GLModelview.

	"--- end the end frame operations"

		ogl endFrame.
		ogl swapBuffers.
		frames := frames + 1.
	].
	] ensure:[ogl destroy].

- Bert -


On Thu, Mar 19, 2020 at 5:57 AM gettimothy via Squeak-dev <[hidden email]> wrote:

Hi Subbu,

I will keep it in mind. My focus now is on building openGL tutorial programs such as this: https://paroj.github.io/gltut/index.html
or this: https://www.linuxjournal.com/content/introduction-opengl-programming


the exercise is already giving me insight into the Squeak openGL and should be of use when I get to the FFI part.

cheers,

t

---- On Thu, 19 Mar 2020 04:00:06 -0400 K K Subbu <[hidden email]> wrote ----

On 18/03/20 5:28 PM, gettimothy via Squeak-dev wrote:

>
> 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.
Have you tried booting 32-bit Ubuntu from a live USB (4GB+) drive for
your experiments?

Regards .. Subbu







Reply | Threaded
Open this post in threaded view
|

Re: 64 bit FFI

Squeak - Dev mailing list
Ubuntu 18 is hugely broken; Canonical took out all the 32 bit support, so if you want to run 32 bit apps, you have to install ALL the 32 bit libraries. Better solution is to install 16.04, it’d be the easiest way to go.

/————————————————————/
For encrypted mail use [hidden email]
Get a free account at ProtonMail.com
Web: https://objectnets.net and https://objectnets.org
https://datascilv.com https://datascilv.org


On Mar 19, 2020, at 17:48, gettimothy via Squeak-dev <[hidden email]> wrote:


Squeak 32 does not run 'seamlessly'  on ubuntu 18 .  After a day of wrangling it, It starts and I can set the preferences wizard up to rhe point where it must connect to the Internet to download and install ffi, osprocess, git, etc ..at that point, what should be  the 'ok' button says 'you dont have internet access' or something to that effect.


Tldr; could not get to OpenGL example on 32 bit install on 64 bit Ubuntu 18 with i386 libs installed.

I got tired of trying and moved to another approach.


If you know of a fix for the internet stuff, I can try again come Tuesday

Fwiw, the 64 bit squeak installs fine as does the CroquetGL stuff and OpenGL example does not work. The ffi? primitives fail.

On a happy note, I was able to build a simple c example after a day, today, of wrangling, and displai a triangle.

Linking libraries was huge issue, which I grok now, and it leads ne to wonder how the Squeak  OpenGL is even aware of the existing libraries.. (i doubt it is)

For example -lGL had to be xhanged to -lOpenGL in my program as did the -L path to get C to talk to the graphics card via the OpenGL stuff.

Cheers

t







---- On Thu, 19 Mar 2020 19:06:37 -0400 [hidden email] wrote ----

The OpenGL class has two example methods on the class side. Trying these is what I meant with "make sure it works in 32 bits":

example	"OpenGL example"
	"A very simple OpenGL example"

	| ogl frames startTime deltaTime framesPerSec bounds font |
	font := StrikeFont familyName: 'Atlanta' pointSize: 11.
	bounds := 0@0 extent: 400@400.
	ogl := OpenGL newIn: bounds.
	ogl ifNil:[^self error: 'Unable to create renderer'].
	[frames := 0.
	startTime := Time millisecondClockValue.
	[Sensor anyButtonPressed] whileFalse:[
		"start counting at second frame since first frame is penalized
		by the upload of the bitmap font outside of ogl."
		frames = 1 ifTrue:[startTime := Time millisecondClockValue].
		ogl beginFrame.

	"--- this is the actual scene content ---"

		ogl glDisable: GLDepthTest.	"for the simple example only"
		ogl glDisable: GLLighting.		"for the simple example only"

		ogl glClearColor: 1.0 with: 1.0 with: 1.0 with: 1.0.
		ogl glClear: GLColorBufferBit.

		ogl glRotatef: 5.0 with: 0.0 with: 0.0 with: 1.0.
		ogl glColor3f: 1.0 with: 0.0 with: 0.0.

		ogl glBegin: GLPolygon.
			ogl glVertex2f: -0.7 with: -0.7.
			ogl glVertex2f:  0.7 with: -0.7.
			ogl glVertex2f:  0.7 with:  0.7.
			ogl glVertex2f: -0.7 with:  0.7.
		ogl glEnd.

	"--- here is the 2d overlay setup ---"

		ogl glMatrixMode: GLProjection.
		ogl glPushMatrix.
		ogl glLoadIdentity.
		ogl glMatrixMode: GLModelview.
		ogl glPushMatrix.
		ogl glLoadIdentity.
		ogl glTranslated: -1 with: 1 with: 0.0.
		ogl glScaled: (2.0 / bounds width) with: (-2.0 / bounds height) with: 1.0.
		ogl glDisable: GLDepthTest.
		ogl glEnable: GLBlend.
		ogl glBlendFunc: GLOne with: GLOneMinusSrcAlpha.

	"--- here is the 2d overlay rendering ---"
		deltaTime := Time millisecondsSince: startTime.
		framesPerSec := frames * 1000 / (deltaTime max: 1) asFloat.
		
		"@@@@: Fixme. It appears as if #drawString: depends on glColor being set.
		Makes no sense but I'm not going to figure this out - probably some mishap
		wrt. GLLighting being disabled."
		ogl glColor3f: 0.0 with: 0.0 with: 0.0.
		ogl drawString: frames printString, ' frames: ', (framesPerSec truncateTo: 0.1), ' fps'
			at: 0@font height@0 font: font color: Color black.

		ogl glDisable: GLBlend.
		ogl glMatrixMode: GLModelview.
		ogl glPopMatrix.
		ogl glMatrixMode: GLProjection.
		ogl glPopMatrix.
		ogl glMatrixMode: GLModelview.

	"--- end the end frame operations"

		ogl endFrame.
		ogl swapBuffers.
		frames := frames + 1.
	].
	] ensure:[ogl destroy].

- Bert -


On Thu, Mar 19, 2020 at 5:57 AM gettimothy via Squeak-dev <[hidden email]> wrote:

Hi Subbu,

I will keep it in mind. My focus now is on building openGL tutorial programs such as this: https://paroj.github.io/gltut/index.html
or this: https://www.linuxjournal.com/content/introduction-opengl-programming


the exercise is already giving me insight into the Squeak openGL and should be of use when I get to the FFI part.

cheers,

t

---- On Thu, 19 Mar 2020 04:00:06 -0400 K K Subbu <[hidden email]> wrote ----

On 18/03/20 5:28 PM, gettimothy via Squeak-dev wrote:

>
> 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.
Have you tried booting 32-bit Ubuntu from a live USB (4GB+) drive for
your experiments?

Regards .. Subbu








Reply | Threaded
Open this post in threaded view
|

Re: 64 bit FFI (was: porting Croquet to Squeak6.0 alpha...)

Squeak - Dev mailing list
In reply to this post by Bert Freudenberg
Hi Bert,

I got the latest 5.3 32 bit installed on the old laptop.

on linux, glxgears works.

OpenGL example does not work.

Same error as on the 64 bit box:


glPixelStorei: pname with: param
"This method was automatically generated."
"void glPixelStorei(GLenum pname, GLint param);"
<apicall: void 'glPixelStorei' (ulong long) module: '#openGLLibraryName'>
^self externalCallFailed

cheers,

tty

---- On Wed, 11 Mar 2020 18:57:39 -0400 Bert Freudenberg <[hidden email]> wrote ----

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


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 <[hidden email]> 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






Reply | Threaded
Open this post in threaded view
|

Re: 64 bit FFI (was: porting Croquet to Squeak6.0 alpha...)

Squeak - Dev mailing list
Hi Bert,

The actual error is "externalCallFailed" output.

I will do the FFI stuff tomorrow.

Much appreciated.

tty.




---- On Tue, 24 Mar 2020 18:20:46 -0400 Bert Freudenberg <[hidden email]> wrote ----

What's the actual error in 32 bits?

Also, make sure that FFI works at all - I think there are test examples in the FFI package.

- Bert -

On Tue, Mar 24, 2020 at 11:59 AM gettimothy <[hidden email]> wrote:


Hi Bert,

I got the latest 5.3 32 bit installed on the old laptop.

on linux, glxgears works.

OpenGL example does not work.

Same error as on the 64 bit box:


glPixelStorei: pname with: param
"This method was automatically generated."
"void glPixelStorei(GLenum pname, GLint param);"
<apicall: void 'glPixelStorei' (ulong long) module: '#openGLLibraryName'>
^self externalCallFailed

cheers,

tty

---- On Wed, 11 Mar 2020 18:57:39 -0400 Bert Freudenberg <[hidden email]> wrote ----

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


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 <[hidden email]> 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