Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Easy way to create a window (using openGL)
Index -> Programming, C++ -> C++ Tutorials
View previous topic Printable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
tupac




PostPosted: Sun Jul 16, 2006 10:28 am   Post subject: Easy way to create a window (using openGL)

creating a window in C++ is really hard and time consuming, well have no fear, i will show you how to create a window using openGL

start with a blank c++ source file (if you are using Visual Studio), then type the following code in:

code:

//simple header files we will need to use:
#include <GL/gl.h>
#include <GL/glut.h>

//this is the "display" void, we will use it to clear the screen:
void display (void){
        glClearColor (0.0, 0.0, 0.0, 1.0);
        glClear (GL_COLOR_BUFFER_BIT);
        glLoadIdentity();
        gluLookAt (0.0, 0.0, 5.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0);
        square();
        glFlush();
}

//next we will create our window and display the "display" void:
int main (int argc, char **argv){
        glutInit (&argc, argv);
        glutInitDisplayMode (GLUT_SINGLE);
        glutInitWindowSize (500,500);
        glutInitWindowPosition (100, 100);
        glutCreateWindow ("Simple Window");
        glutDisplayFunc (display);
        glutMainLoop();
        return 0;
}


Of course, you do need to download the openGL package to run this program (without getting any errors).
http://www.nigels.com/glt/download.html -- go here to download the OpenGL toolkit, if this doesnt work, the search "openGL for C++ download" in google.
Sponsor
Sponsor
Sponsor
sponsor
Mazer




PostPosted: Sun Jul 16, 2006 12:05 pm   Post subject: (No subject)

You should probably do some more research on OpenGL.

Windows aren't made with OpenGL. What you're using, GLUT, does all the window creation code for you in this case. But GLUT (OpenGL Utility Toolkit) is pretty old and if I remember correctly, unmaintained.
McKenzie




PostPosted: Sun Jul 16, 2006 4:19 pm   Post subject: (No subject)

If you want to do some research SDL is all the rage these days.
http://www.libsdl.org/index.php
md




PostPosted: Sun Jul 16, 2006 5:37 pm   Post subject: (No subject)

Also there is no way to create a window in C++. You can create windows in X or the windows GDI; or any number of other display systems, but those are not part of C++.

It's sad how warped people's minds become by turing... so many people lack an understanding of the difference between language and library.
wtd




PostPosted: Sun Jul 16, 2006 6:09 pm   Post subject: (No subject)

When there is but one library for the language, and one language for the library, then what difference is there to see?
md




PostPosted: Sun Jul 16, 2006 11:25 pm   Post subject: (No subject)

Yes, but in C++ there are many libraries most of which are also used by many languages. There is a distinction in C++ between language and library when it comes to windowing methodology.

'Course your right, in the end I suppose it really doesn't make a huge difference to some people if it's a language or a library feature. They just care that it works in their language of choice.
Display posts from previous:   
   Index -> Programming, C++ -> C++ Tutorials
View previous topic Tell A FriendPrintable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 6 Posts ]
Jump to:   


Style:  
Search: