如何编写一个检查openGL支持的安装程序? [英] How to write an installer that checks for openGL support?

查看:118
本文介绍了如何编写一个检查openGL支持的安装程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一个使用OpenGL的3D查看器,但是我们的客户有时会抱怨它不起作用".我们怀疑这些问题中的大多数是由他们试图在商务笔记本电脑上尝试使用(实际上是现代3D实时游戏)造成的.

We have a 3D viewer that uses OpenGL, but our clients sometimes complain about it "not working". We suspect that most of these issues stem from them trying to use, what is in effect a modern 3d realtime game, on a businiss laptop computer.

我们如何在使用的Windows MSI安装程序中检查对openGL的支持?

此外,如果您可以回答"OpenGL支持的图形卡列表?",那也很棒.奇怪的是,谷歌在这里无济于事.

And as a side note, if you can answer "List of OpenGL supported graphic cards?", that would also be greate. Strange that google doesnt help here..

推荐答案

取决于客户不工作"的含义.可能是以下之一:

Depends on what the customers mean by "not working". It could be one of:

  1. 由于缺少某些OpenGL支持,它根本无法安装/启动.
  2. 它启动了,但随后崩溃了.
  3. 它启动,不会崩溃,但是渲染已损坏.
  4. 它可以正确启动和渲染所有内容,但是性能却很糟糕.

所有Windows版本(自95开始)都内置了OpenGL支持.因此,除非您的应用程序需要更高的OpenGL版本,否则不太可能导致上述情况1).

All Windows versions (since 95) have OpenGL support built-in. So it's unlikely to cause situation 1) above, unless you application requires higher OpenGL version.

但是,默认的OpenGL实现是带有软件渲染的OpenGL 1.1.如果用户未手动安装具有OpenGL支持的驱动程序(从NVIDIA/AMD/Intel网站下载的任何驱动程序都将具有OpenGL),则它们将默认为该缓慢且较旧的实现.这很可能导致上述情况3)和4).

However, that default OpenGL implementation is OpenGL 1.1 with software rendering. If user did not manually install drivers that have OpenGL support (any driver downloaded from NVIDIA/AMD/Intel site will have OpenGL), they will default to this slow and old implementation. This is quite likely to cause situations 3) and 4) above.

即使可以使用OpenGL,在Windows上,OpenGL驱动程序也不是很健壮.驱动程序中的各种错误很可能导致情况2),在这种情况下,执行有效的操作会导致驱动程序崩溃.

Even if OpenGL is available, on Windows OpenGL drivers are not very robust, to say mildly. Various bugs in the drivers are very likely to cause situation 2), where doing something valid causes a crash in the driver.

这是一个C ++/WinAPI代码片段,它创建一个虚拟OpenGL上下文并检索信息(GL版本,图形卡名称,扩展名等):

Here's a C++/WinAPI code snippet that creates a dummy OpenGL context and retrieves info (GL version, graphics card name, extensions etc.):

// setup minimal required GL
HWND wnd = CreateWindow(
    "STATIC",
    "GL",
    WS_OVERLAPPEDWINDOW | WS_CLIPSIBLINGS | WS_CLIPCHILDREN,
    0, 0, 16, 16,
    NULL, NULL,
    AfxGetInstanceHandle(), NULL );
HDC dc = GetDC( wnd );

PIXELFORMATDESCRIPTOR pfd = {
    sizeof(PIXELFORMATDESCRIPTOR), 1,
    PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL,
    PFD_TYPE_RGBA, 32,
    0, 0, 0, 0, 0, 0,
    0, 0, 0, 0, 0, 0, 0,
    16, 0,
    0, PFD_MAIN_PLANE, 0, 0, 0, 0
};

int fmt = ChoosePixelFormat( dc, &pfd );
SetPixelFormat( dc, fmt, &pfd );

HGLRC rc = wglCreateContext( dc );
wglMakeCurrent( dc, rc );

// get information
const char* vendor = (const char*)glGetString(GL_VENDOR);
const char* renderer = (const char*)glGetString(GL_RENDERER);
const char* extensions = (const char*)glGetString(GL_EXTENSIONS);
const char* version = (const char*)glGetString(GL_VERSION);

// DO SOMETHING WITH THOSE STRINGS HERE!

// cleanup
wglDeleteContext( rc );
ReleaseDC( wnd, dc );
DestroyWindow( wnd );

您可以以某种方式将该代码插入安装程序或应用程序,并至少检查GL版本是否为1.1;这将检测到未安装驱动程序"的情况.要解决实际的OpenGL驱动程序错误,必须找出它们并加以解决.很多工作.

You could somehow plug that code into your installer or application and at least check GL version for being 1.1; this will detect "driver is not installed" situation. To work around actual OpenGL driver bugs, well, you have to figure them out and work around them. Lots of work.

这篇关于如何编写一个检查openGL支持的安装程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆