Results 1 to 7 of 7

Thread: multithreading problem

  1. #1
    Junior Member Newbie
    Join Date
    Feb 2002
    Location
    Romania
    Posts
    9

    multithreading problem

    Hi!

    I implemented a multithreading application for out-of-core terrain visualization. In loader thread resources like terrain geometry and texture for visible tiles are loaded. In displaying thread resources are displayed. In loader thread function glGenTextures is called and returned invalid texture id that is zero. Can somebody advice me something?
    Thank you.

    Sebi.

  2. #2
    Senior Member OpenGL Guru Relic's Avatar
    Join Date
    Apr 2000
    Posts
    2,450

    Re: multithreading problem

    You have a context current?
    You have tried to make the same context current to both threads?
    You have two contexts and didn't issue wglShareLists? (shouldn'result in this error)
    You never issued glDeleteTextures and ran out of 2^32-1 IDs?
    You ran out of texture memory? (should not result in this error though)

  3. #3
    Junior Member Newbie
    Join Date
    Feb 2002
    Location
    Romania
    Posts
    9

    Re: multithreading problem

    Originally posted by Relic:
    You have a context current?
    You have tried to make the same context current to both threads?

    No. I have one context for displaying thread.
    Do you think that I need two different context for each thread? Generaly is possibile what I want? If not then how is possibile to solve loading and rendering problems in separate threads?

    You have two contexts and didn't issue wglShareLists? (shouldn'result in this error)

    Sorry but I don't understand your question.

    You never issued glDeleteTextures and ran out of 2^32-1 IDs?

    No. Number of textures is big but is limited.

    You ran out of texture memory? (should not result in this error though)
    No. When I made loading and rendering in the same thread application worked without problems.

    Thank you for your help.

  4. #4
    Senior Member OpenGL Guru Relic's Avatar
    Join Date
    Apr 2000
    Posts
    2,450

    Re: multithreading problem

    If you have two threads using OpenGL on the same window at the same time they need to use two different OpenGL contexts, one per thread. Otherwise wglMakeCurrent would fail, because one context can only be current to one window at a time (read the wglMakeCurrent manual).
    But two different OpenGL contexts can only share texture objects if you issued wglShareLists (under Win32) to let them reference the same texture objects.
    If you didn't do the above I don't see how multithreading would help at all.
    For less headaches, try to avoid situations where you have the same texture bound in one thread and updated in the second.

    [This message has been edited by Relic (edited 07-12-2003).]

  5. #5
    Guest

    Re: multithreading problem

    Originally posted by Relic:
    one context can only be current to one window at a time
    Perhaps a typo but it should be "one context can only be current to one thread at a time".
    http://msdn.microsoft.com/library/de...pnglr_2u0k.asp

  6. #6
    Senior Member OpenGL Guru Relic's Avatar
    Join Date
    Apr 2000
    Posts
    2,450

    Re: multithreading problem

    Yes, never edit posts without reading what you typed before.

  7. #7
    Junior Member Newbie
    Join Date
    Feb 2002
    Location
    Romania
    Posts
    9

    Re: multithreading problem

    Originally posted by Relic:
    If you have two threads using OpenGL on the same window at the same time they need to use two different OpenGL contexts, one per thread. Otherwise wglMakeCurrent would fail, because one context can only be current to one window at a time (read the wglMakeCurrent manual).
    But two different OpenGL contexts can only share texture objects if you issued wglShareLists (under Win32) to let them reference the same texture objects.
    If you didn't do the above I don't see how multithreading would help at all.
    For less headaches, try to avoid situations where you have the same texture bound in one thread and updated in the second.

    [This message has been edited by Relic (edited 07-12-2003).]
    Ok. Now multithread loading and displaying is working. Thank you very much.

Similar Threads

  1. Replies: 0
    Last Post: 03-27-2012, 07:40 AM
  2. Multithreading problem!
    By HanWu in forum OpenGL: Basic Coding
    Replies: 4
    Last Post: 08-27-2008, 10:07 PM
  3. multithreading Problem
    By tpp in forum OpenGL: Advanced Coding
    Replies: 1
    Last Post: 10-27-2004, 09:00 AM
  4. Multithreading problem
    By wolfman in forum OpenGL: Advanced Coding
    Replies: 7
    Last Post: 06-18-2004, 05:28 PM
  5. multithreading in MFC OpenGL problem
    By cypher in forum OpenGL: Advanced Coding
    Replies: 0
    Last Post: 05-22-2001, 06:13 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean