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-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-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