热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

什么是英特尔HD3000上正确的OpenGL初始化?-WhatistheproperOpenGLinitialisationonIntelHD3000?

IhaveaproblemwithIntelgraphicsHD3000onToshibanotebook(OSWin7x32,langC++).我在Toshiba

I have a problem with Intel graphics HD 3000 on Toshiba notebook (OS Win7 x32, lang C++).

我在Toshiba笔记本电脑上安装了英特尔图形HD 3000(OS Win7 x32,lang C ++)。

Classical single context OpenGL applications work fine but on multiple OpenGL contexts in single App creates weird behavior:

经典的单上下文OpenGL应用程序工作正常但在单个App中的多个OpenGL上下文中会产生奇怪的行为:

  1. on older versions of my apps the Intel driver cannot create second rendering context at all.
  2. 在我的应用程序的旧版本上,英特尔驱动程序根本无法创建第二个渲染上下文。

  3. after major changes in my OpenGL based software architecture behavior changed

    在我的基于OpenGL的软件架构行为的重大变化发生变化之后

    now I am able to create second rendering context but after releasing it (after use / close window) the driver cannot create any next rendering context. This has been tested on more than one app and behaves the same all the time. I wanted to get over this by having the second context at all time active but it does not work too (somehow rendering context is invalidated on Intel). For clarity the second OpenGL rendering context is used for Open/Save dialogs (preview sub-windows).

    现在我能够创建第二个渲染上下文但在释放之后(在使用/关闭窗口之后),驱动程序无法创建任何下一个渲染上下文。这已经在多个应用程序上进行了测试,并且始终表现相同。我想通过让第二个上下文始终处于活动状态来克服这个问题,但它也不起作用(某种程度上,渲染上下文在英特尔上无效)。为清楚起见,第二个OpenGL渲染上下文用于打开/保存对话框(预览子窗口)。

Driver info:

Intel(R) HD Graphics 3000
OpenGL ver: 3.1.0 - Build 9.17.10.2932

Init and exit OpenGL code (from my OpenGL engine):

初始化和退出OpenGL代码(来自我的OpenGL引擎):

//------------------------------------------------------------------------------
int OpenGLscreen::init(void *f,int textures)
    {
    if (_init) exit();
    frm=(formtype*)f;
    hdc = GetDC(frm->Handle);       // get device context
    int i;
    if (!_used)
        {
        int i,_pfid=-1,_zbit=0;
        PIXELFORMATDESCRIPTOR _pfd;
        #define pfd_test i=ChoosePixelFormat(hdc,&pfd); DescribePixelFormat(hdc,i,sizeof(_pfd),&_pfd); if (_zbit<_pfd.cDepthBits) { _zbit=_pfd.cDepthBits; _pfid=i; }
        pfd.cColorBits = 32; pfd.cDepthBits = 32; pfd_test;
        pfd.cColorBits = 24; pfd.cDepthBits = 32; pfd_test;
        pfd.cColorBits = 16; pfd.cDepthBits = 32; pfd_test;
        pfd.cColorBits = 32; pfd.cDepthBits = 24; pfd_test;
        pfd.cColorBits = 24; pfd.cDepthBits = 24; pfd_test;
        pfd.cColorBits = 16; pfd.cDepthBits = 24; pfd_test;
        pfd.cColorBits = 32; pfd.cDepthBits = 16; pfd_test;
        pfd.cColorBits = 24; pfd.cDepthBits = 16; pfd_test;
        pfd.cColorBits = 16; pfd.cDepthBits = 16; pfd_test;
        #undef pfd_test
        pfd.cDepthBits = _zbit; // iba koli warningu
        DescribePixelFormat(hdc,_pfid,sizeof(pfd),&pfd);
        pfid=ChoosePixelFormat(hdc,&pfd);
        SetPixelFormat(hdc,pfid,&pfd);
        DescribePixelFormat(hdc,pfid,sizeof(pfd),&pfd);

        znum=1<<(pfd.cDepthBits-1);
        }

    // create current rendering context
    hrc = wglCreateContext(hdc);

    if(hrc == NULL)
        {
        ShowMessage("Could not initialize OpenGL Rendering context !!!");
        _init=0;
        return 0;
        }
    if(wglMakeCurrent(hdc, hrc) == false)
        {
        ShowMessage("Could not make current OpenGL Rendering context !!!");
        wglDeleteContext(hrc);          // destroy rendering context
        _init=0;
        return 0;
        }
    if (!_used) glewInit();
    _init=1;
    _used=1;
    resize(0,0,128,128);

//  glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
//  glFrontFace(GL_CCW);                    // predna strana je proti smeru hod. ruciciek
//  glEnable(GL_CULL_FACE);                 // vynechavaj odvratene steny
//  glEnable(GL_TEXTURE_2D);                // pouzivaj textury, farbu pouzivaj z textury
//  glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL);
//  glEnable(GL_BLEND);                     // priehladnost
//  glBlendFunc(GL_SRC_ALPHA,GL_DST_ALPHA);
/*
    glEnable(GL_LIGHTING);
    glEnable(GL_LIGHT0);
    glEnable(GL_COLOR_MATERIAL);

    GLdouble MaterialAmbient  [] = {0.25, 0.25, 0.25, 1.00};
    GLdouble MaterialDiffuse  [] = {0.25, 0.25, 0.25, 1.00};
    GLdouble MaterialSpecular [] = {0.50, 0.50, 0.50, 1.00};
    GLdouble MaterialShininess[] = {15.0};                  // 0-ufocused, 128 max focus
    glMaterialfv(GL_FRONT, GL_AMBIENT  , MaterialAmbient  );
    glMaterialfv(GL_FRONT, GL_DIFFUSE  , MaterialDiffuse  );
    glMaterialfv(GL_FRONT, GL_SPECULAR , MaterialSpecular );
    glMaterialfv(GL_FRONT, GL_SHININESS, MaterialShininess);
    glColorMaterial(GL_FRONT, GL_AMBIENT_AND_DIFFUSE);

    GLdouble LightPosition [] = {0.00, 0.00, 0.00, 0.0};
    GLdouble LightAmbient  [] = {0.10, 0.10, 0.10, 1.0};
    GLdouble LightDiffuse  [] = {0.20, 0.20, 0.20, 1.0};
    GLdouble LightSpecular [] = {1.00, 1.00, 1.00, 1.0};
    glLightfv(GL_LIGHT0,GL_AMBIENT ,LightAmbient );
    glLightfv(GL_LIGHT0,GL_DIFFUSE ,LightDiffuse );
    glLightfv(GL_LIGHT0,GL_SPECULAR,LightSpecular);
    glLightfv(GL_LIGHT0,GL_POSITION,LightPosition);
    glLightModelfv(GL_LIGHT_MODEL_AMBIENT, LightAmbient);
*/
    glEnable(GL_DEPTH_TEST);                // Zbuf
    glShadeModel(GL_SMOOTH);                // gourard shading
    glClearColor(0.0f, 0.0f, 0.0f, 1.0f);   // background color
    glDepthFunc(GL_LEQUAL);

    const GLubyte *p; char a;               // get extensions list
    extensiOns="";
    #define ext_add if ((extensions!="")&&(extensions[extensions.Length()]!=' ')) extensions+=' '; for (i=0;;i++) { a=p[i]; if (!a) break; extensions+=a; }
    p=glGetString(GL_EXTENSIONS); ext_add;
    if (wglGetExtensionsStringARB) p=wglGetExtensionsStringARB(hdc); ext_add;
    if (wglGetExtensionsStringEXT) p=wglGetExtensionsStringEXT(); ext_add;

//  int hnd=FileCreate("glext.txt"); FileWrite(hnd,scr.extensions.c_str(),scr.extensions.Length()); FileClose(hnd);

    OpenGLtexture txr;
    txrs.alloc(textures);           // allocate textures name space
    font_init(txr);
    fOnt=txrs.add(txr);
    s3dl=txrs.add(txr); txrs.sizes[s3dl]._mode=GL_MODULATE;
    s3dr=txrs.add(txr); txrs.sizes[s3dr]._mode=GL_MODULATE;
    return 1;
    }
//------------------------------------------------------------------------------
void OpenGLscreen::exit()
    {
    if (!_init) return;
    wglMakeCurrent(hdc,hrc);        // use this context if multiple OpenGLs are used
    txrs.free();
    wglMakeCurrent(NULL, NULL);     // release current rendering context
    wglDeleteContext(hrc);          // destroy rendering context
    hrc=NULL;
    _init=0;
    }
//------------------------------------------------------------------------------

now the questions:

现在问题:

  1. Am I doing something wrong?

    难道我做错了什么?

    Engine is fully functional GL,GLSL,VBO,VAO,... and tested for years. Weird behavior is present only on Intel. Cards from nVidia works fine and ATI/AMD works almost fine (there are some issues but they are buggy drivers related as always for ATI especially for VBO with indices everything else works fine)

    发动机是功能齐全的GL,GLSL,VBO,VAO ......并经过多年的测试。奇怪的行为仅出现在英特尔上。来自nVidia的卡工作正常并且ATI / AMD工作得很好(有一些问题,但它们是驱动器相关的驱动器,因为ATI总是如此,特别是对于VBO,其他一切工作正常)

  2. Is there a better way to init/exit OpenGL?

    有没有更好的方法来初始化/退出OpenGL?

  3. How to properly switch between different rendering contexts?

    如何在不同的渲染上下文之间正确切换?

    I am using wglMakeCurrent(hdc,hrc) for now but may be I am missing something or there is some workaround on Intel for this.

    我现在正在使用wglMakeCurrent(hdc,hrc),但可能是我遗漏了一些东西,或者英特尔为此做了一些解决方法。

1 个解决方案

#1


0  

Your use of WGL looks correct to me (including your use of wglMakeCurrent), but I haven't used it in a while, so my memory might be foggy (to answer Q1 and Q3).

你对WGL的使用看起来对我来说是正确的(包括你使用wglMakeCurrent),但我有一段时间没用过它,所以我的记忆可能有些模糊(回答Q1和Q3)。

However, there is a better way to initialize OpenGL: use a loader library, as detailed here. As the wiki says, it's highly recommended to use a loader library rather than attempting to do it yourself.

但是,有一种更好的初始化OpenGL的方法:使用加载程序库,如此处所述。正如维基所说,强烈建议使用加载程序库而不是自己尝试。

I like to use SFML to create the OpenGL context and window, plus GLEW (only necessary for Windows) to set up the OpenGL core context functions. I've also had success with glfw, which is good for loading OpenGL 3.2+

我喜欢使用SFML来创建OpenGL上下文和窗口,加上GLEW(仅对Windows来说是必需的)来设置OpenGL核心上下文功能。我也用glfw取得了成功,这对于加载OpenGL 3.2+非常有用


推荐阅读
  • This article discusses the efficiency of using char str[] and char *str and whether there is any reason to prefer one over the other. It explains the difference between the two and provides an example to illustrate their usage. ... [详细]
  • C++字符字符串处理及字符集编码方案
    本文介绍了C++中字符字符串处理的问题,并详细解释了字符集编码方案,包括UNICODE、Windows apps采用的UTF-16编码、ASCII、SBCS和DBCS编码方案。同时说明了ANSI C标准和Windows中的字符/字符串数据类型实现。文章还提到了在编译时需要定义UNICODE宏以支持unicode编码,否则将使用windows code page编译。最后,给出了相关的头文件和数据类型定义。 ... [详细]
  • 电话号码的字母组合解题思路和代码示例
    本文介绍了力扣题目《电话号码的字母组合》的解题思路和代码示例。通过使用哈希表和递归求解的方法,可以将给定的电话号码转换为对应的字母组合。详细的解题思路和代码示例可以帮助读者更好地理解和实现该题目。 ... [详细]
  • 本文介绍了解决Netty拆包粘包问题的一种方法——使用特殊结束符。在通讯过程中,客户端和服务器协商定义一个特殊的分隔符号,只要没有发送分隔符号,就代表一条数据没有结束。文章还提供了服务端的示例代码。 ... [详细]
  • 本文介绍了设计师伊振华受邀参与沈阳市智慧城市运行管理中心项目的整体设计,并以数字赋能和创新驱动高质量发展的理念,建设了集成、智慧、高效的一体化城市综合管理平台,促进了城市的数字化转型。该中心被称为当代城市的智能心脏,为沈阳市的智慧城市建设做出了重要贡献。 ... [详细]
  • 本文主要解析了Open judge C16H问题中涉及到的Magical Balls的快速幂和逆元算法,并给出了问题的解析和解决方法。详细介绍了问题的背景和规则,并给出了相应的算法解析和实现步骤。通过本文的解析,读者可以更好地理解和解决Open judge C16H问题中的Magical Balls部分。 ... [详细]
  • Python正则表达式学习记录及常用方法
    本文记录了学习Python正则表达式的过程,介绍了re模块的常用方法re.search,并解释了rawstring的作用。正则表达式是一种方便检查字符串匹配模式的工具,通过本文的学习可以掌握Python中使用正则表达式的基本方法。 ... [详细]
  • 利用Visual Basic开发SAP接口程序初探的方法与原理
    本文介绍了利用Visual Basic开发SAP接口程序的方法与原理,以及SAP R/3系统的特点和二次开发平台ABAP的使用。通过程序接口自动读取SAP R/3的数据表或视图,在外部进行处理和利用水晶报表等工具生成符合中国人习惯的报表样式。具体介绍了RFC调用的原理和模型,并强调本文主要不讨论SAP R/3函数的开发,而是针对使用SAP的公司的非ABAP开发人员提供了初步的接口程序开发指导。 ... [详细]
  • 前景:当UI一个查询条件为多项选择,或录入多个条件的时候,比如查询所有名称里面包含以下动态条件,需要模糊查询里面每一项时比如是这样一个数组条件:newstring[]{兴业银行, ... [详细]
  • 开发笔记:实验7的文件读写操作
    本文介绍了使用C++的ofstream和ifstream类进行文件读写操作的方法,包括创建文件、写入文件和读取文件的过程。同时还介绍了如何判断文件是否成功打开和关闭文件的方法。通过本文的学习,读者可以了解如何在C++中进行文件读写操作。 ... [详细]
  • 本文讨论了在手机移动端如何使用HTML5和JavaScript实现视频上传并压缩视频质量,或者降低手机摄像头拍摄质量的问题。作者指出HTML5和JavaScript无法直接压缩视频,只能通过将视频传送到服务器端由后端进行压缩。对于控制相机拍摄质量,只有使用JAVA编写Android客户端才能实现压缩。此外,作者还解释了在交作业时使用zip格式压缩包导致CSS文件和图片音乐丢失的原因,并提供了解决方法。最后,作者还介绍了一个用于处理图片的类,可以实现图片剪裁处理和生成缩略图的功能。 ... [详细]
  • 本文讨论了一个数列求和问题,该数列按照一定规律生成。通过观察数列的规律,我们可以得出求解该问题的算法。具体算法为计算前n项i*f[i]的和,其中f[i]表示数列中有i个数字。根据参考的思路,我们可以将算法的时间复杂度控制在O(n),即计算到5e5即可满足1e9的要求。 ... [详细]
  • 本文介绍了在开发Android新闻App时,搭建本地服务器的步骤。通过使用XAMPP软件,可以一键式搭建起开发环境,包括Apache、MySQL、PHP、PERL。在本地服务器上新建数据库和表,并设置相应的属性。最后,给出了创建new表的SQL语句。这个教程适合初学者参考。 ... [详细]
  • 本文介绍了一个在线急等问题解决方法,即如何统计数据库中某个字段下的所有数据,并将结果显示在文本框里。作者提到了自己是一个菜鸟,希望能够得到帮助。作者使用的是ACCESS数据库,并且给出了一个例子,希望得到的结果是560。作者还提到自己已经尝试了使用"select sum(字段2) from 表名"的语句,得到的结果是650,但不知道如何得到560。希望能够得到解决方案。 ... [详细]
  • 本文介绍了一个题目的解法,通过二分答案来解决问题,但困难在于如何进行检查。文章提供了一种逃逸方式,通过移动最慢的宿管来锁门时跑到更居中的位置,从而使所有合格的寝室都居中。文章还提到可以分开判断两边的情况,并使用前缀和的方式来求出在任意时刻能够到达宿管即将锁门的寝室的人数。最后,文章提到可以改成O(n)的直接枚举来解决问题。 ... [详细]
author-avatar
I技男
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有