OpenGL Basic Learning Topic (i) Programming environment construction

Source: Internet
Author: User


Off Topic:

For the first time, share the blog with you. The place of the water, the place of typos. Environmental communication-criticism. Yes, right away.

Previously in the Baidu space to write technology to share blog post, and then Baidu did not say that the entire space sealed. At that time, it was still a bit chilling. I just want to black it, the director is old. The place should be changed.

For want to write a OEPNGL basic study of the topic, mainly online resources a bit old, a lot of can not run, bought Red Book <<opengl Programming Guide 8th edition >>, see also see, feel a bit professional, optimization and technical core speak of more.

And they are snippets of code, like their own layman to learn or feel that the foundation is not. Need to fill in the basic API about Freeglut and Glew programming. For these reasons, I want to summarize my own about OpenGL.

Share it with friends who like graphics. There is also an online about OpenGL basic learning material is a mold carved, but the mold is a bit old. The code has an error. Someone needs to change a little bit.

Business:

This is the Freeglut and Glew development environment built on the window. At least until 2015-10-11, the two libraries used were the latest in the official web.

Freeglut is the freeglut-3.0.0 version, Freeglut is the primary API for compatible glut graphics libraries. Glew is the encapsulation that makes it possible to cross the platform. The individual feels that the cross-platform chews more.

It's still going to take some work. The latter version is glew-1.13.0.

Formally start configuring the environment.

1. Basic header files and library files for the two libraries above

http://download.csdn.net/detail/wangzhione/9172439

Download here to put *lib and *.dll into the project's root directory.

and link in, refer to the following image to add to the attached dependent library, all plus,

For the module file, the recommended practice is.

Locate the project right-click Property and locate the VC + + directory, including directories such as

Do the following:

This way your environment is OK, and the rest of the header files need to be included in the project, I do the following:

Mainly see the structure of the above module, you build a virtual directory, Shift+alt+a contains those header files can be, about the library file must be in the root directory, is the project folder.

Here's about vs on learning Freeglut and GLEW environment set up. This is too much trouble.

2. Setting up the environment a little bit more trouble every time, in the window development can not stand.

To say a few things, the inclusion path procedure above is equivalent to the command for GCC on Linux.

Gcc-imodule/freeglut-imodule/glew-l.-L .......

Say here continue to mention a little detail gcc for the static and dynamic libraries with the same name as the-L, first find the dynamic library, plus the-static option to find the static library.

The following approach is to use the VS auto-Add project template feature. Here I built one with VS2015. The Simplec template is as follows:

http://download.csdn.net/detail/wangzhione/9172445

Download it and put it under the VS2015 project template file. The basic path format is

c:\users\{Computer name}\documents\visual Studio 2015\templates\projecttemplates

Create a project later (Shift+ctrl+n) to add that project.

3. With regard to the basic C-Learning development framework above, the source engineering documents are as follows:

http://download.csdn.net/detail/wangzhione/9172455

Have the opportunity to write several blog posts dedicated to design ideas at the time.

This simple C development infrastructure is suitable for learning, suitable for play.

With multi-threading, simple configuration file reading, logging, simple string, Csv,json file reading and so on. Commonly used macros, some constraints simple common data structure encapsulation.

Here are some other, purely personal feelings.

1) It is recommended to learn to install the latest IDE on window, the default is Visual Studio this tool debugging function really dick not.

Really save lives. Next time I have the opportunity to share how to use the Pelles C Development Program topic. It's not easy to use. The debugging break point is prone to collapse.

2) work on Linux with VIM + gcc + makefile. Try CMake and share it again next time.

Microsoft's tools are really good, often work in the operation of the full screen of the black window, really want to ask, so really appropriate. The elder Gods. Why don't we try

Develop a visual Stduio for Linux 2048 for Linux and save a rookie like me.

Here our environment is OK, below write a test demo, as below, some questions do not always ask why, or to insist on codeing, because there is not so much why.

#include <glut.h>//screen drawing function void display (void);//Here Simple configuration glut environment int main (int argc, char *argv[]) {Glutinit (&ARGC , argv); Glutinitdisplaymode (Glut_rgb | Glut_single); glutinitwindowposition (100,100); glutinitwindowsize (400,400); Glutcreatewindow ("First OpenGL program");// Set the drawing function Glutdisplayfunc (display_02);//Perform GLUT loop glutmainloop (); return 0;} void display (void) {glclear (gl_color_buffer_bit);//Draw a rectangle here GLRECTF ( -0.5f,-0.5f,0.5f,0.5f); Glflush ();}

The function of the program is to draw a white rectangle in the center of a black window.

For the above code format, the next opportunity to share, about the C name, write the format of the school feel can pull a week, these problems few people say, basically is to catch and crawl after a lot of experience.

Here again more, for C Foundation bad person, can see I add a friend article, learn more. Profit is shallow, he is more serious, but the code is more rigorous, suitable for laying the groundwork.

Garbageman = http://www.cnblogs.com/pmer/

There are cloud-wind blog posts, in order to enhance the lattice can see. Pragmatic look at the above blog

Each line statement is described below.

First, you need to include the header file # include <glut.h>, which is a header file contained in the Freeglut.

Then look at the main function.

int main (int argc, char *argv[]), this is the main function with command line arguments, you should have seen it? Comrades who have not seen please turn over the book, and so on to understand and then look down.

Note that the statements in the main function, except for the last return, all begin with glut. This function, which starts with glut, is the function provided by the GLUT Toolkit, which describes several functions that are used.

1, Glutinit, initialize the glut, this function must be called before the other glut use. Its format is more rigid, generally copy this sentence glutinit (&ARGC, argv) on the can.

2, Glutinitdisplaymode, set the display mode, where GLUT_RGB means using RGB color, and corresponding to the Glut_index (indicating the use of indexed colors). The glut_single represents the use of a single buffer, which corresponds to a glut_double (using double buffering). For more information, please Google yourself. Of course, later tutorials will also have some explanation. (about how to fq the next chance to share a blog post separately)

3, Glutinitwindowposition, this simple, set the window in the position of the screen.

4, Glutinitwindowsize, this is also simple, set the size of the window.

5, Glutcreatewindow, create a window based on the information set earlier. The parameter is used as the caption of the window. Note: When the window is created, it is not immediately displayed to the screen. You need to call Glutmainloop to see the window.

6, Glutdisplayfunc, set a function that will be called when drawing is required. (This statement is not accurate enough, but the exact statement may not be very good for beginners to understand, for the time being said).

7, Glutmainloop, a message loop. (This may not be easy for beginners to understand, but it's enough to know that the function can show the window and wait for the window to close before it returns.) )

In the Glutdisplayfunc function, we set "call the display function when drawing is required." The display function is then used to draw. Observe the three function calls in display and find that they all start with GL. This function, which begins with GL, is the standard function of OpenGL, and the functions used are described below.

1, Glclear, clear. Gl_color_buffer_bit means clear color, glclear function can also clear other things, but this is not introduced here.

2, GLRECTF, draw a rectangle. The four parameters represent the horizontal and vertical coordinates of two points located on the diagonal.

3, Glflush, ensure that the previous OpenGL command executes immediately (instead of letting them wait in the buffer). The effect is similar to Fflush (stdout).

Then the basic configuration here is OK, if there is a problem, you can leave a message, you can also search.

Blog post errors are certain. Please correct me. Continue to share the next time you do not work overtime, welcome to add friends to communicate, in Beijing. Single Male programmer

OpenGL Basic Learning Topic (i) Programming environment construction

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.