Solved

opengl render context

Posted on 2002-05-23
8
1,442 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
 

Author Comment

by:Ronnie_Shmuel
Comment Utility
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
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 

Expert Comment

by:Vincenz
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

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…
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…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

744 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now