控制台窗口有图标,但OpenGL/GLUT窗口没有.为什么? [英] Console-window has icon, but OpenGL/GLUT window don't have. Why?
问题描述
我在Windows下用C/C ++/OpenGL/GLUT编写程序.我想在程序中添加一个图标.我使用MinGW和命令提示符来编译我的一个.cpp文件.我为自己编写了一些.bat文件,可以将其编译为调试模式,发布模式等.
I write a program in C / C++ / OpenGL / GLUT under Windows. I want to add an icon to my program. I use MinGW and command prompt to compile my only one .cpp file. I wrote myself some .bat files, which I can compile to debug-mode, release-mode, and things like that.
我想在程序中添加一个图标.因此,我制作了一个新的编译蝙蝠,如下所示:
I want to add an icon to my program. So, I made a new compile bat, that looks like this:
windres resource.rc object.o
set PATH=%PATH%;c:\mingw\bin
g++ program.cpp object.o >>>some other settings<<<
我有一个.ico文件和一个使用资源脚本"语言的资源文件.资源文件如下所示:
I have a .ico file, and a resource file in "resource script" language. Resource file looks like this:
#ifndef _resource_rc
#define _resource_rc
MAINICON ICON "icons\\icon1.ico"
#endif
现在,问题是:我编译了这些东西,并且得到了发行版.exe,如果在文件处理程序中查看它,则可以看到.exe文件附近的图标,如果运行它,则可以是角落里的图标.但是,我的程序从控制台模式菜单开始.如果您在菜单中旅行,然后选择一个给定的菜单点,那么之后,您可以启动一个用OpenGL/GLUT编写的图形窗口.问题是,控制台窗口带有图标,但是OpenGL/GLUT窗口没有.它具有一个基本的.exe图标(蓝色边框,内部为白色矩形),而不是我的特定图标.这不好:-(
Now, the problem: I compile these things, and I got a release .exe, if I looks it in a file-handler program, I can see the icon near the .exe file, and if I run it, there is an icon in the corner. But, my program starts with a console-mode menu. If you travel in the menu, and choose a given menu-point, after that, you can start a graphic window, which wrote in OpenGL / GLUT. The problem is, that the console-window has the icon, but the OpenGL / GLUT window don't. It has a basic .exe icon (blue border, white rectangle inside), and not my specific icon. This is not good :-(
如何解决OpenGL/GLUT窗口带有我的图标,而不是默认图标的问题?
How can I solve, that the OpenGL / GLUT window has my icon, and not the default?
感谢您的回答,由于我的语法而感到抱歉:-)
Thank for answers, and sorry because of my grammar :-)
推荐答案
以跨平台方式执行此操作的唯一方法(如果对您而言至关重要)是使您的应用程序不是控制台应用程序.使它成为一个创建控制台的Windows应用程序.因此您的主窗口将是OpenGL窗口,而控制台窗口将是辅助窗口.
The only way to do this in a cross-platform way, if it matters that much to you, is to make your application not a console application. Make it a Windows application that creates a console. so your main window will be the OpenGL window, and the console window will be secondary.
在Windows上创建控制台窗口并将其连接到标准输入/输出不是一个简单的过程,但是可以完成.
Creating a console window on Windows and hooking it up to standard in/out is not a trivial process, but it can be done.
这篇关于控制台窗口有图标,但OpenGL/GLUT窗口没有.为什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!