Solved

opengl render context

Posted on 2002-05-23
8
1,458 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
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
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

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

 

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

Suggested Solutions

Recently, in one of the tech-blogs I usually read, I saw a post about the best-selling video games through history. The first place in the list is for the classic, extremely addictive Tetris. Well, a long time ago, in a galaxy far far away, I was…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

809 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