我有一个用VC++6.0写的用OpenGL调用.3ds模型的程序使用的是NeheWindow做的,想改成Dll程序让别人调用,就是别人的程序给一个.3ds文件的文件名,作为参数调用我的Dll,请问有哪些函数需要输出,该怎么写?因为很多函数是在类里面的所以我不知道该怎么做。
//Load3dsDll.cpp
BOOL CLoad3dsDllApp::RegisterWindowClass()
{
// Register A Window Class
...
}
BOOL CLoad3dsDllApp::ChangeScreenResolution (int width, int height, int bitsPerPixel) // Change The Screen Resolution
{
...
}
BOOL CLoad3dsDllApp::CreateOpenGLWindow()
{
...
return TRUE;
}
void CLoad3dsDllApp::DestroyOpenGLWindow() // Destroy The OpenGL Window & Release Resources
{
...
}void CLoad3dsDllApp::ReshapeGL(int width, int height) // Reshape The Window When It's Moved Or Resized
{
...
}
int CLoad3dsDllApp::InitGL(GLvoid) // All Setup For OpenGL Goes Here
{
...
return TRUE; // Initialization Went OK
}
void CLoad3dsDllApp::DrawModel(t3DModel& Model)
{
...
}
void CLoad3dsDllApp::TerminateGLWindowMSG()
{
...
}
void CLoad3dsDllApp::Load3DSWnd()
{
m_Width = 480; // Width
m_Height = 360; // Height
m_bitsPerPixel = 16; // Bits Per Pixel
m_isVisible = TRUE; m_pDC = NULL; // pointer to our device context
m_hRC = NULL; RegisterWindowClass(); CreateOpenGLWindow();
m_wndMain.MoveWindow(0,0,m_Width,m_Height); m_wndMain.ShowWindow( SW_SHOW ); //SW_NORMAL
m_isVisible = TRUE; CLoad3DS *loader;
loader=NULL;
loader=new CLoad3DS();
loader->Import3DS(&m_Model, ".\\3ds\\f166.3DS"); //load 3ds Model InitGL(); Loop=TRUE; // Bool Variable To Exit Loop
BOOL isMessagePumpActive; // Message Pump Active?
MSG msg; // Window Message Structure while(Loop) // Loop Until WM_QUIT Is Received
{
isMessagePumpActive = TRUE;
while (isMessagePumpActive == TRUE) // While The Message Pump Is Active
{
// Check For Window Messages
if (PeekMessage (&msg, NULL, 0, 0, PM_REMOVE) != NULL)
{
if (msg.message != WM_QUIT) // Is The Message A WM_QUIT Message?
{
TranslateMessage(&msg);
DispatchMessage (&msg); // If Not, Dispatch The Message
}
else
// Otherwise (If Message Is WM_QUIT)
{
isMessagePumpActive = FALSE; // Terminate The Message Pump
theApp.TerminateGLWindowMSG();
}
}
else
{
if (m_isVisible == FALSE) // If Window Is Not Visible
{
WaitMessage (); // Application Is Minimized Wait For A Message
}
else // If Window Is Visible
{
m_wndMain.RenderScene(); //显示场景
}
}
}
}
}在neheWindow.cpp中还有响应函数
void CNeheWindow::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
void CNeheWindow::OnKeyUp(UINT nChar, UINT nRepCnt, UINT nFlags) 等等在Load3dsDll.def中
; Load3dsDll.def : Declares the module parameters for the DLL.LIBRARY "Load3dsDll"
DESCRIPTION 'Load3dsDll Windows Dynamic Link Library'EXPORTS
Load3DSWnd
; Explicit exports can go here不知道只用一个窗口Load3DSWnd函数做借口行不行?调用的时候是一个对话框一个按钮单击响应调用//CallLoad3dsDllDlg.cpp
void CCallLoad3dsDllDlg::OnButton1()
{
// TODO: Add your control notification handler code here
typedef void (*lpFun)(void);
//typedef void (FAR __cdecl *MYWENT)(CString);
HINSTANCE hDll; //DLL句柄
hDll = LoadLibrary("Load3dsDll.dll");
if (NULL==hDll)
{
MessageBox("DLL加载失败");
}
lpFun addFun; //函数指针
lpFun pLoad3DSWnd = (lpFun)GetProcAddress(hDll,"Load3DSWnd");
if (NULL==pLoad3DSWnd)
{
MessageBox("DLL中函数寻找失败");
}
pLoad3DSWnd();
}
两个程序调试均没有错误和警告,调用程序运行的时候就报错“0x00d56385”指令引用的“0x7c9380f1”内存该内存不能为“written”。
单步运行时F5过‘pLoad3DSWnd();’这句话时跳出“Unhandled exeception in Pcomm.exe(NTDLL.DLL) 0xC0000005: Access Violation.”
请问是怎么回事?
我是新手没有分啊,惭愧啊,先请教啦,敬请各位大虾不吝赐教啊!!
//Load3dsDll.cpp
BOOL CLoad3dsDllApp::RegisterWindowClass()
{
// Register A Window Class
...
}
BOOL CLoad3dsDllApp::ChangeScreenResolution (int width, int height, int bitsPerPixel) // Change The Screen Resolution
{
...
}
BOOL CLoad3dsDllApp::CreateOpenGLWindow()
{
...
return TRUE;
}
void CLoad3dsDllApp::DestroyOpenGLWindow() // Destroy The OpenGL Window & Release Resources
{
...
}void CLoad3dsDllApp::ReshapeGL(int width, int height) // Reshape The Window When It's Moved Or Resized
{
...
}
int CLoad3dsDllApp::InitGL(GLvoid) // All Setup For OpenGL Goes Here
{
...
return TRUE; // Initialization Went OK
}
void CLoad3dsDllApp::DrawModel(t3DModel& Model)
{
...
}
void CLoad3dsDllApp::TerminateGLWindowMSG()
{
...
}
void CLoad3dsDllApp::Load3DSWnd()
{
m_Width = 480; // Width
m_Height = 360; // Height
m_bitsPerPixel = 16; // Bits Per Pixel
m_isVisible = TRUE; m_pDC = NULL; // pointer to our device context
m_hRC = NULL; RegisterWindowClass(); CreateOpenGLWindow();
m_wndMain.MoveWindow(0,0,m_Width,m_Height); m_wndMain.ShowWindow( SW_SHOW ); //SW_NORMAL
m_isVisible = TRUE; CLoad3DS *loader;
loader=NULL;
loader=new CLoad3DS();
loader->Import3DS(&m_Model, ".\\3ds\\f166.3DS"); //load 3ds Model InitGL(); Loop=TRUE; // Bool Variable To Exit Loop
BOOL isMessagePumpActive; // Message Pump Active?
MSG msg; // Window Message Structure while(Loop) // Loop Until WM_QUIT Is Received
{
isMessagePumpActive = TRUE;
while (isMessagePumpActive == TRUE) // While The Message Pump Is Active
{
// Check For Window Messages
if (PeekMessage (&msg, NULL, 0, 0, PM_REMOVE) != NULL)
{
if (msg.message != WM_QUIT) // Is The Message A WM_QUIT Message?
{
TranslateMessage(&msg);
DispatchMessage (&msg); // If Not, Dispatch The Message
}
else
// Otherwise (If Message Is WM_QUIT)
{
isMessagePumpActive = FALSE; // Terminate The Message Pump
theApp.TerminateGLWindowMSG();
}
}
else
{
if (m_isVisible == FALSE) // If Window Is Not Visible
{
WaitMessage (); // Application Is Minimized Wait For A Message
}
else // If Window Is Visible
{
m_wndMain.RenderScene(); //显示场景
}
}
}
}
}在neheWindow.cpp中还有响应函数
void CNeheWindow::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
void CNeheWindow::OnKeyUp(UINT nChar, UINT nRepCnt, UINT nFlags) 等等在Load3dsDll.def中
; Load3dsDll.def : Declares the module parameters for the DLL.LIBRARY "Load3dsDll"
DESCRIPTION 'Load3dsDll Windows Dynamic Link Library'EXPORTS
Load3DSWnd
; Explicit exports can go here不知道只用一个窗口Load3DSWnd函数做借口行不行?调用的时候是一个对话框一个按钮单击响应调用//CallLoad3dsDllDlg.cpp
void CCallLoad3dsDllDlg::OnButton1()
{
// TODO: Add your control notification handler code here
typedef void (*lpFun)(void);
//typedef void (FAR __cdecl *MYWENT)(CString);
HINSTANCE hDll; //DLL句柄
hDll = LoadLibrary("Load3dsDll.dll");
if (NULL==hDll)
{
MessageBox("DLL加载失败");
}
lpFun addFun; //函数指针
lpFun pLoad3DSWnd = (lpFun)GetProcAddress(hDll,"Load3DSWnd");
if (NULL==pLoad3DSWnd)
{
MessageBox("DLL中函数寻找失败");
}
pLoad3DSWnd();
}
两个程序调试均没有错误和警告,调用程序运行的时候就报错“0x00d56385”指令引用的“0x7c9380f1”内存该内存不能为“written”。
单步运行时F5过‘pLoad3DSWnd();’这句话时跳出“Unhandled exeception in Pcomm.exe(NTDLL.DLL) 0xC0000005: Access Violation.”
请问是怎么回事?
我是新手没有分啊,惭愧啊,先请教啦,敬请各位大虾不吝赐教啊!!
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货