Re: OpenGl.l and Segmentation fault

2012-11-09 Thread Alexander Burger
Hi Jon,

> This is how it was done in simul/gl/glut.c, which worked with
> (32-bit) picoLisp-2.3.5:
> ...
> void* font = GLUT_STROKE_ROMAN;
> ...
> int character;
> ...
> glutStrokeCharacter(font, character);

Yes. The only difference is that glutStrokeCharacter() expects a pointer
and an integer, while 'native' will pass two long integers.

This shouldn't make any difference, though, especially not on 64-bit
systems (where all three types have a size of 64 bits), and not when
arguments are passed in registers anyway.

Where is the hitch?
-- 
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


Re: OpenGl.l and Segmentation fault

2012-11-09 Thread Jon Kleiser

Hi all,

This is how it was done in simul/gl/glut.c, which worked with (32-bit) 
picoLisp-2.3.5:


// (glut:BitmapCharacter 'fontNum 'character) -> T
any BitmapCharacter(any ex) {
void* font;
int fontNum;
int character;

fontNum = (int)evCnt(ex, cdr(ex));
character = (int)evCnt(ex, cddr(ex));
switch (fontNum) {
// These GLUT_BITMAP values are system dependent.
case 2: font = GLUT_BITMAP_9_BY_15;break;
case 3: font = GLUT_BITMAP_8_BY_13;break;
case 4: font = GLUT_BITMAP_TIMES_ROMAN_10;break;
case 5: font = GLUT_BITMAP_TIMES_ROMAN_24;break;
case 6: font = GLUT_BITMAP_HELVETICA_10;break;
case 7: font = GLUT_BITMAP_HELVETICA_12;break;
case 8: font = GLUT_BITMAP_HELVETICA_18;break;
default: font = GLUT_BITMAP_TIMES_ROMAN_24;break;
}
//printf("BitmapCharacter, font = %10p\n", font);
glutBitmapCharacter(font, character);
return T;
}

// (glut:StrokeCharacter 'mono 'character) -> T
any StrokeCharacter(any ex) {
void* font = GLUT_STROKE_ROMAN;
int mono;
int character;

mono = (int)evCnt(ex, cdr(ex));// correct? - jk
character = (int)evCnt(ex, cddr(ex));
if (mono) font = GLUT_STROKE_MONO_ROMAN;
glutStrokeCharacter(font, character);
return T;
}

.. and this is how it was called in my china.l:

(glut:BitmapCharacter FontNum (char Chr))

I know that parameters in calls to C library functions are done quite 
differently nowadays, in pil64.


/Jon


On 11/8/12 9:43 PM, Jorge Acereda wrote:

On Nov 8, 2012, at 9:09 PM, Alexander Burger wrote:


Hi Jon,


work to make OpenGl.l a little more complete (lots missing). The problem
I have right now, is with glutBitmapCharacter and glutStrokeCharacter;
they give me "Segmentation fault", and I suspect they'll fail on Linux
as well.

Yes. At least 'glutStrokeCharacter' does.


I'm wondering whether (or why)

(glutStrokeCharacter 2 (char "A"))

is correct, as the corresponding C function signature is

   void glutStrokeCharacter(void *font, int character);

i.e. '2' is a "pointer".



#if defined(_WIN32)
/* Stroke font constants (use these in GLUT program). */
#define GLUT_STROKE_ROMAN   ((void*)0)
#define GLUT_STROKE_MONO_ROMAN  ((void*)1)
..
#else
..
#define GLUT_STROKE_ROMAN   (&glutStrokeRoman)
#define GLUT_STROKE_MONO_ROMAN  (&glutStrokeMonoRoman)
..
#endif





I faintly remember I saw this usage before (perhaps in your OpenGl /
ErsatzLisp code?), and it seems passing '2' as a pointer is legal use.
But then I have no idea why it crashes.

Cheers,
- Alex



--
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


Re: OpenGl.l and Segmentation fault

2012-11-08 Thread Jorge Acereda

On Nov 8, 2012, at 9:09 PM, Alexander Burger wrote:

> Hi Jon,
> 
>> work to make OpenGl.l a little more complete (lots missing). The problem 
>> I have right now, is with glutBitmapCharacter and glutStrokeCharacter; 
>> they give me "Segmentation fault", and I suspect they'll fail on Linux 
>> as well.
> 
> Yes. At least 'glutStrokeCharacter' does.
> 
> 
> I'm wondering whether (or why)
> 
>(glutStrokeCharacter 2 (char "A"))
> 
> is correct, as the corresponding C function signature is
> 
>   void glutStrokeCharacter(void *font, int character);
> 
> i.e. '2' is a "pointer".



#if defined(_WIN32) 
  
/* Stroke font constants (use these in GLUT program). */
  
#define GLUT_STROKE_ROMAN   ((void*)0)  
  
#define GLUT_STROKE_MONO_ROMAN  ((void*)1)  
  
..
#else
..
#define GLUT_STROKE_ROMAN   (&glutStrokeRoman)
#define GLUT_STROKE_MONO_ROMAN  (&glutStrokeMonoRoman)
..
#endif



> 
> 
> I faintly remember I saw this usage before (perhaps in your OpenGl /
> ErsatzLisp code?), and it seems passing '2' as a pointer is legal use.
> But then I have no idea why it crashes.
> 
> Cheers,
> - Alex
> -- 
> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe

--
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


Re: OpenGl.l and Segmentation fault

2012-11-08 Thread Alexander Burger
Hi Jon,

> work to make OpenGl.l a little more complete (lots missing). The problem 
> I have right now, is with glutBitmapCharacter and glutStrokeCharacter; 
> they give me "Segmentation fault", and I suspect they'll fail on Linux 
> as well.

Yes. At least 'glutStrokeCharacter' does.


I'm wondering whether (or why)

(glutStrokeCharacter 2 (char "A"))

is correct, as the corresponding C function signature is

   void glutStrokeCharacter(void *font, int character);

i.e. '2' is a "pointer".


I faintly remember I saw this usage before (perhaps in your OpenGl /
ErsatzLisp code?), and it seems passing '2' as a pointer is legal use.
But then I have no idea why it crashes.

Cheers,
- Alex
-- 
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


OpenGl.l and Segmentation fault

2012-11-08 Thread Jon Kleiser

Hi,

Since I can now run OpenGL stuff using emu64 on Mac, I can continue some 
work to make OpenGl.l a little more complete (lots missing). The problem 
I have right now, is with glutBitmapCharacter and glutStrokeCharacter; 
they give me "Segmentation fault", and I suspect they'll fail on Linux 
as well. If you use my "extended" OpenGl.l (goes into lib/), attached, 
and try the code below, you'll see the problem.

This requires emu64 or pil64.

/Jon

# 18sep07abu, 07nov12jk
# (c) Software Lab. Alexander Burger

(load "@lib/openGl.l")

(glutInit)
(glutInitDisplayMode (| GLUT_SINGLE GLUT_RGB))
(glutInitWindowSize 400 400)
(glutCreateWindow "Test Window")

(glClearColor 0.5 0.5 0.5 0.0)
(glMatrixMode GL_PROJECTION)
(glLoadIdentity)
(glOrtho 0.0 1.0 0.0 1.0 -1.0 1.0)

(setq *M 0)
(setq *CL '((1.0 0.5 0.5) (0 1.0 0) (0 0 1.0) (0.8 0.8 0.2)))

(displayPrg
   (glClear GL_COLOR_BUFFER_BIT)
   (glColor3f (caar *CL) (cadar *CL) (caddr (car *CL)))
   (glBegin GL_POLYGON)
   (glVertex3f 0.25 0.25 0.0)
   (glVertex3f 0.75 0.25 0.0)
   (glVertex3f 0.75 0.75 0.0)
   (glVertex3f 0.25 0.75 0.0)
   (glEnd)

   (glRasterPos2f 0 0)
   # http://www.opengl.org/resources/libraries/glut/spec3/node76.html
   (glutBitmapCharacter 2 (char "A"))
   # http://www.opengl.org/resources/libraries/glut/spec3/node78.html
   #(glutStrokeCharacter 2 (char "A"))

   (glFlush) )

(mouseFunc '((Btn State X Y)
(rot *CL)
(println "mouseFunc" (inc '*M))
(glutPostRedisplay) ) )

(glutMainLoop)

# vi:et:ts=3:sw=3


--090904040509000408010403
Content-Type: application/zip;
name="openGl.l.zip"
Content-Transfer-Encoding: base64
Content-Disposition: attachment;
filename="openGl.l.zip"

UEsDBBQACAAIAFhtZ0EIABAAb3BlbkdsLmxVWAwA0WabUEhXmlD1ARQA
tVpZc+JIEn4e/4pa+8FiYttGmLbdEzERK0BgbQuJQaLb3S9eAQXWWEisDh/z6zfrkFSlAzwz
vUQ4bFJffnlUVVZWyWdI7f2eharqLbOTM9S9CaNnkDzB38qqg5xok754MUamt7xAWoBfvXCN
YzTI4i2OT07Ozs6QvcfhxESBv4y9+A35YYrjjbfCCB6eKEHkrdHpv+Dp5c5LHy+C087JieJv
kPIr+tl20OnIi1/8EKQ/KWu88bIgPfnpp58nQWb6S3R66bwlKd5dmoz9chx7O/wSxU/JJbN7
scklXHDK1dNj+hNz4Qra5OspanMjS+JLEgP8APAiiSpmhOdbEBIA6gAb5HEW4w+rKEzwGm38
130ECUJevM12OEyTEyXB6X9PEEKn4yBVT5HSRRfog3rR7eTCXpPwqknYrwlHyyDnFGW9BtlV
g6zfIPvY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