1. Dll's
- Posted by Paul Martin <twilight at WCC.NET> Mar 20, 1999
- 374 views
Hello all, I have a question about DLL's and wrappers. I'm currently putting together a wrapper for OpenGL. The question I have pertains to pointers and values that are passed to a function or procedure. Let's suppose I come across a line in the C source that the DLL was made, like: WINGDIAPI void APIENTRY glColor3ui (GLuint red, GLuint green, GLuint blue); This would translate to: constant gl_Color3ui = define_c_proc(OpenGL, "glColor3ui",{C_INT,C_INT,C_INT}) Right? But what if I run into this: WINGDIAPI void APIENTRY glTexCoord1dv (const GLdouble *v); Does it translate to: constant gl_TexCoordldv = define_c_proc(OpenGL, "glTexCoordldv",{C_POINTER}) Does the "*" denote a pointer? If so, would there be any other instances where I would need to use a pointer instead of passing or receiving a value directly? Also a question for Robert Craig. Are you going to ever install code into Euphoria that will allow for easier access to DLL's and possibly eliminate the need for wrappers. Thanks Paul Martin
2. Re: Dll's
- Posted by Daniel Berstein <daber at PAIR.COM> Mar 20, 1999
- 376 views
At 01:04 PM 20-03-1999 , you wrote: >Hello all, > >I have a question about DLL's and wrappers. I'm currently putting together >a wrapper >for OpenGL. The question I have pertains to pointers and values that are >passed to >a function or procedure. > >Let's suppose I come across a line in the C source that the DLL was made, >like: > >WINGDIAPI void APIENTRY glColor3ui (GLuint red, GLuint green, GLuint blue); > >This would translate to: > >constant gl_Color3ui = define_c_proc(OpenGL, "glColor3ui",{C_INT,C_INT,C_INT}) > >Right? Depends on what GLuint is. If it's simply another way to say UINT, then your parameters should be C_UINT. >But what if I run into this: > >WINGDIAPI void APIENTRY glTexCoord1dv (const GLdouble *v); > >Does it translate to: > >constant gl_TexCoordldv = define_c_proc(OpenGL, "glTexCoordldv",{C_POINTER}) > >Does the "*" denote a pointer? If so, would there be any other instances where >I would need to use a pointer instead of passing or receiving a value >directly? Yes, you'll need to pass the memory address of a GLdouble variable. You can use allocate() to allocate and get the memory address, then you poke() to the memory block the appropiate value(s), you can use atom_to_float64 and float64_to_atom to read/write double floating point values. Example: v = allocate(8) -- allocate 8 bytes poke(v, atom_to_float64(value)) -- fill the buffer c_proc(gl_TexCoordldv, {v}) Regards, Daniel Berstein [ daber at pair.com ]
3. Re: Dll's
- Posted by Robert Craig <rds at ATTCANADA.NET> Mar 20, 1999
- 383 views
Paul Martin writes: > Also a question for Robert Craig. Are you going to ever install > code into Euphoria that will allow for easier access to DLL's and > possibly eliminate the need for wrappers. When you call a routine written in one language from a routine written in a very different language, with very different data types, I think it's inevitable that you will have some awkwardness. Once a "wrapper" Euphoria routine has been written, the awkwardness goes away, since you can call the Euphoria routine just like any other Euphoria routine. In setting up a call to a C routine, you must (unfortunately) understand something about C declarations. The situation is very similar in DOS32, where you set up a call to a DOS software interrupt. The mechanism is a bit ugly, but you only have to figure it out once, and then you and others can simply call the Euphoria "wrapper" routine. Regards, Rob Craig Rapid Deployment Software http://members.aol.com/FilesEu/
4. Re: Dll's
- Posted by Paul Martin <twilight at WCC.NET> Mar 21, 1999
- 368 views
Hello again, Sorry, I have a couple more questions. I ran into this while looking over the code for GLUT, and I'm not sure how to handle it. /* Stroke font opaque addresses (use constants instead in source code). */ extern void *glutStrokeRoman; /* Stroke font constants (use these in GLUT program). */ #define GLUT_STROKE_ROMAN (&glutStrokeRoman) What is going on here, and is there a way to port this into Euphoria? I also ran into this: extern void APIENTRY glutButtonBoxFunc(void (*)(int button, int state)); Is this passing a pointer to a structure containing button, and state? Thanks Paul Martin
5. Re: Dll's
- Posted by The AfterBeat <afterbeat at GEOCITIES.COM> Mar 21, 1999
- 375 views
Paul Martin wrote: > Hello again, > > Sorry, I have a couple more questions. I ran into this while looking over > the code for > GLUT, and I'm not sure how to handle it. > > /* Stroke font opaque addresses (use constants instead in source code). */ > extern void *glutStrokeRoman; > > /* Stroke font constants (use these in GLUT program). */ > #define GLUT_STROKE_ROMAN (&glutStrokeRoman) > > What is going on here, and is there a way to port this into Euphoria? > Okay, well in C, the "extern" keyword defines an external variable, or, in other words, lets the compiler know that a variable with the given name exists, but it's going to be defined somewhere else, but, no, that can't really be ported to Euphoria, because those are just variable declarations.. > > I also ran into this: > > extern void APIENTRY glutButtonBoxFunc(void (*)(int button, int state)); > > Is this passing a pointer to a structure containing button, and state? Nope. That's passing a pointer to a function. Example: /* Define a pointer to a function */ void (*__void_func)(int i); /* Make __void_func point to exit() */ __void_func = exit; /* Call the function that __void_func points to */ (*__void_func)(1); I'm not sure if that right there will help, but, if you wanna pass a function pointer to a C routine, first, you'll have to create a Euphoria routine, get the address of it through the call_back() function, and pass that value to the C function you're trying to call.. Or something like that.. Erm, well, I hope I made sense.. *heh* > > > Thanks > Paul Martin Austin Cathey (aka The AfterBeat)