Подскажите пожалуйста как решить проблемму с компиляцией простейшего opengl приложения на платформе Windows 7
,Microsoft Visual Studio 2008.
файл opengl.cpp
Код: Выделить всё
// OpenGL.cpp
#include <windows.h>
#include <GL/gl.h>
#include "OpenGL.h"
int InitPixelFormat(HDC hdc);
void InitSettings();
namespace{
HWND hWnd;
HDC hDC;
HGLRC hRC;
}
int InitOpenGL(HWND _hWnd)
{
hWnd = _hWnd;
hDC = GetDC(hWnd);
if(!InitPixelFormat(hDC))
return 0;
hRC = wglCreateContext(hDC);
wglMakeCurrent(hDC, hRC);
InitSettings();
return 1;
}
void InitSettings()
{
}
void ReleaseOpenGL()
{
if(hRC)
{
wglMakeCurrent(hDC, 0);
wglDeleteContext(hRC);
hRC = 0;
}
if(hDC)
{
ReleaseDC(hWnd, hDC);
hDC = 0;
}
}
int InitPixelFormat(HDC hdc)
{
int pixelformat;
PIXELFORMATDESCRIPTOR pfd = {0};
pfd.nSize = sizeof(PIXELFORMATDESCRIPTOR);
pfd.nVersion = 1;
pfd.dwFlags = PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER | PFD_DRAW_TO_WINDOW;
pfd.iPixelType = PFD_TYPE_RGBA;
pfd.cColorBits = 32;
if (!(pixelformat = ChoosePixelFormat(hdc, &pfd)))
{
//Error: ChoosePixelFormat failed
return 0;
}
if(!SetPixelFormat(hdc, pixelformat, &pfd))
{
//Error: SetPixelFormat failed"
return 0;
}
return 1;
}
Код: Выделить всё
// OpenGL.h
#ifndef _OpenGL_h_
#define _OpenGL_h_
int InitOpenGL(HWND hWnd);
void ReleaseOpenGL();
#endif //_OpenGL_h_
в результате отладки выходит такое сообщение:
1>------ Построение начато: проект: opengl-1, Конфигурация: Debug Win32 ------
1>Компоновка...
1>opengl.obj : error LNK2019: ссылка на неразрешенный внешний символ __imp__wglMakeCurrent@8 в функции "int __cdecl InitOpenGL(struct HWND__ *)" (?InitOpenGL@@YAHPAUHWND__@@@Z)
1>opengl.obj : error LNK2019: ссылка на неразрешенный внешний символ __imp__wglCreateContext@4 в функции "int __cdecl InitOpenGL(struct HWND__ *)" (?InitOpenGL@@YAHPAUHWND__@@@Z)
1>opengl.obj : error LNK2019: ссылка на неразрешенный внешний символ __imp__wglDeleteContext@4 в функции "void __cdecl ReleaseOpenGL(void)" (?ReleaseOpenGL@@YAXXZ)
1>MSVCRTD.lib(crtexe.obj) : error LNK2019: ссылка на неразрешенный внешний символ _main в функции ___tmainCRTStartup
1>H:\КОД\opengl-1\opengl-1\Debug\opengl-1.exe : fatal error LNK1120: 4 неразрешенных внешних элементов
1>Журнал построения был сохранен в "file://h:\КОД\opengl-1\opengl-1\opengl-1\Debug\BuildLog.htm"
1>opengl-1 - ошибок 5, предупреждений 0
========== Построение: успешно: 0, с ошибками: 1, без изменений: 0, пропущено: 0 ==========