Solved

opengl render context

Posted on 2002-05-23
8
1,455 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
Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

 

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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

What is RenderMan: RenderMan is a not any particular piece of software. RenderMan is an industry standard, defining set of rules that any rendering software should use, to be RenderMan-compliant. Pixar's RenderMan is a flagship implementation of …
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 Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

776 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