Results 1 to 4 of 4

Thread: Can opengl work in Win32 console application?

  1. #1
    Guest

    Can opengl work in Win32 console application?

    My program is a Win32 console application.

    But I want to do the belows for COLLISION DETECTION in my program:

    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();
    glTranslatef(pos.x, pos.y, pos.z);
    float mat2[16];
    glGetFloatv(GL_MODELVIEW_MATRIX, mat2);

    But it seems can't work!

    Can anyone help me?Thanks a lot!!!!

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

    Re: Can opengl work in Win32 console application?

    Hi !

    Could you be a little bit more specific about the problem, do you get an error or incoreect result or what ? (I guess you don't have an active rendering context)

    From an OpenGL point of view there is no difference between a console and a window application, the only difference is that the console application opens a console window, but a normal window application can do this also.

    BUT, you do need to create a window or a bitmap to hook up the rendering context to, because you cannot execute any opengl functions without selecting a valid rendering context first.

    Mikael

  3. #3
    Guest

    Re: Can opengl work in Win32 console application?

    I am doing a online multiplayers game.

    The server program is a Win32 console program, it will not have any rendering part, it just use for receiving and sending message to client and COLLISION DETECTION. It will just open a normal console window to printf the message.

    For collision detection, it needs to run following:
    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();
    glTranslatef(pos.x, pos.y,pos.z);
    glRotatef(Players.at(1)->angle,0,1,0);
    glRotatef(-90, 1, 0, 0);
    float mat3[16];
    glGetFloatv(GL_MODELVIEW_MATRIX, mat3);
    model2->setTransform(mat3);

    BOOL collision1=model->collision(model2);

    But, I find that it can't detect the collision. But It works fine in my client program (which have rendering part)

    So, I asked whether in my server.cpp can't run the gl function, although it can compile.

  4. #4
    Senior Member OpenGL Pro
    Join Date
    Feb 2002
    Location
    Bonn, Germany
    Posts
    1,633

    Re: Can opengl work in Win32 console application?

    OpenGL is for rendering.

    What you're doing there is basic matrix manipulation. Just do it yourself. Why use OpenGL for something that has nothing to do with rendering?

    If you're stubborn and insist on using OpenGL, the answer has already been given: you need a valid GL context, and for that you need a window.

Similar Threads

  1. Win32 or Console Environment?
    By Ehsan Nekooee in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 08-14-2009, 04:27 PM
  2. Visual C: Console Application and OpenGL
    By in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 08-21-2004, 05:17 AM
  3. Win32 Console OpenGL?
    By Omaha in forum OpenGL: Basic Coding
    Replies: 5
    Last Post: 11-06-2001, 02:58 AM
  4. console app VS win32 app
    By fabmathews in forum OpenGL: Basic Coding
    Replies: 9
    Last Post: 08-21-2001, 03:08 PM
  5. Add Color in Win32 Console Application
    By Acer722 in forum OpenGL: Basic Coding
    Replies: 8
    Last Post: 06-26-2001, 08:38 PM

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