用VC++做OpenGL程序框架时出现非法错误,望解决?
用VC++调试OpenGL程序框架时出现非法错误:Compiling...OpenGL.cppF:\MICROSOFTVISUALSTUDIO\VC98\OpenGL\O...
用VC++调试OpenGL程序框架时出现非法错误:
Compiling...
OpenGL.cpp
F:\MICROSOFT VISUAL STUDIO\VC98\OpenGL\OpenGL.cpp(102) : error C2601: 'WinMain' : local function definitions are illegal
F:\MICROSOFT VISUAL STUDIO\VC98\OpenGL\OpenGL.cpp(135) : error C2601: 'GameLoop' : local function definitions are illegal
Error executing cl.exe.
OpenGL.exe - 2 error(s), 0 warning(s)
------------------------分割线-----------------------------
现在把我的OpenGL.cpp的出现错误处的源程序代码复制如下:
#include "stdafx.h"
...
//WinMain()程序
INT WINAPI WinMain(HINSTANCE hInst,HINSTANCE,LPSTR,INT)
{
bool fullScreen = TRUE;
DWORD dwExStyle;
DWORD dwStyle;
RECT windowRect;
int nX=0,nY=0;
dwExStyle=WS_EX_APPWINDOW|WS_EX_WINDOWEDGE;
dwStyle =WS_OVERLAPPEDWINDOW;
int wid=GetSystemMetrics(SM_CXSCREEN);
int hei=GetSystemMetrics(SM_CYSCREEN);
nX=(wid-Width)/2;nY=(hei-Height)/2;
AdjustWindowRectEx(&windowRect,dwStyle,FALSE,dwExStyle);
char cc[]="tml";
WNDCLASSEX wc = {sizeof(WNDCLASSEX),CS_CLASSDC,MsgProc,0L,0L,GetModuleHandle(NULL),NULL,NULL,NULL,NULL,cc,NULL};
RegisterClassEx(&wc);
HWND hWnd=Create WindowEx (NULL,cc,
"OpenGL 框架",
dwStyle | WS_CLIPCHILDREN | WS_CLIPSIBLINGS,
nX,nY,
Width,Height,
NULL,
NULL,
hInst,
NULL
);
ShowWindow(hWnd,SW_SHOWDEFAULT);
UpdateWindow(hWnd);
GameLoop();
return 0;
}
//GameLoop()消息循环
void GameLoop()
{ MSG msg;
BOOL fMessage;
PeekMessage(&msg,NULL,0U,0U,PM_NOREMOVE);
while(msg.message !=WM_QUIT)
{fMessage = PeekMessage(&msg,NULL,0U,0U,PM_REMOVE);
if(fMessage)
{TranslateMessage(&msg);
DispatchMessage(&msg);
}
else
Render();
}
}
}
楼下的朋友你说我WinMain定义不对,我试过你的了,也不行啊,还是出现相同的错误.
因为我是按书上代码一步步做的,代码应该没什么问题,可是我试过多次,而且网上也找了很多资料关于解决local function definitions are illegal的问题,可我没发现什么少了"}"之类的问题,我该怎么做?
再附加问一下,我现在在VC++环境下编写OpenGL程序框架,预先没有下载好OpenGL软件,是不是要先下载??? 展开
Compiling...
OpenGL.cpp
F:\MICROSOFT VISUAL STUDIO\VC98\OpenGL\OpenGL.cpp(102) : error C2601: 'WinMain' : local function definitions are illegal
F:\MICROSOFT VISUAL STUDIO\VC98\OpenGL\OpenGL.cpp(135) : error C2601: 'GameLoop' : local function definitions are illegal
Error executing cl.exe.
OpenGL.exe - 2 error(s), 0 warning(s)
------------------------分割线-----------------------------
现在把我的OpenGL.cpp的出现错误处的源程序代码复制如下:
#include "stdafx.h"
...
//WinMain()程序
INT WINAPI WinMain(HINSTANCE hInst,HINSTANCE,LPSTR,INT)
{
bool fullScreen = TRUE;
DWORD dwExStyle;
DWORD dwStyle;
RECT windowRect;
int nX=0,nY=0;
dwExStyle=WS_EX_APPWINDOW|WS_EX_WINDOWEDGE;
dwStyle =WS_OVERLAPPEDWINDOW;
int wid=GetSystemMetrics(SM_CXSCREEN);
int hei=GetSystemMetrics(SM_CYSCREEN);
nX=(wid-Width)/2;nY=(hei-Height)/2;
AdjustWindowRectEx(&windowRect,dwStyle,FALSE,dwExStyle);
char cc[]="tml";
WNDCLASSEX wc = {sizeof(WNDCLASSEX),CS_CLASSDC,MsgProc,0L,0L,GetModuleHandle(NULL),NULL,NULL,NULL,NULL,cc,NULL};
RegisterClassEx(&wc);
HWND hWnd=Create WindowEx (NULL,cc,
"OpenGL 框架",
dwStyle | WS_CLIPCHILDREN | WS_CLIPSIBLINGS,
nX,nY,
Width,Height,
NULL,
NULL,
hInst,
NULL
);
ShowWindow(hWnd,SW_SHOWDEFAULT);
UpdateWindow(hWnd);
GameLoop();
return 0;
}
//GameLoop()消息循环
void GameLoop()
{ MSG msg;
BOOL fMessage;
PeekMessage(&msg,NULL,0U,0U,PM_NOREMOVE);
while(msg.message !=WM_QUIT)
{fMessage = PeekMessage(&msg,NULL,0U,0U,PM_REMOVE);
if(fMessage)
{TranslateMessage(&msg);
DispatchMessage(&msg);
}
else
Render();
}
}
}
楼下的朋友你说我WinMain定义不对,我试过你的了,也不行啊,还是出现相同的错误.
因为我是按书上代码一步步做的,代码应该没什么问题,可是我试过多次,而且网上也找了很多资料关于解决local function definitions are illegal的问题,可我没发现什么少了"}"之类的问题,我该怎么做?
再附加问一下,我现在在VC++环境下编写OpenGL程序框架,预先没有下载好OpenGL软件,是不是要先下载??? 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询