Please Help With C DLL



 DEVELOP > c-Plus-Plus > Please Help With C DLL

LINK TO THIS PAGE  


rating :  0   |  0


  Page 1 of 1

1

 
Topic: DEVELOP > c-Plus-Plus
User: "Matthew Hanna"
Date: 16 Oct 2003 11:31:24 AM
Object: Please Help With C DLL
I am writing a short OpenGL application in Visual Basic. I need an
extension that I can't get from the VB side. I create a dll named
glFogCoordf_Vb.dll to do the work for me. The dll fails to see the OpenGL
commands. I am at a loss as to how this can be fixed. Any ideas on how to
fix the problem? The dll is being created in MS Visual C/C++ 6.0 using the
Win32 Dynamic-Link Library Wizard. My code is as follows...
-- glFogCoordf_vb.def --
LIBRARY glFogCoordf_vb
DESCRIPTION 'Volume Fog OpenGL Extension'
EXPORTS
glFogCoordfEXT
-- glFogCoordf_vb.h --
#ifdef GLFOGCOORDF_VB_EXPORTS
#define GLFOGCOORDF_VB_API __declspec(dllexport)
#else
#define GLFOGCOORDF_VB_API __declspec(dllimport)
#endif
GLFOGCOORDF_VB_API void APIENTRY glFogCoordfEXT(const float fCoord);
-- glFogCoordf_vb.cpp --
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows
headers
#include <windows.h>
#include <olectl.h>
#include <gl\gl.h>
#include "glFogCoordf_vb.h"
#pragma comment( lib, "opengl32.lib" )
typedef void (APIENTRY * PFNGLFOGCOORDFEXTPROC) (GLfloat coord); // Declare
Function Prototype
PFNGLFOGCOORDFEXTPROC glFogCoordfEXT_func = NULL; // Our glFogCoordfEXT
Function
int Extension_Init()
{
char Extension_Name[] = "EXT_fog_coord";
MessageBox(NULL, "Checkpoint 1", "Message", MB_OK);
// Allocate Memory For Our Extension String
char* glextstring=(char *)malloc(strlen((char
*)glGetString(GL_EXTENSIONS))+1);
MessageBox(NULL, "Checkpoint 2", "Message", MB_OK);
strcpy (glextstring,(char *)glGetString(GL_EXTENSIONS)); // Grab The
Extension List, Store In glextstring
MessageBox(NULL, glextstring, "Extensions", MB_OK);
if (!strstr(glextstring,Extension_Name)) // Check To See If The
Extension Is Supported
return FALSE; // If Not, Return FALSE
free(glextstring); // Free Allocated Memory
// Setup And Enable glFogCoordEXT
glFogCoordfEXT_func = (PFNGLFOGCOORDFEXTPROC)
wglGetProcAddress("glFogCoordfEXT");
return TRUE;
}
BOOL APIENTRY DllMain( HANDLE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
switch (ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:
/* if (!Extension_Init()) {
return FALSE;
}
*/
case DLL_PROCESS_DETACH:
glFogCoordfEXT_func = NULL;
break;
}
return TRUE;
}
GLFOGCOORDF_VB_API void APIENTRY glFogCoordfEXT(const float fCoord)
{
if (glFogCoordfEXT_func == NULL) {
Extension_Init();
}
if (glFogCoordfEXT_func != NULL) {
glFogCoordfEXT_func((GLfloat)fCoord);
}
}
I get past Checkpoint 1 but the dll bombs on glGetString which I assume
means that the function isn't there. I have tried stepping through the code
during debug and it goes straight to strlen and complains about an invalid
memory address. This code was taken from a C application I wrote and it
works fine there. The OpenGL in the VB application works fine as well; as
long as I don't let it execute the call to the dll. Any help would be
greatly appreciated.
Thanks!
Matthew Hanna
.

User: "Thomas Matthews"

Title: Re: Please Help With C DLL 16 Oct 2003 02:32:17 PM
Matthew Hanna wrote:

I am writing a short OpenGL application in Visual Basic. I need an
extension that I can't get from the VB side. I create a dll named
glFogCoordf_Vb.dll to do the work for me. The dll fails to see the OpenGL
commands. I am at a loss as to how this can be fixed. Any ideas on how to
fix the problem? The dll is being created in MS Visual C/C++ 6.0 using the
Win32 Dynamic-Link Library Wizard. My code is as follows...

[snip]

Thanks!
Matthew Hanna

You need help from the experts in a Microsoft newsgroup.
This newsgroup, news:comp.lang.c++, only discusses the _standard_
C++ language which has no facilities for DLLs or OpenGL.
See the FAQ and welcome.txt links below.
--
Thomas Matthews
C++ newsgroup welcome message:
http://www.slack.net/~shiva/welcome.txt
C++ Faq: http://www.parashift.com/c++-faq-lite
C Faq: http://www.eskimo.com/~scs/c-faq/top.html
alt.comp.lang.learn.c-c++ faq:
http://www.raos.demon.uk/acllc-c++/faq.html
Other sites:
http://www.josuttis.com -- C++ STL Library book
.


  Page 1 of 1

1

 


Related Articles
 

NEWER

pg.1232     pg.940     pg.716     pg.544     pg.412     pg.311     pg.234     pg.175     pg.130     pg.96     pg.70     pg.50     pg.35     pg.24     pg.16     pg.10     pg.6     pg.3     pg.1

OLDER