Solved

opengl render context

Posted on 2002-05-23
8
1,463 Views
Last Modified: 2013-12-26
In windows GDI, when you want to draw to the screen you create a device context and use the HDC (handle to the device context) with any function, for example:
BOOL Ellipse(HDC hdc, int nLeftRect, ...);

now...
in opengl programing you don't specify the HRC (handle to render context) every time you use opengl function.
how does it work ?
In case of two different processes that run in the same time, how the opengl dll know which process called. why it is importent to the opengl dll to know that?, this is because every process defines states for the opengl (for example line stippling), that means that the opengl should apply the line stippling state according to the current process which request to draw a line.

how does it work ?
hope i explained the question :)
0
Comment
Question by:Ronnie_Shmuel
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
8 Comments
 
LVL 5

Expert Comment

by:Jan Louwerens
ID: 7043013
HDC is a structure used by Windows to draw to the screen.
OpenGL does not draw to the screen using windows. It accesses the video hardware directly, through the use of your video drivers.

An analogy could be that you could draw with a pen or with a pencil. And in your question, you're asking how the pencil can draw without using any ink. The ink is just the means of how the pen draws, not the pencil. And HDC is a means of how Windows draws, but not OpenGL
0
 
LVL 1

Accepted Solution

by:
nomad516 earned 300 total points
ID: 7113232
yep, you don't specify the HRC because you told
openGL that a window uses this specific RC.

I have a tutorial at: http://nomadonline.esmartweb.com

Take a look at the first opengl tutorial (setting
it up), it explains where to "bind" the RC and the
window.

Hope this helps!
0
 

Expert Comment

by:Jitender
ID: 7328742
to accomplish the portablity of the core Open GL  functions each environment must implement some means specifying a current rendering window before executing any OPEN GL commands.just as the windows GDI functions use the windows device contexts ,the OpenGl environment is embodied in what is known as rendering context .just as device contxet remembers settings abt drawing modes and commands for the GDI,teh rendering context remembers Opengl
settings and commands

0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:Ronnie_Shmuel
ID: 7330457
you answered what are role of the rendering context. but the question is: HOW DOES THE OPENGL DLL KNOW which process (in case of more then one) called him and accordingly USE it's RENDERING CONTEXT. in windows programing we specify the device context but in openGL we do not do that in any place.

hope that's clear !
0
 

Expert Comment

by:Vincenz
ID: 7395116
Copied from the MSDN library:
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
);

Hope this helps
0
 

Expert Comment

by:Vincenz
ID: 7395121
To create such a opengl specific rendering context. (Just like HRC, just that opengl has their own).  You use the function wglCreateContext.
Again from MSDN

The wglCreateContext function creates a new OpenGL rendering context, which is suitable for drawing on the device referenced by hdc. The rendering context has the same pixel format as the device context.

HGLRC wglCreateContext(
  HDC  hdc   // device context of device that the rendering context
             // will be suitable for
);

There you go
0
 

Expert Comment

by:Vincenz
ID: 7395125
This is what nomad meant when he said, "look at tutorial...".  So I think, with the addition of my comments, his explanation is clear enough.  So give him the points :)
0
 

Author Comment

by:Ronnie_Shmuel
ID: 7402185
sorry nomad for the long time it took me to give you the point. you should thanks Vincenz which explained me your answer.

tnx Vincenz!
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Artificial Intelligence comes in many forms, and for game developers, Path-Finding is an important ability for making an NPC (Non-Playable Character) maneuver through terrain.  A* is a particularly easy way to approach it.  I’ll start with the algor…
As game developers, we quickly learn that Artificial Intelligence (AI) doesn’t need to be so tough.  To reference Space Ghost: “Moltar, I have a giant brain that is able to reduce any complex machine into a simple yes or no answer. (http://www.youtu…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question