Results 1 to 10 of 10

Thread: how can i call opengl from another Visual C++ program

  1. #1
    Junior Member Newbie
    Join Date
    Dec 2002
    Posts
    5

    how can i call opengl from another Visual C++ program

    hi
    I have a problem. I can not call an opengl example from my another(my base) program in Visual C++.
    I calgulate some values and I want to draw it in opengl.
    Everything is ok but when I write
    gluMainLoop() my base program stops.

    So I want to learn if there is a simple way to call opengl window from another program.
    Thanks for your answer.

  2. #2
    Senior Member OpenGL Pro
    Join Date
    Oct 2000
    Location
    Fargo, ND
    Posts
    1,753

    Re: how can i call opengl from another Visual C++ program

    glutMainLoop basically takes over the thread of operation it is called in until the window is closed. You could call that in a separate thread, but there might be better ways. You'd have to explain what you want in a bit more detail.
    Deiussum
    Software Engineer and OpenGL enthusiast

  3. #3
    Junior Member Newbie
    Join Date
    Dec 2002
    Posts
    5

    Re: how can i call opengl from another Visual C++ program

    In fact my problem is with glutMainLoop().

    I want to take the coordinates from another (my base) program and draw in step by step with opengl in another window. I can take the values from base program and update them. But I can't make it draw step bye step. Whenever I put glutMainLoop() my base program stops. I want two of them to run together. To update the coordinates and draw it.

    Is there a way to draw something like this step by step in opengl?

    By the way thanks for your answer

  4. #4
    Senior Member OpenGL Pro
    Join Date
    May 2001
    Location
    Kristianstad,Skåne,Sweden
    Posts
    1,595

    Re: how can i call opengl from another Visual C++ program

    Hi !

    Can't you use a timer, or an idle function, not sure if idle function are available in glut though.

    The timer calls a callback function for you every x milliseconds, wouldn't that be possible to put your code in there ?

    Mikael

  5. #5
    Junior Member Newbie
    Join Date
    Dec 2002
    Posts
    5

    Re: how can i call opengl from another Visual C++ program

    I don't want a timer infact. I only want to run two programs parallel. I dont want opengl to stop my base program. It stops whenever I write glutMainLoop(). So I cant see it step by step. I can only see the diagram at the end of the program. That is my problem...
    But a timer is not a solution for me.
    Thanks anyway

  6. #6
    Senior Member OpenGL Pro
    Join Date
    Oct 2000
    Location
    Fargo, ND
    Posts
    1,753

    Re: how can i call opengl from another Visual C++ program

    As I already stated, glutMainLoop() will lock up the current thread of execution until that window is closed. That means if you call it from your main thread, your main thread will appear to be halted.

    There are a few methods to do what you are trying to do, but it would help to know a bit more about the architecture of your program. How do you create your main window? How do you update your data? Do you want them to be totally separate of each other, or do you want the display window to be a child window of the main window?

    Some methods off the top of my head would include:
    - Multithreading, and have the glut app check for updated data in the idle method, or a timer
    - Create both windows with glut and use the idle function or timer for updating the data.
    - Create both windows with Win32 (or however you are creating your main app window).
    - Create them as two truly separate applications which communicate using something like named pipes or sockets.
    Deiussum
    Software Engineer and OpenGL enthusiast

  7. #7
    Senior Member OpenGL Guru
    Join Date
    Jun 2000
    Location
    Gastonia, NC, USA
    Posts
    2,068

    Re: how can i call opengl from another Visual C++ program

    You do not have to use GLUT to write a openGL program, there are lot's of examples of writting openGL with pure windows code to open and setup the window.

    Once you have written a standard windows based program, should be able to pass information between your openGL window and some other program program written using the windows API.

    But do you really need two program, or maybe one that creates two seaperate threads. Which is now more a windows question and best suited for a forum on windows programming.

    Originally posted by Mystery:
    hi
    I have a problem. I can not call an opengl example from my another(my base) program in Visual C++.
    I calgulate some values and I want to draw it in opengl.
    Everything is ok but when I write
    gluMainLoop() my base program stops.

    So I want to learn if there is a simple way to call opengl window from another program.
    Thanks for your answer.


    [This message has been edited by nexusone (edited 12-26-2002).]

  8. #8
    Junior Member Newbie
    Join Date
    Dec 2002
    Posts
    5

    Re: how can i call opengl from another Visual C++ program

    Infact I'm trying to run two closed programs. My base program is not a graffical program. But I want to see what it is doing. It is a timestepped program. It updates all data according to time. I can take the updated values to opengl. I have no problem with it. But I dont want to use
    glutMainLoop() cause it stops my other program.
    Opengl is the child wimdow. It only draws the updated values.

    I'll try the thing you suggested.
    thank you

  9. #9
    Senior Member OpenGL Pro
    Join Date
    Oct 2000
    Location
    Fargo, ND
    Posts
    1,753

    Re: how can i call opengl from another Visual C++ program

    You keep saying, "two programs" yet you seem to be inferring that you have all the code in a single executable. Generally two separate programs would actually be considered two separate executables. What it sounds like you've actually got is a single program with two windows.

    Anyway, the simplest thing for you to do might be just create a separate thread for the glut-based app. It isn't necessarily the best way, but it should work and be fairly simple to implement once you learn how to create a new thread. (Look at the CreateThread function in the Win32 API.)
    Deiussum
    Software Engineer and OpenGL enthusiast

  10. #10
    Junior Member Newbie
    Join Date
    Dec 2002
    Posts
    5

    Re: how can i call opengl from another Visual C++ program

    It seems that it is the best way to create a thread. I'll try it...

    Thank you...

Similar Threads

  1. crash while execution of opengl(visual basic) program
    By abhishek21 in forum OpenGL: Basic Coding
    Replies: 0
    Last Post: 05-03-2015, 09:54 PM
  2. Program crashing on draw call with very basic shaders
    By jafrbc in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 06-22-2014, 11:15 AM
  3. OpenCV function call within OpenGL program
    By 4d5245 in forum OpenGL: Basic Coding
    Replies: 5
    Last Post: 12-03-2013, 10:04 AM
  4. OpenGL and Visual Studio 2010 Visual C++
    By Matt SA in forum OpenGL: Windows
    Replies: 1
    Last Post: 09-21-2012, 09:43 PM
  5. Asynchrouous call to program build
    By manish.agarw in forum OpenCL
    Replies: 1
    Last Post: 09-09-2012, 12:50 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