c++ entry point not found
Posted: 2009-08-02T06:31:53-07:00
Hi there
I am testing some win32 opengl code using image magick++ to load textures in visual c++ express 2008. Project is based off button example and has been compiling without problems
A few hicups along the way but everything is going along nicely using I used this line
gluBuild2DMipmaps(GL_TEXTURE_2D, 4, image.columns(), image.rows(),GL_RGBA, GL_UNSIGNED_BYTE, blob.data());
where I now get a procedure entry point error for constImage@Image@Magick.....@MagickCoe could not be located in CORE_RL_Magick++_.dll
Complete source is here
Any ideas?
I am testing some win32 opengl code using image magick++ to load textures in visual c++ express 2008. Project is based off button example and has been compiling without problems
A few hicups along the way but everything is going along nicely using I used this line
gluBuild2DMipmaps(GL_TEXTURE_2D, 4, image.columns(), image.rows(),GL_RGBA, GL_UNSIGNED_BYTE, blob.data());
where I now get a procedure entry point error for constImage@Image@Magick.....@MagickCoe could not be located in CORE_RL_Magick++_.dll
Complete source is here
Code: Select all
#include <Magick++.h>
#include <windows.h>
#include <gl\gl.h> // Header File For The OpenGL32 Library
#include <gl\glu.h> // Header File For The GLu32 Library
using namespace std;
using namespace Magick;
const char g_szClassName[] = "myWindowClass";
enum { ID_BUTTON = 1, ID_EDIT};
HINSTANCE hInstance; // Holds The Instance Of The Application
HWND hWnd=NULL,hButton=NULL,hEdit=NULL;
HDC hDC1=NULL;
HGLRC hglrc1=NULL;
char szFileName[MAX_PATH] = "";
float rtri = 0.0f;
float rquad = 0.0f;
GLvoid ReSizeGLScene(GLsizei width, GLsizei height) // Resize And Initialize The GL Window
{
if (height==0) // Prevent A Divide By Zero By
height=1; // Making Height Equal One
glViewport(0,0,width,height); // Reset The Current Viewport
glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
glLoadIdentity(); // Reset The Projection Matrix
gluPerspective(45.0f,(GLfloat)width/(GLfloat)height,0.1f,100.0f); // Calculate The Aspect Ratio Of The Window
glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
glLoadIdentity(); // Reset The Modelview Matrix
}
GLvoid KillGLWindow(GLvoid) // Properly Kill The Window
{
if (hglrc1) // Do We Have A Rendering Context?
{
if (!wglMakeCurrent(NULL,NULL)) // Are We Able To Release The DC And RC Contexts?
{
MessageBox(NULL,"Release Of DC And RC Failed.","SHUTDOWN ERROR",MB_OK | MB_ICONINFORMATION);
}
if (!wglDeleteContext(hglrc1)) // Are We Able To Delete The RC?
{
MessageBox(NULL,"Release Rendering Context Failed.","SHUTDOWN ERROR",MB_OK | MB_ICONINFORMATION);
}
hglrc1=NULL; // Set RC To NULL
}
if (hDC1 && !ReleaseDC(hEdit,hDC1)) // Are We Able To Release The DC
{
MessageBox(NULL,"Release Device Context Failed.","SHUTDOWN ERROR",MB_OK | MB_ICONINFORMATION);
hDC1=NULL; // Set DC To NULL
}
if (hButton && !DestroyWindow(hButton)) // Are We Able To Destroy The Window?
{
MessageBox(NULL,"Could Not Release hButton.","SHUTDOWN ERROR",MB_OK | MB_ICONINFORMATION);
hButton=NULL; // Set hWnd To NULL
}
if (hEdit && !DestroyWindow(hEdit)) // Are We Able To Destroy The Window?
{
MessageBox(NULL,"Could Not Release hEdit.","SHUTDOWN ERROR",MB_OK | MB_ICONINFORMATION);
hEdit=NULL; // Set hWnd To NULL
}
if (hWnd && !DestroyWindow(hWnd)) // Are We Able To Destroy The Window?
{
MessageBox(NULL,"Could Not Release hWnd.","SHUTDOWN ERROR",MB_OK | MB_ICONINFORMATION);
hWnd=NULL; // Set hWnd To NULL
}
if (!UnregisterClass("OpenGL",hInstance)) // Are We Able To Unregister Class
{
MessageBox(NULL,"Could Not Unregister Class.","SHUTDOWN ERROR",MB_OK | MB_ICONINFORMATION);
hInstance=NULL; // Set hInstance To NULL
}
}
int InitGL(GLvoid) // All Setup For OpenGL Goes Here
{
glShadeModel(GL_SMOOTH); // Enable Smooth Shading
glClearColor(0.0f, 0.0f, 0.0f, 0.5f); // Black Background
glClearDepth(1.0f); // Depth Buffer Setup
glEnable(GL_DEPTH_TEST); // Enables Depth Testing
glDepthFunc(GL_LEQUAL); // The Type Of Depth Testing To Do
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); // Really Nice Perspective Calculations
return TRUE; // Initialization Went OK
}
int DrawGLScene(GLvoid) // Here's Where We Do All The Drawing
{
// make ImageMagick object / read file into memory
Image image(szFileName);
Blob blob;
// set RGBA output format
image.magick("RGBA");
// write to BLOB in RGBA format
image.write(&blob);
// pointer to temporary Texture
GLuint GLtexture;
// create the temporary Texture
glGenTextures(1, &GLtexture);
// bind the texture to the next thing we make
glBindTexture(GL_TEXTURE_2D, GLtexture);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR)
gluBuild2DMipmaps(GL_TEXTURE_2D, 4, image.columns(), image.rows(),GL_RGBA, GL_UNSIGNED_BYTE, blob.data());
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Clear Screen And Depth Buffer
glLoadIdentity(); // Reset The Current Modelview Matrix
glTranslatef(0.0f,0.0f,-7.0f); // Move Right 1.5 Units And Into The Screen 7.0
glRotatef(45.0f,1.0f,1.0f,0.0f); // Rotate The Quad On The X axis ( NEW )
glBegin(GL_QUADS); // Draw A Quad
glColor3f(0.0f,1.0f,0.0f); // Set The Color To Green
glTexCoord2f (0.0, 0.0);
glVertex3f( 1.0f, 1.0f,-1.0f); // Top Right Of The Quad (Top)
glTexCoord2f (1.0, 0.0);
glVertex3f(-1.0f, 1.0f,-1.0f); // Top Left Of The Quad (Top)
glTexCoord2f (1.0, 1.0);
glVertex3f(-1.0f, 1.0f, 1.0f); // Bottom Left Of The Quad (Top)
glTexCoord2f (0.0, 1.0);
glVertex3f( 1.0f, 1.0f, 1.0f); // Bottom Right Of The Quad (Top)
glColor3f(1.0f,0.5f,0.0f); // Set The Color To Orange
glVertex3f( 1.0f,-1.0f, 1.0f); // Top Right Of The Quad (Bottom)
glVertex3f(-1.0f,-1.0f, 1.0f); // Top Left Of The Quad (Bottom)
glVertex3f(-1.0f,-1.0f,-1.0f); // Bottom Left Of The Quad (Bottom)
glVertex3f( 1.0f,-1.0f,-1.0f); // Bottom Right Of The Quad (Bottom)
glColor3f(1.0f,0.0f,0.0f); // Set The Color To Red
glVertex3f( 1.0f, 1.0f, 1.0f); // Top Right Of The Quad (Front)
glVertex3f(-1.0f, 1.0f, 1.0f); // Top Left Of The Quad (Front)
glVertex3f(-1.0f,-1.0f, 1.0f); // Bottom Left Of The Quad (Front)
glVertex3f( 1.0f,-1.0f, 1.0f); // Bottom Right Of The Quad (Front)
glColor3f(1.0f,1.0f,0.0f); // Set The Color To Yellow
glVertex3f( 1.0f,-1.0f,-1.0f); // Top Right Of The Quad (Back)
glVertex3f(-1.0f,-1.0f,-1.0f); // Top Left Of The Quad (Back)
glVertex3f(-1.0f, 1.0f,-1.0f); // Bottom Left Of The Quad (Back)
glVertex3f( 1.0f, 1.0f,-1.0f); // Bottom Right Of The Quad (Back)
glColor3f(0.0f,0.0f,1.0f); // Set The Color To Blue
glVertex3f(-1.0f, 1.0f, 1.0f); // Top Right Of The Quad (Left)
glVertex3f(-1.0f, 1.0f,-1.0f); // Top Left Of The Quad (Left)
glVertex3f(-1.0f,-1.0f,-1.0f); // Bottom Left Of The Quad (Left)
glVertex3f(-1.0f,-1.0f, 1.0f); // Bottom Right Of The Quad (Left)
glColor3f(1.0f,0.0f,1.0f); // Set The Color To Violet
glVertex3f( 1.0f, 1.0f,-1.0f); // Top Right Of The Quad (Right)
glVertex3f( 1.0f, 1.0f, 1.0f); // Top Left Of The Quad (Right)
glVertex3f( 1.0f,-1.0f, 1.0f); // Bottom Left Of The Quad (Right)
glVertex3f( 1.0f,-1.0f,-1.0f); // Bottom Right Of The Quad (Right)
glEnd(); // Done Drawing The Quad
return TRUE; // Keep Going
}
// Set up the pixel format
int MySetPixelFormat(HDC hdc)
{
PIXELFORMATDESCRIPTOR pfd = {
sizeof(PIXELFORMATDESCRIPTOR), // size of this pfd
1, // version number
PFD_DRAW_TO_WINDOW | // support window
PFD_SUPPORT_OPENGL | // support OpenGL
PFD_DOUBLEBUFFER, // double buffered
PFD_TYPE_RGBA, // RGBA type
24, // 24-bit color depth
0, 0, 0, 0, 0, 0, // color bits ignored
0, // no alpha buffer
0, // shift bit ignored
0, // no accumulation buffer
0, 0, 0, 0, // accum bits ignored
32, // 32-bit z-buffer
0, // no stencil buffer
0, // no auxiliary buffer
PFD_MAIN_PLANE, // main layer
0, // reserved
0, 0, 0 // layer masks ignored
};
int iPixelFormat;
// get the device context's best, available pixel format match
if((iPixelFormat = ChoosePixelFormat(hdc, &pfd)) == 0)
{
MessageBox(NULL, "ChoosePixelFormat Failed", NULL, MB_OK);
return 0;
}
// make that match the device context's current pixel format
if(SetPixelFormat(hdc, iPixelFormat, &pfd) == FALSE)
{
MessageBox(NULL, "SetPixelFormat Failed", NULL, MB_OK);
return 0;
}
return 1;
}
// Step 4: the Window Procedure
LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch(msg)
{
case WM_CREATE:
hButton = CreateWindow("Button","Select",BS_PUSHBUTTON | WS_CHILD | WS_VISIBLE ,50,100,100,25,hWnd,(HMENU)ID_BUTTON,GetModuleHandle(NULL),0);
if(hButton == NULL)
{
MessageBox(NULL, "Button Creation Failed!", "Error!",MB_ICONEXCLAMATION | MB_OK);
return 0;
}
hEdit = CreateWindow("Edit",NULL, WS_CHILD | WS_VISIBLE,250,50,500,450,hWnd,(HMENU)ID_EDIT,GetModuleHandle(NULL),0);
if(hEdit == NULL)
{
MessageBox(NULL, "Edit box Creation Failed!", "Error!",MB_ICONEXCLAMATION | MB_OK);
return 0;
}
if (!(hDC1=GetDC(hEdit))) // Did We Get A Device Context?
{
KillGLWindow();
MessageBox(NULL,"Can't Create A GL Device Context.","ERROR",MB_OK|MB_ICONEXCLAMATION);
return FALSE;
}
if(!MySetPixelFormat(hDC1)) // Are We Able To Set The Pixel Format?
{
KillGLWindow();
MessageBox(NULL,"Can't Set The PixelFormat.","ERROR",MB_OK|MB_ICONEXCLAMATION);
return FALSE;
}
if (!(hglrc1=wglCreateContext(hDC1))) // Are We Able To Get A Rendering Context?
{
KillGLWindow();
MessageBox(NULL,"Can't Create A GL Rendering Context.","ERROR",MB_OK|MB_ICONEXCLAMATION);
return FALSE;
}
if(!wglMakeCurrent(hDC1,hglrc1)) // Try To Activate The Rendering Context
{
KillGLWindow(); // Reset The Display
MessageBox(NULL,"Can't Activate The GL Rendering Context.","ERROR",MB_OK|MB_ICONEXCLAMATION);
return FALSE;
}
ReSizeGLScene(500, 450);
InitGL();
break;
case WM_COMMAND:
switch(LOWORD(wParam))
{
case ID_BUTTON:
OPENFILENAME ofn;
ZeroMemory(&ofn, sizeof(ofn));
ofn.lStructSize = sizeof(ofn); // SEE NOTE BELOW
ofn.hwndOwner = hWnd;
ofn.lpstrFilter = "Text Files (*.txt)\0*.txt\0All Files (*.*)\0*.*\0";
ofn.lpstrFile = szFileName;
ofn.nMaxFile = MAX_PATH;
ofn.Flags = OFN_EXPLORER | OFN_FILEMUSTEXIST | OFN_HIDEREADONLY;
ofn.lpstrDefExt = "txt";
if(GetOpenFileName(&ofn))
{
}
}
break;
case WM_CLOSE:
PostQuitMessage(0);
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hWnd, msg, wParam, lParam);
}
return 0;
}
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR lpCmdLine, int nCmdShow)
{
InitializeMagick("C:\\imagemagick\\bin");
BOOL done=FALSE;
WNDCLASSEX wc;
MSG msg;
//Step 1: Registering the Window Class
wc.cbSize = sizeof(WNDCLASSEX);
wc.style = 0;
wc.lpfnWndProc = WndProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = hInstance;
wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.hbrBackground = (HBRUSH)GetSysColorBrush(COLOR_3DFACE);
wc.lpszMenuName = NULL;
wc.lpszClassName = g_szClassName;
wc.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
if(!RegisterClassEx(&wc))
{
MessageBox(NULL, "Window Registration Failed!", "Error!",
MB_ICONEXCLAMATION | MB_OK);
return 0;
}
hInstance = GetModuleHandle(NULL);
// Step 2: Creating the Window
hWnd = CreateWindowEx(
WS_EX_CLIENTEDGE,
g_szClassName,
"OpenGL image viewer with Magick++",
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, CW_USEDEFAULT, 800, 600,
NULL, NULL, hInstance, NULL);
if(hWnd == NULL)
{
MessageBox(NULL, "Window Creation Failed!", "Error!",MB_ICONEXCLAMATION | MB_OK);
return 0;
}
ShowWindow(hWnd, nCmdShow);
UpdateWindow(hWnd);
while(!done) // Loop That Runs While done=FALSE
{
if (PeekMessage(&msg,NULL,0,0,PM_REMOVE)) // Is There A Message Waiting?
{
if (msg.message==WM_QUIT) // Have We Received A Quit Message?
{
done=TRUE; // If So done=TRUE
}
else // If Not, Deal With Window Messages
{
TranslateMessage(&msg); // Translate The Message
DispatchMessage(&msg); // Dispatch The Message
}
}
else // If There Are No Messages
{
DrawGLScene(); // Draw The Scene
SwapBuffers(hDC1); // Swap Buffers (Double Buffering)
}
}
// Shutdown
KillGLWindow(); // Kill The Window
return (msg.wParam); // Exit The Program
}