comp.lang.ada
 help / color / mirror / Atom feed
* ADA and Open GL
@ 2011-08-09 14:31 ldries46
  2011-08-09 14:48 ` Georg Bauhaus
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: ldries46 @ 2011-08-09 14:31 UTC (permalink / raw)


I do have a program where I have to create an OpenGL window in a selected 
number of cases.
The routine in which that happens is:

procedure InitGlutWindow( argc : integer; argv : string; Xpos : integer; 
Ypos : integer; Width : integer; Height : integer;  WindowName : string ) is
   argca : aliased integer := argc;
   winna : aliased string := WindowName;
   pargv : Interfaces.C.Strings.chars_ptr;
   pwin  : GLubytePtr := Interfaces.C.Strings.New_String(WindowName);
begin
   pargv := Interfaces.C.Strings.New_String(argv);
   glutInit( argca'Access, pargv );
   glutInitDisplayMode (GLUT_DOUBLE);
   glLoadIdentity;
   gluLookAt(eyex, eyey, eyez, refx, refy, refz, dirx, diry, dirz);
   glutInitWindowSize( Width, Height );
   glutInitWindowPosition( Xpos, Ypos );
   glutCreateWindow( pwin );                   -- Create the Window PROBLEM
   glMatrixMode(GL_PROJECTION);
   glLoadIdentity;
   glOrtho( -0.5*vOrtho, vOrtho, -0.5*vOrtho, 0.5*vOrtho, -0.5*vOrtho, 
0.5*vOrtho );
   glMatrixMode(GL_MODELVIEW);
end InitGlutWindow;

When compiling I get the error message:

cannot use function "glutCreateWindow" in a procedure call

when I create a function in stead of a procedure I get the same error 
message

What can I do to make this work.

L. Dries 




^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: ADA and Open GL
  2011-08-09 14:31 ldries46
@ 2011-08-09 14:48 ` Georg Bauhaus
  2011-08-09 14:51 ` Simon Wright
  2011-08-10  8:58 ` ldries46
  2 siblings, 0 replies; 8+ messages in thread
From: Georg Bauhaus @ 2011-08-09 14:48 UTC (permalink / raw)


On 09.08.11 16:31, ldries46 wrote:

>   glutCreateWindow( pwin );                   -- Create the Window PROBLEM
ignored_window_identifier := glutCreateWindow( pwin );

The function glutCreateWindow returns a value.
The Ada mapping, then, will also return this
value, as programmers might want to keep it.
  If you do not need the return value, the
program must still follow Ada rules which state
that all parameters of a subprograms must be
handled, be they in, in out, out or return.



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: ADA and Open GL
  2011-08-09 14:31 ldries46
  2011-08-09 14:48 ` Georg Bauhaus
@ 2011-08-09 14:51 ` Simon Wright
  2011-08-10  8:58 ` ldries46
  2 siblings, 0 replies; 8+ messages in thread
From: Simon Wright @ 2011-08-09 14:51 UTC (permalink / raw)


"ldries46" <bertus.dries@planet.nl> writes:

> I do have a program where I have to create an OpenGL window in a
> selected number of cases.
> When compiling I get the error message:
>
> cannot use function "glutCreateWindow" in a procedure call
>
> when I create a function in stead of a procedure I get the same error
> message

The problem is (presumably!) that glutCreateWindow() is a
function. Google shows:

Usage

  int glutCreateWindow(char *name);

  name
    ASCII character string for use as window name.

[...]

  The value returned is a unique small integer identifier for the
  window. The range of allocated identifiers starts at one. This window
  identifier can be used when calling glutSetWindow.

So, if you don't want the identifier, say something like

  declare
    dummy : integer;
    pragma unreferenced (dummy);
  begin
    dummy := glutCreateWindow( pwin );
  end;



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: ADA and Open GL
  2011-08-09 14:31 ldries46
  2011-08-09 14:48 ` Georg Bauhaus
  2011-08-09 14:51 ` Simon Wright
@ 2011-08-10  8:58 ` ldries46
  2011-08-10 11:09   ` Simon Wright
  2 siblings, 1 reply; 8+ messages in thread
From: ldries46 @ 2011-08-10  8:58 UTC (permalink / raw)


Thanks,

I didn't realize that in the C++ program I used for example it is opssible 
to use a function without using the return part,

unit is compiling.

My program seems correct now, but I get the following error message:

opengl-glu.ads:373:31: warning: subprogram pointer 
"gluNurbsCallback.CallBackFunc" should have foreign convention
opengl-glu.ads:373:31: warning: add Convention pragma to declaration of 
"GLU.GLUFUNCPTR" at line 231

This is found in a standard unit nl. the adabindings to Open GL, GLU and 
GLUT

Can I disregard this warning or should I do something to avoid it. I don't 
thoink I should be altering my copy of the ADA bindings so
where should I do something.
In my program I don't call this routine directly soit is a result of a call 
from another routine within the ADA bindings.

L. Dries




^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: ADA and Open GL
  2011-08-10  8:58 ` ldries46
@ 2011-08-10 11:09   ` Simon Wright
  2011-08-10 13:23     ` ldries46
  0 siblings, 1 reply; 8+ messages in thread
From: Simon Wright @ 2011-08-10 11:09 UTC (permalink / raw)


"ldries46" <bertus.dries@planet.nl> writes:

> My program seems correct now, but I get the following error message:
>
> opengl-glu.ads:373:31: warning: subprogram pointer
> "gluNurbsCallback.CallBackFunc" should have foreign convention
> opengl-glu.ads:373:31: warning: add Convention pragma to declaration
> of "GLU.GLUFUNCPTR" at line 231
>
> This is found in a standard unit nl. the adabindings to Open GL, GLU
> and GLUT
>
> Can I disregard this warning or should I do something to avoid it. I
> don't thoink I should be altering my copy of the ADA bindings so
> where should I do something.
> In my program I don't call this routine directly soit is a result of a
> call from another routine within the ADA bindings.

Perhaps you're compiling with a different set of compiler options than
those used by the developer of the bindings?

Very often, GNAT will in fact translate iffy code like this correctly
(the compiler backend understands C, of course). Better not to risk it,
though, convention errors can be a real pain to debug.

Those bindings aren't "standard" in the RM sense. Personally I'd make
the change and send a patch to the bindings maintainer.



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: ADA and Open GL
  2011-08-10 11:09   ` Simon Wright
@ 2011-08-10 13:23     ` ldries46
  2011-08-10 15:35       ` Simon Wright
  0 siblings, 1 reply; 8+ messages in thread
From: ldries46 @ 2011-08-10 13:23 UTC (permalink / raw)


I did what you suggested. and with only one pragma for a function pointer it 
worked.
But I got now a number of message of this kind:

E:/ada/project/Blastula/visualize.adb:289: undefined reference to 
`glutSwapBuffers'

I got the same messages for the glSomething routines and adding:
"-LC:\windows\system32" to the linker options solved these These routines 
are in openGL32.dll
The errors in the other routines were not solved although these are 
positioned in Glu32.dll and Glut32.dll both also in the C:\Windows\System32 
directory

"Simon Wright"  schreef in bericht news:m2liv134lb.fsf@pushface.org...

"ldries46" <bertus.dries@planet.nl> writes:

> My program seems correct now, but I get the following error message:
>
> opengl-glu.ads:373:31: warning: subprogram pointer
> "gluNurbsCallback.CallBackFunc" should have foreign convention
> opengl-glu.ads:373:31: warning: add Convention pragma to declaration
> of "GLU.GLUFUNCPTR" at line 231
>
> This is found in a standard unit nl. the adabindings to Open GL, GLU
> and GLUT
>
> Can I disregard this warning or should I do something to avoid it. I
> don't thoink I should be altering my copy of the ADA bindings so
> where should I do something.
> In my program I don't call this routine directly soit is a result of a
> call from another routine within the ADA bindings.

Perhaps you're compiling with a different set of compiler options than
those used by the developer of the bindings?

Very often, GNAT will in fact translate iffy code like this correctly
(the compiler backend understands C, of course). Better not to risk it,
though, convention errors can be a real pain to debug.

Those bindings aren't "standard" in the RM sense. Personally I'd make
the change and send a patch to the bindings maintainer. 




^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: ADA and Open GL
@ 2011-08-10 14:24 ldries46
  0 siblings, 0 replies; 8+ messages in thread
From: ldries46 @ 2011-08-10 14:24 UTC (permalink / raw)


If this message is send twice, please forgive but to me it seems as if the 
message was not send

I did what you suggested. and with only one pragma for a function pointer it
worked.
But I got now a number of message of this kind:

E:/ada/project/Blastula/visualize.adb:289: undefined reference to
`glutSwapBuffers'

I got the same messages for the glSomething routines and adding:
"-LC:\windows\system32" to the linker options solved these These routines
are in openGL32.dll
The errors in the other routines were not solved although these are
positioned in Glu32.dll and Glut32.dll both also in the C:\Windows\System32
directory

"Simon Wright"  schreef in bericht news:m2liv134lb.fsf@pushface.org...

"ldries46" <bertus.dries@planet.nl> writes:

> My program seems correct now, but I get the following error message:
>
> opengl-glu.ads:373:31: warning: subprogram pointer
> "gluNurbsCallback.CallBackFunc" should have foreign convention
> opengl-glu.ads:373:31: warning: add Convention pragma to declaration
> of "GLU.GLUFUNCPTR" at line 231
>
> This is found in a standard unit nl. the adabindings to Open GL, GLU
> and GLUT
>
> Can I disregard this warning or should I do something to avoid it. I
> don't thoink I should be altering my copy of the ADA bindings so
> where should I do something.
> In my program I don't call this routine directly soit is a result of a
> call from another routine within the ADA bindings.

Perhaps you're compiling with a different set of compiler options than
those used by the developer of the bindings?

Very often, GNAT will in fact translate iffy code like this correctly
(the compiler backend understands C, of course). Better not to risk it,
though, convention errors can be a real pain to debug.

Those bindings aren't "standard" in the RM sense. Personally I'd make
the change and send a patch to the bindings maintainer. 




^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: ADA and Open GL
  2011-08-10 13:23     ` ldries46
@ 2011-08-10 15:35       ` Simon Wright
  0 siblings, 0 replies; 8+ messages in thread
From: Simon Wright @ 2011-08-10 15:35 UTC (permalink / raw)


"ldries46" <bertus.dries@planet.nl> writes:

> But I got now a number of message of this kind:
>
> E:/ada/project/Blastula/visualize.adb:289: undefined reference to
> glutSwapBuffers'
>
> I got the same messages for the glSomething routines and adding:
> "-LC:\windows\system32" to the linker options solved these These
> routines are in openGL32.dll
> The errors in the other routines were not solved although these are
> positioned in Glu32.dll and Glut32.dll both also in the
> C:\Windows\System32 directory

I guess (really!) that you need to say also -lglu32 -lglut32 ????



^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2011-08-10 15:35 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-08-10 14:24 ADA and Open GL ldries46
  -- strict thread matches above, loose matches on Subject: below --
2011-08-09 14:31 ldries46
2011-08-09 14:48 ` Georg Bauhaus
2011-08-09 14:51 ` Simon Wright
2011-08-10  8:58 ` ldries46
2011-08-10 11:09   ` Simon Wright
2011-08-10 13:23     ` ldries46
2011-08-10 15:35       ` Simon Wright

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox