View Poll Results: OpenGL or DirectX?

Voters
22. You may not vote on this poll
  • OpenGL

    9 40.91%
  • DirectX

    13 59.09%

Thread: DirectX/OpenGL

  1. #31
    Registered User
    Join Date
    Jul 2002
    Posts
    273
    Originally posted by no-one
    lets say you have a DC, right? and then you make two RC's in two threads.

    and you have one thread drawing lets say an object, and the other drawing a gui. will this work? yes! why? OpenGL is thread safe.
    the current RC is a global state, if windows context switches in the middle of your drawing to the first RC, you're global current RC is still set to that of the first. Context switches can happen at any time and you're rendering depends heavily on which RC is current. What would you do if you context switch between the two rendering threads 5 times before the rendering was done?

    thread1 SetMyRCCurrent() //RC 1 is current
    thread1 DrawaPolygon() //draw to RC1 - correct
    thread2 SetMyRCCurrent() //RC 2 is current
    thread1 DrawaPolygon() //draw to RC2 - wrong
    thread2 DrawaPolygon() //draw to RC2 - correct
    thread2 DrawaPolygon() //draw to RC2 - correct
    thread1 DrawaPolygon() //draw to RC2 - wrong
    thread2 EndDrawing() //end
    thread1 EndDrawing()

    look, I don't expect you to understand this if you have never done multi-threading but stop being so much of a know it all.
    always looking, make an offer. get me out of this place.

  2. #32
    Banned Troll_King's Avatar
    Join Date
    Oct 2001
    Posts
    1,784
    Originally posted by Hershlag

    the current RC is a global state, if windows context switches in the middle of your drawing to the first RC, you're global current RC is still set to that of the first. Context switches can happen at any time and you're rendering depends heavily on which RC is current. What would you do if you context switch between the two rendering threads 5 times before the rendering was done?

    thread1 SetMyRCCurrent() //RC 1 is current
    thread1 DrawaPolygon() //draw to RC1 - correct
    thread2 SetMyRCCurrent() //RC 2 is current
    thread1 DrawaPolygon() //draw to RC2 - wrong
    thread2 DrawaPolygon() //draw to RC2 - correct
    thread2 DrawaPolygon() //draw to RC2 - correct
    thread1 DrawaPolygon() //draw to RC2 - wrong
    thread2 EndDrawing() //end
    thread1 EndDrawing()

    look, I don't expect you to understand this if you have never done multi-threading but stop being so much of a know it all.
    If you find a problem with mesaGL than you fix the code. The library is open source. You work as a real programmer and don't become dependent on the vendor. Many sophisticated apps have been designed with OpenGL. It's use is very wide spread. I don't know whether or not it is perfect, however at least you can learn from it and obviously it is widely accepted and at least you are not working as an end user for a monopoly. If we all worked for a monopoly than there would be very little original thought. We would all be following one idea dictated by advertising. In reality there should be a variety of choices, not just one or two or three or four. Hopefully this will be possible once standards are set in place and hardware manufacturers are not controlled by a monopolistic ambition to close the doors to competition.

  3. #33
    Registered User
    Join Date
    Jul 2002
    Posts
    273
    TK, as usual your post has nothing to do with the topic being discussed. I use OpenGL. I like OpenGL. no-one and I have just been going back and forth as to weither it is thread-safe. This is a concept relevant only to multi-threaded applications. Even in that case if you keep all openGL instructions in a single thread you are fine. And that is how I will be using it in my unique case.

    The reason the dialog had started was that I wanted to use it in multiple threads drawing to different windows as to appear to be drawing at the same time. This is simply not reasonable because of the reasons I have laid out so I won't try. The second window will just have to wait till the first window is done. that's unfortunate but a fact of life with OpenGL. Somehow along the way, no-one has decided to take it as a personal attack against his openGL baby.
    always looking, make an offer. get me out of this place.

  4. #34
    Has a Masters in B.S.
    Join Date
    Aug 2001
    Posts
    2,263
    >no-one, have you worked with mesaGL?

    unfortunatly, no. but i hope to soon.

    >What kind of apps can you build with it.

    anything the latest OpenGL spec they have implemented allows, thye update mesa constanly

    Hershlag,

    I think here might be where you confused. i think were talking about two different problems...

    ok, lets try this example.

    problem:

    you what two seperate threads and two seperate contexts, rendering to the same DC at once right?

    using your example, slightly modified, do this:

    [CODE]

    thread1 CreateRC()
    thread1 MakeCurrent()
    thread2 CreateRC()
    thread2 MakeCurrent()

    //now both can draw simultaneously
    thread1 DrawaPolygon() //draw to RC1 - correct
    thread1 DrawaPolygon() //draw to RC2 - correct
    thread2 DrawaPolygon() //draw to RC2 - correct
    thread2 DrawaPolygon() //draw to RC2 - correct
    thread1 DrawaPolygon() //draw to RC2 - correct
    thread2 EndDrawing() //end
    thread1 EndDrawing() //end

    [CODE]

    and it works, why?

    you can only have one rendering context current per thread, and the thread must own its RC to draw simultaniously.

    The problem you were having is this, you create both RC's in a single thread and have two threads try and use them, so your only setting the current thread in the RC's creating thread.

    >look, I don't expect you to understand this if you have never done multi-threading but stop being so much of a know it all.

    i've done quite a bit of multithreading in my day, stop being a smart ass.
    ADVISORY: This users posts are rated CP-MA, for Mature Audiences only.

  5. #35
    Registered User
    Join Date
    Jul 2002
    Posts
    273
    no-one.... understand something. the conversation was started by a question that I asked about multithreading in OpenGL. if you're going to insist that the question was about two RCs on a single DC I must insist that you QUOTE that. The fact is I never said that and you're in la la land. you're modified example is NOT the situation I have been talking about. and to be quite honest, is pointless. There is no good reason to have two RCs on a single DC. Look back at the history of my posts about this. you have obviously been dancing around like a crazy person in your brain. congratulations.
    always looking, make an offer. get me out of this place.

  6. #36
    Registered User
    Join Date
    Jul 2002
    Posts
    273
    never mind, I'll do it for you
    Originally posted by Hershlag
    well the thing is, this is an internet app. It downloads models as it's running.

    But here's the real question. what if you have two windows open, both opengl. Certainly they should both have their own material, lighting, matrix queue, etc... right? I don't see how you can have these things unique to an rc. RC and display lists seem to be the only things that are per-instance.
    When you are trying to draw to both at the same time, you'll have overlapping state changes. THIS IS BAD!!!! any ideas?
    this is the first post that described the situation. CLEARLY I'm talking about two different windows, therefore two different RCs. like I said. lala land
    always looking, make an offer. get me out of this place.

  7. #37
    Has a Masters in B.S.
    Join Date
    Aug 2001
    Posts
    2,263
    Then what the hell have WE been talking about?

    i'll clarify for you:
    OpenGL thread safty.

    OpenGL is thread safe.

    >
    The reason the dialog had started was that I wanted to use it in multiple threads drawing to different windows as to appear to be drawing at the same time.
    <

    so whats the problem, Make two DC's one for each window in their respective threads two RC's then DRAW! WOO!

    >The fact is I never said that and you're in la la land.

    it's quite true, i've been there! and i love it.

    >you're modified example is NOT the situation I have been talking about.

    then usen it as a template, and modify it to make it work for your needs!!!!

    >
    if you're going to insist that the question was about two RCs on a single DC I must insist that you QUOTE that.
    <

    we were never talking about anything specific to the number of DC's in this thread

    maybe your thinking of this one

    http://www.cprogramming.com/cboard/s...threadid=21889

    >and to be quite honest, is pointless.

    then you missed the point of this discussion entirly.

    >There is no good reason to have two RCs on a single DC.

    oh?, that is your opinion.

    > you have obviously been dancing around like a crazy person in your brain. congratulations.

    thank you, thank you all very very much!! woo woooo1!! HAHAHAHAHAH!! woo AAAAAHAHAHHAAHAAHAHAHAHAHAHAHAA!!!
    ADVISORY: This users posts are rated CP-MA, for Mature Audiences only.

  8. #38
    Has a Masters in B.S.
    Join Date
    Aug 2001
    Posts
    2,263
    >
    this is the first post that described the situation. CLEARLY I'm talking about two different windows, therefore two different RCs. like I said. lala land
    <

    it doesn't matter... the concept still applies, create your RC's in different threads with the particular windows DC and go to town.
    ADVISORY: This users posts are rated CP-MA, for Mature Audiences only.

  9. #39
    Registered User
    Join Date
    Jul 2002
    Posts
    273
    Now that we have that nonsense cleared up.....

    I'll start from the beginning.

    I have a multithreaded app. I want to render at the same time to both windows. The problem is that the "current window" is a global setting and when the system context switches (the process of switching between threads) the second thread is still trying to work on the other RC as in the previous example. As it is a global state you don't have the ability to assume you are talking to the right RC when you make a call. these calls don't take RCs as parameters.

    Thread safeness is about being sure you can make calls in the library on multiple threads without things happening differently than when in single threads.

    again..... a two window two thread example
    thread1 SetMyRCCurrent() //RC 1 is current
    thread1 DrawaPolygon() //draw to RC1 - correct
    thread2 SetMyRCCurrent() //RC 2 is current
    thread1 DrawaPolygon() //draw to RC2 - wrong
    thread2 DrawaPolygon() //draw to RC2 - correct
    thread2 DrawaPolygon() //draw to RC2 - correct
    thread1 DrawaPolygon() //draw to RC2 - wrong
    thread2 EndDrawing() //end
    thread1 EndDrawing()
    can you please stop arguing and start participating in conversation?
    always looking, make an offer. get me out of this place.

  10. #40
    Registered User
    Join Date
    Jul 2002
    Posts
    273
    look, all I've wanted to do was get some definitive reason out of someone why it's threadsafe or not threadsafe. You didn't seem to know when you first posted, now all of a sudden you're convinced of it. That's not a definitive reason to me. I'm still looking for proof one way or another. So far it seems that there is a problem and nobody except no-one has made any effort to figure it out (I'm not sure he really tried either)

    facts that I'm aware of:
    -when you set the current RC you are setting it globally
    -if RC1 is selected in and we context switch to thread2, thread2 thinks he's still rendering to RC2 cause that's the one HE selected
    -threads share global memory therefore a global state such as current RC is set for both threads.

    I'm pretty sure that these three facts are correct. If so, then you couldn't possibly render safely from both threads at the same time. Perhaps I've missed something but thus far all I've heard is "OpenGL is thread-safe. And you're a doodie head!"
    always looking, make an offer. get me out of this place.

  11. #41
    Registered User VBprogrammer's Avatar
    Join Date
    Mar 2002
    Posts
    175
    no-one you really should learn to accept that you are wrong. Hershlag is a pro programmer and, given you misunderstandings of code re-entrancy (better name for being tread safe), you are not. Now these things are mostly theoritical, however you are not saying this you are said it is thread safe, but they are important to some people (non wheel re-inventers). In short - give it up.
    VC++ 6

  12. #42
    Registered User
    Join Date
    Jul 2002
    Posts
    273
    dang VB, that's harsh. thanks though. I still am not even saying that I'm sure about this. If the OpenGL people have documented a way of being thread-safe in this circumstance I would love to see it! Anyone? Anyone? Please?
    always looking, make an offer. get me out of this place.

  13. #43
    Has a Masters in B.S.
    Join Date
    Aug 2001
    Posts
    2,263
    >can you please stop arguing and start participating in conversation?

    HOW BOUT YOU READ MY ****ING POSTS HUH?

    i have answer your damn question already!!!

    RC's ARE NOT GLOBAL TO THE APPLICATION!!!!!! THEY ARE EXCLUSIVE TO THE THREAD THAT CREATES THEM!!!!

    Create the RC's in seperate threads and they with render simultaniously!!

    >I have a multithreaded app.

    good start.

    >I want to render at the same time to both windows.

    easy enough.

    >
    The problem is that the "current window" is a global setting and when the system context switches (the process of switching between threads) the second thread is still trying to work on the other RC as in the previous example.
    <

    define "current window"!

    >
    look, all I've wanted to do was get some definitive reason out of someone why it's threadsafe or not threadsafe.
    <

    again read my previous posts. its thread safe because the RC's ARE EXCLUSIVE to the thread that creates them.

    an Rc created in one thread cannot affect another rc created in another no matter how many times you call wglMakeCurrent(), END OF FREAKING STORY.

    >You didn't seem to know when you first posted, now all of a sudden you're convinced of it.

    i was being ****ing polite, jesus people.

    >(I'm not sure he really tried either)

    because you havn't payed any attention.

    you wrote me off as an idiot, and thats you mistake.

    >-when you set the current RC you are setting it globally

    WRONG, for the thread ONLY!

    >-if RC1 is selected in and we context switch to thread2, thread2 thinks he's still rendering to RC2 cause that's the one HE selected

    if it was created in the calling thread then thread2 is using an RC illegaly anyway so SHUT UP!

    >-threads share global memory therefore a global state such as current RC is set for both threads.

    WRONG, the RC's are exclusive to the thread that creates them, read the damn spec.

    >erhaps I've missed something but thus far all I've heard is "OpenGL is thread-safe. And you're a doodie head!"

    READ THE POSTS!!!!!

    >no-one you really should learn to accept that you are wrong.

    I DO WHEN I AM!

    >Hershlag is a pro programmer and

    really?

    >In short - give it up.

    have you even read any of this?

  14. #44
    Registered User
    Join Date
    Jul 2002
    Posts
    273
    i was being ****ing polite, jesus people.
    certainly aren't now are you.
    RC's ARE NOT GLOBAL TO THE APPLICATION!!!!!! THEY ARE EXCLUSIVE TO THE THREAD THAT CREATES THEM!!!!
    WRONG, the RC's are exclusive to the thread that creates them, read the damn spec.
    is this true? if so, that's all I've been after since the beginning. So then OpenGL would have to be doing a GetCurrentThread internally to tell which RC to use?

    so SHUT UP!
    I particularly like this one.
    always looking, make an offer. get me out of this place.

  15. #45
    Registered User
    Join Date
    Jul 2002
    Posts
    273
    no-one, you spent most of this time talking about multiple RCs on a single window like that had anything to do with my question. now, for the first time you are really answering the question. If you are correct I am happy about that and would like to see this spec to verify it. Have a link? This will make my life much easier if it is true.
    always looking, make an offer. get me out of this place.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. shaders: directx/opengl
    By Raven Arkadon in forum Game Programming
    Replies: 5
    Last Post: 08-24-2006, 09:19 AM