使用opengl过程中遇到的问题和寻找到的解决办法

上学期进行图形学选修课程,在进行课程大作业的过程中,遇到了很多问题,主要是在环境配置以及编程中一些语法的问题。

1.Error: argument of type ‘const char*’ is incompatible with parameter of type ‘LPCWSTR’

即:const char to LPCTSTR不能转化问题,
Visual C++ 里cannot convert parameter 1 from ‘const char [13]‘ to ‘LPCTSTR’造成不能运行的原因主要是之前版本中增加了一些参数类型的安全性检查,所以通常微软给出的解决办法有两个:

Change your project configuration to use multibyte strings. Press ALT+F7 to open the properties, and navigate to Configuration Properties > General. Switch Character Set to “Use Multi-Byte Character Set”.
Indicate that the string literal, in this case “Hello world!” is of a specific encoding. This can be done through either prefixing it with L, such as L”Hello world!”, or surrounding it with the generic _T(“Hello world!”) macro. The latter will expand to the L prefix if you are compiling for unicode (see #1), and nothing (indicating multi-byte) otherwise.
但是如果是变量,不是常量字符串的话,就还是会有问题。最痛快的办法就是在建立工程时,直接选不用那个Use Unicode libraries ,这样就不会再遇到这个问题了。

2.Win32窗口无法显示出来?

90% 是 LRESULT CALLBACK wndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam); 函数的消息处理分支逻辑不正确,比如:(当这种情况发生时,最快的排错法子是:用beyong compare来比较文本)

...
    case  WM_SIZE: {

        resizeGLScence(LOWORD(lParam),HIWORD(lParam));
        return 0;
        }
    }
    return DefWindowProc(hWnd,uMsg,wParam,lParam);
}
写成...
case WM_SIZE:

resizeGLScence(LOWORD(lParam),HIWORD(lParam)); return 0; } return DefWindowProc(hWnd,uMsg,wParam,lParam); } }

3.无法定位程序输入点_glewInit@0于动态链接库glew32.dll

在使用cmake编译freetype-gl后,使用vs2010运行程序出现”无法定位程序输入点_glewInit@0于动态链接库glew32.dll“,原因是cmake使用程序中带的glew32.lib库进行链接,但是运行时用的是windows中的动态链接库glew32.dll进行链接。而这个是我自己下载的glew32.dll,不是程序中带有的glew32.dll,由于两个版本不相同。导致了定位错误。将程序中的glew32.lib对应的glew32.dll替换system32/systemW64中的glew32.dll即可

转载于:https://www.cnblogs.com/zhaogang3015207537/p/8551081.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值