`
liujiawinds
  • 浏览: 132951 次
  • 性别: Icon_minigender_1
  • 来自: 成都
社区版块
存档分类
最新评论

wglMakeCurrent

API 
阅读更多
wglMakeCurrent 函数设定OpenGL当前线程的渲染环境。以后这个线程所有的OpenGL调用都是在这个hdc标识的设备上绘制。你也可以使用wglMakeCurrent 函数来改变调用线程的当前渲染环境,使之不再是当前的渲染环境。



BOOL wglMakeCurrent(
  HDC  hdc,      // device context of device that OpenGL calls are
                 // to be drawn on
  HGLRC  hglrc   // OpenGL rendering context to be made the calling
                 // thread's current rendering context
);



参数:

hdc

设备环境的句柄。调用这个函数的线程接下来的所有OpenGL调用都将在这个hdc所标识的设备上绘制。

hglrc

函数设定的OpenGL渲染环境的句柄,作为当前线程的渲染环境。

如果hglrc为NULL,函数将使调用线程的当前渲染环境不再作为当前的渲染环境,并释放这个渲染环境所使用的设备环境。这种情况下hdc参数将被忽略。



返回值:

当wglMakeCurrent 函数调用成功,将返回TRUE,否则返回FALSE,要想得到更多的信息,请调用

GetLastError。



注意:

hdc参数的绘制表面必须是支持OpenGL的。它不需是wglCreateContext 创建hglrc时所传进来的hdc,但它必须是相同的设备并具有相同的像素格式。GDI转换的hdc将不被渲染环境所支持。当前的渲染环境将一直使用hdc设备环境直到它不再是当前渲染环境。


在切换到新的渲染环境之前,OpenGL将冲刷掉当前调用线程之前的所有渲染环境。



一个线程可以有一个渲染环境。所以一个多线程进程可以有多个渲染环境。一个线程在调用任何OpenGL函数之前必须设置一个当前渲染环境。否则所有OpenGL调用都将忽略。



在某一时刻渲染环境只能属于一个线程,你不能使一个渲染环境同时属于多个线程。



一个应用程序可以通过不同线程中的不同的当前渲染环境产生多个绘图,它支持各个线程都拥有自己的渲染环境的设备环境。



如果有错误发生,wglMakeCurrent 函数在返回之前将使渲染环境不作为线程当前的渲染环境。



MSDN原文:

wglMakeCurrent
The wglMakeCurrent function makes a specified OpenGL rendering context the calling thread's current rendering context. All subsequent OpenGL calls made by the thread are drawn on the device identified by hdc. You can also use wglMakeCurrent to change the calling thread's current rendering context so it's no longer current.

BOOL wglMakeCurrent(
  HDC  hdc,      // device context of device that OpenGL calls are
                 // to be drawn on
  HGLRC  hglrc   // OpenGL rendering context to be made the calling
                 // thread's current rendering context
);
Parameters
hdc
Handle to a device context. Subsequent OpenGL calls made by the calling thread are drawn on the device identified by hdc.
hglrc
Handle to an OpenGL rendering context that the function sets as the calling thread's rendering context.
If hglrc is NULL, the function makes the calling thread's current rendering context no longer current, and releases the device context that is used by the rendering context. In this case, hdc is ignored.

Return Values
When the wglMakeCurrent function succeeds, the return value is TRUE; otherwise the return value is FALSE. To get extended error information, call GetLastError.

Remarks
The hdc parameter must refer to a drawing surface supported by OpenGL. It need not be the same hdc that was passed to wglCreateContext when hglrc was created, but it must be on the same device and have the same pixel format. GDI transformation and clipping in hdc are not supported by the rendering context. The current rendering context uses the hdc device context until the rendering context is no longer current.

Before switching to the new rendering context, OpenGL flushes any previous rendering context that was current to the calling thread.

A thread can have one current rendering context. A process can have multiple rendering contexts by means of multithreading. A thread must set a current rendering context before calling any OpenGL functions. Otherwise, all OpenGL calls are ignored.

A rendering context can be current to only one thread at a time. You cannot make a rendering context current to multiple threads.

An application can perform multithread drawing by making different rendering contexts current to different threads, supplying each thread with its own rendering context and device context.

If an error occurs, the wglMakeCurrent function makes the thread's current rendering context not current before returning.
分享到:
评论

相关推荐

    opengl画图程序附带源代码

    wglMakeCurrent(NULL,NULL)) // Are We Able To Release The DC And RC Contexts? { MessageBox(NULL,"Release Of DC And RC Failed.","SHUTDOWN ERROR",MB_OK | MB_ICONINFORMATION); } if (!wglDeleteContext...

    gertt点阵图读取器(opengl)

    wglMakeCurrent(NULL,NULL)) // Are We Able To Release The DC And RC Contexts? { MessageBox(NULL,"Release Of DC And RC Failed.","SHUTDOWN ERROR",MB_OK | MB_ICONINFORMATION); } if (!...

    计算机图形学制作时钟源代码

    if(wglMakeCurrent(hDC,this->m_hGLContext)==FALSE) {//选为当前RC失败 return FALSE; } return TRUE; } void CMFCFrame1View::OnDestroy() { CView::OnDestroy(); // TODO: Add your message handler ...

    贪吃蛇代码

    这是一个简单的代码,运行后可以玩呦void DisableOpenGL (HWND hwnd, HDC hDC, HGLRC hRC) { wglMakeCurrent(NULL, NULL); wglDeleteContext(hRC); ReleaseDC(hwnd, hDC); }

    数据预处理之基于统计的异常值检测

    matlab+数据预处理+统计+异常值+检测+适用维度较小的数据 基于统计的异常值检测是一种利用统计学原理和技术来识别数据集中异常值或离群点的方法。这种方法通过考察数据集的统计特性来发现与其他样本显著不同的观测值。我们可以利用几种常见的方法,包括3σ(sigma)准则、Z分数(Z-score)和Boxplot(箱线图)。

    2021-2022中国中东欧智慧教育学术会议报告集-25页(1).pdf

    2021-2022中国中东欧智慧教育学术会议报告集-25页(1)

    基于形态学的权重自适应图像去噪.zip

    MATLAB是MathWorks公司出品的商业数学软件,用于数据分析、无线通信、深度学习、图像处理与计算机视觉、信号处理、量化金融与风险管理、机器人,控制系统等领域。 【主页资源】 遗传算法、免疫算法、退火算法、粒子群算法、鱼群算法、蚁群算法和神经网络算法等常用智能算法的MATLAB实现,包含TSP、LQR控制器、结合量子算法、多目标优化、粒子群等matlab程序。 MATLAB计算机视觉与深度学习实战项目:直方图优化去雾技术、基于形态学的权重自适应图像去噪、多尺度形态学提取眼前节组织、基于分水岭算法的肺癌分割诊断、基于harris 的角点检测(可以直接用matlab自带的函数)、基于K均值的据类算法分割(算法时间有点久)、 区域生长算法进行肝部肿瘤分割(原始分割精度不高)、matlab编写的图像处理相关算法代码及算法原理等等。

    基于STM32微控制器的数据采集系统的固件

    目前实现的功能: 示波器 伏特计 逻辑分析仪(实验性) PWM测量 PWM输出 基于DDS(直接数字合成)的发生器 功能的选择取决于所选的目标。在小型器件上,由于外设约束或引脚排列有限,仅实现了功能子集。 固件还可以在不同的配置之间切换。例如,和 .Voltmeter + PWMOscilloscope + PWM 固件通过虚拟 COM 端口(USB CDC 类)直接或使用 UART 转 USB 桥接器与 PC 应用程序通信。 如何运行固件 您可以在发布部分下载已编译的二进制文件,并通过 ST-Link(或任何其他调试器)或通过 USB 设备固件更新 (DFU) 下载

    An open-source HDL register code generator fast enough to run in

    vhdl

    B2141 确定进制.cpp

    B2141 确定进制

    bootstrap模板-moban6820.rar

    bootstrap模板

    岗位管理体系5大要素全解读.pdf

    岗位管理体系5大要素全解读.pdf

    php+mysql社区交流系统(系统)

    随着计算机网络的不断发展,网页逐渐融入人们的生活。快速及时的新闻浏览,五彩缤纷的网上信息,使网络与人们的生活息息相关,于是世界上又出现了第三媒体——Internet。它打破了地域限制,真正使信息得以共享,改变了人们的工作和生活方式。官方网页是企业和个人的宣传自己的重要手段,各大公司和个人主页包括演艺圈艺人,作家,大学生等,纷纷创建自己的主页和Web站点,向全世界宣告自己的存在,展示自己的产品、服务及个人爱好等等。我的系统由:会员登录、会员注册、论坛等之类的组合而成的。

    【技巧】人才盘点体系构建最佳实践.docx

    【技巧】人才盘点体系构建最佳实践.docx

    9471 - Uruk-hai Army.mpd

    9471 - Uruk-hai Army.mpd

    编译原理大作业:类似C语言的编译器设计与实现-支持加减乘除转换 print 输出转换 if 条件转换 赋值语句转换

    编译原理 大作业 基本功能:类 C 语言编译为汇编语言 支持语法: 1. 加减乘除转换 2. print 3. 输出转换 4. if 条件转换 5. 赋值语句转换 具体实现原理 源文件——词法分析——语法分析——三元式生成——目标代码生成 词法分析——预处理(识别)——分类——得到结果 语法分析——基本转换——相关语法分析 主要模块 词法分析模块-词法分析.cpp 语法分析模块-语法分析.cpp 使用模块-源.cpp 函数声明-header.h

    10240 - UCS Red Five X-wing Starfighter.mpd

    10240 - UCS Red Five X-wing Starfighter.mpd

    7307 - Duel in the Air.mpd

    7307 - Duel in the Air.mpd

    B2111 基因相关性.exe

    B2111 基因相关性

    6844 - Seismologic Vehicle.mpd

    6844 - Seismologic Vehicle.mpd

Global site tag (gtag.js) - Google Analytics