OpenGL development environment Configuration in Xcode under Computer graphics-mac system.

Source: Internet
Author: User

OpenGL development environment configuration in Xcode under Mac system.

This semester has a computer graphics course, need to use OpenGL, recently started to configure the development environment, the teacher gave the installation package is based on Windows system. There are many tutorials on the web that are also configured on Windows, with fewer versions of Mac. I synthesized a few tutorials and summed it up, and the practice was successful. To share the configuration process. Hope to help everyone!

Introduced

OpenGL (Open graphics Library) is a professional graphics program interface that defines a cross-programming language, cross-platform programming Interface Specification . It is used for three-dimensional image (two-dimensional also), is a powerful, hardware-independent, easy to invoke the underlying graphics library.

In programming, several libraries based on OpenGL are typically used, which provide functionality that OpenGL itself does not have. Many of the tutorials are based on glut, and most of the programs that beginners find on the web after the configuration end are tested on C + + files that are based on Windows-but Xcode shows deprecate and warning, mainly glut no longer updated from 1998, But not to be able to use ~ need to note that Mac and Windows system in the corresponding header file is different.

OpenGL and glut as the framework, all /System/Library/Frameworks under. The only thing that needs attention in the program is the include header file.

Windows provides OpenGL and Glu, and if you use glut, you have to install one yourself.
The use of header files under Windows is generally

    •     #include<GL/gl.h>    #include<GL/glu.h>

Under Mac OS x, it is generally

    • c++ #include <OpenGL/gl.h> #include <OpenGL/glu.h> #include <GLUT/glut.h>

In summary, we have found the source program's header file after modification , although there will be a warning but can run normally!

Configuration steps
  1. Find Xcode open in Finder, select Create a new Xcode project

2.OS x in the Application directory under Select CreateCommand Line Tool

3. Give your own file a name ~

On the edit page, locate the link below and click the Open drop-down Build Phases Binary With Libraries(0 items) menu to see the + number below? Click on it!

Find Glut.framework and Opengl.framework in the two framework, click Add after the completion of the effect such as:

Now you can happily write our computer graphics homework! We entered main.cpp to write a small demo.

The code is as follows:

//for testing only, code directly to the copy, only modified the header file  Span class= "ot" > #include <glut/glut.h>  void  mydisplay (void    ) {glclear (gl_color_buffer_bit); GLRECTF (-0.5f , -0.5f , 0.5f ,    0.5f ); Glflush ();} int  Main (int  argc, char  *argv[]) {Glutinit (    &ARGC, argv); Glutinitdisplaymode (Glut_rgb |    Glut_single);    Glutinitwindowposition (100 , 100 );    Glutinitwindowsize (400 , 400 );    Glutcreatewindow ( "first OpenGL program" );    Glutdisplayfunc (&mydisplay);    Glutmainloop (); return  0 ;}  

Code run

OpenGL development environment Configuration in Xcode under Computer graphics-mac system.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.