Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: Shell + OpenGL window

  1. #1
    Junior Member Newbie
    Join Date
    Sep 2006
    Posts
    7

    Shell + OpenGL window

    Hello,
    I did a class which contains simulation data.
    I'd like to create a main which first opens a shell (i ll put my simulation parameters in it),
    then creates an OpenGL window drawing the results.
    I used some tutorials about opengl and I ve been able to draw some objects etc... But I still don't know how to use class methods in the main
    using cout or cin for example (need a shell).
    I realy don't know if i must use glu, glut, or glui, i'm realy lost among them.
    Thanks.

  2. #2
    Senior Member OpenGL Pro k_szczech's Avatar
    Join Date
    Feb 2006
    Location
    Poland
    Posts
    1,107

    Re: Shell + OpenGL window

    I guess you'll need glut (or freeglut). GLU is just a set of helpful functions, and GLUI is for creating user interface inside OpenGL window (buttons, lists, etc. are drawn using OpenGL).

  3. #3
    Junior Member Newbie
    Join Date
    Sep 2006
    Posts
    7

    Re: Shell + OpenGL window

    Yes i thought so, but even using it I still don't know how to do...
    The main I use at the moment is :
    int main( int argc, char *argv[ ], char *envp[ ]
    found in a tutorial, it works for opening an opengl window but not for what i want as described lately.

  4. #4
    Senior Member OpenGL Pro
    Join Date
    Jul 2001
    Location
    France
    Posts
    1,662

    Re: Shell + OpenGL window

    If I understood correctly, you arguments to the simulation HAVE TO be treated inside argv. AFAIK I don't know extra new exotic parameters to add to main.

    For the rest, can you be more precise ? In fact I don't really understand.

  5. #5
    Junior Member Newbie
    Join Date
    Sep 2006
    Posts
    7

    Re: Shell + OpenGL window

    I'm sorry. I'm c++ beginner and my english isn't very good.
    Actualy I want to make a .exe which first opens a shell, in it i'll put some parameters ( cin >> ).In the main i need to use some class methods dealing with the parameters.
    Then an opengl window appears. Drawing what is in some privates of the class.
    But I think I just managed to do this.
    In the tutorial in foud, you're told to create a windows application project. I tried to create a project shell application (by the way i use dev-cpp), and it seems to work. I know have a shell and then an opengl window. I'm not sure at the moment, but thanks anyway. I'll ask again if that way isn't ok.

  6. #6
    Junior Member Newbie
    Join Date
    Sep 2006
    Posts
    7

    Re: Shell + OpenGL window

    Hum actualy it doesn't seem to work.
    There is the file, maybe it will be clearer.
    This works, but if i use cubic cube; and cubic cube.saisir(); , the .exe fail (but compilation is still ok)


    #include <cstdlib>
    #include <iostream>
    #include <gl/glut.h>
    #include <cubic.h>
    using namespace std;

    int WindowName;

    void Reshape(int width, int height)
    {
    glViewport(0,0,width,height);
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    gluPerspective(
    45,
    float(width)/float(height),
    0.1,
    100
    );
    glMatrixMode(GL_MODELVIEW);
    }

    void Draw()
    {
    glClear
    (
    GL_COLOR_BUFFER_BIT |
    GL_DEPTH_BUFFER_BIT
    );
    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();
    gluLookAt(0,0,-10,0,0,0,0,1,0);
    glBegin(GL_TRIANGLES);
    glVertex2i(0,1);
    glVertex2i(-1,0);
    glVertex2i(1,0);

    glEnd();
    glutSwapBuffers();

    glutPostRedisplay();
    }

    int main(int argc, char *argv[])
    {
    //cubic cube;
    //cubic cube.saisir();

    system("PAUSE");

    glutInit(&argc, argv);
    glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_DEPTH);
    glutInitWindowSize(640,480);
    WindowName = glutCreateWindow("OpenGL Window");


    glutReshapeFunc(Reshape);
    glutDisplayFunc(Draw);
    //InitGL();

    glutMainLoop();

    return EXIT_SUCCESS;
    }

  7. #7
    Senior Member OpenGL Pro
    Join Date
    Jul 2001
    Location
    France
    Posts
    1,662

    Re: Shell + OpenGL window

    Try to debug your program, it looks more like an error from within your class. This kind of code is expected to work.

  8. #8
    Junior Member Newbie
    Join Date
    Sep 2006
    Posts
    7

    Re: Shell + OpenGL window

    Yes as shown it works, but when cubic cube; and
    cube.saisir(); are on, the program fails, even if i debug. The class is ok, i tried it in another program without opengl.

  9. #9
    Junior Member Newbie
    Join Date
    Sep 2006
    Posts
    7

    Re: Shell + OpenGL window

    You were right jide, it seems like there were too much private in the class, thanks a lot.
    The problem now (not directly related to the topic), is I don't know how to put some class data (from methods) in the drawing function.
    For example in order to draw, I'd like to put 'Dx' as a coordinate for a vertex, and I get it thanks to the method 'cube.getDx' .
    But it looks like class methods are not recognized in Draw() (they are in the main now),
    and I don't think the function allows parameters.
    Any idea ?

    Thanks for answers.

  10. #10
    Senior Member OpenGL Pro
    Join Date
    Jul 2001
    Location
    France
    Posts
    1,662

    Re: Shell + OpenGL window

    What you actually need is to learn about what programmation is, about your programming language and surely other things (maths...). This will definately help you A LOT.

    Unfortunately this forum is not dedicated to that. If I don't tell you that, others will.
    There are many sites that might help you. Or best, buy a book. Have a look at Amazon for that (or Eyrolles as it seems you're french).

    But for your conveniencies, until you have your books, here is a hint:

    Code :
    cubic cube;
    should be declared global and before any other functions.

Page 1 of 2 12 LastLast

Similar Threads

  1. Window is redrawn inside the OpenGL area instead of the whole window
    By Visual act in forum OpenGL: User Software
    Replies: 0
    Last Post: 09-18-2015, 06:31 AM
  2. Multi process opengl (SHELL+GAME) free resources, performance issue
    By Arnaud Maye in forum OpenGL: Advanced Coding
    Replies: 3
    Last Post: 03-12-2007, 10:47 AM
  3. Compiling using unix shell ssh
    By in forum OpenGL: User Software
    Replies: 1
    Last Post: 01-13-2005, 11:48 PM
  4. i am trying to implement OpenGL|ES on T-Shell
    By panja in forum OpenGL ES
    Replies: 2
    Last Post: 05-05-2004, 07:49 PM
  5. shell error when running opengl program
    By mjs1 in forum OpenGL: Basic Coding
    Replies: 5
    Last Post: 01-22-2004, 06:59 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