For some herself also don’t know why, I have a strange tenderness in c + +, always have the urge to want to use c + + programming task, but I really don’t like to always inside the black box of the console input and output, and the operation mechanism of MFC temporarily and I don’t know, one is a string file has been completed, looking at halo, OpenGL is accord with the need, and there is a glut can help implement simple forms in the console, speak quite enough as a simple to use, complex use later to say again.
I am completely a beginner, with reference to the “OpenGL Introduction Tutorial” this document and some references on the network can be scraped together to complete this simple solar system model. (here to thank the makers of this tutorial and the sharer, I feel to write quite good, there is a download on the Internet, I am from baidu library to get, they also passed a to the resources) why is the solar system model?Because I love it, and a lot of people have done it, and I don’t understand it, but there’s a code to learn. Needless to say, the first on a renderings:
The starting point of any project should be a requirement analysis. The requirement is very simple, which is to display a model that looks like the solar system on the screen, and just look like it. It takes time and effort to make an accurate model of the solar system, and no one pays for it. Then the design phase, as object-oriented programming, look for the object, the eight planets in the solar system as well as the sun itself, in order to look more beautiful point, track should also be mapped, so the object has two, all objects to achieve a draw method, is used to draw themselves, to design a myObj parent class can be easily performed as part of the paint job, I think now that each orbit to a certain object, then the track can be used as a private attribute of the object, it should be a dependency. The class diagram is as follows:
The basic information for the star ASTER includes the radius of the star, the revolution period revolution_solar, the revolution period self, the orbit orbit, and the revolution radius distance. Orbit has only one radius property. There are also some auxiliary properties that are defined in the implementation and are not listed in the class diagram.
With the class diagram, you can enter the coding stage, the first need to configure the development environment, I am using VS2010, development is using OpenGL, download address Baidu Google, I do not remember the original download address, passed a copy to the resources inside. Tutorial there said to be integrated development libraries to vs inside, but I don’t like it, don’t often use it is not necessary to change the development environment, as long as it is good to set a single project, the DLL file to the operation of the generated files,. H file saved to the project folder,..lib file loaded in the code should be able to use relative paths, but I don’t know where the base path is temporarily, so chose to set the attributes of the project, particular way is:
Right-click the project name in the Solution Explorer and select Properties ->; Linker-> General, add an absolute lib directory to Additional Librarydirectories. The lib file is loaded using #pragma comment (lib).
There are many examples in the tutorial, and each knowledge point is also very clear, do not repeat. Inside I met a little problem when system is realized in lesson 5 day month, if you use the tutorial to the parameters of the inside, in the window is what also can’t see, but if I ten times to reduce the parameters of the unified, can appear normal, though I searched some articles of coordinate transformation, but at present still don’t know why will appear this problem, if such as morally scaling should not appear different results?Doesn’t OpenGL accept parameters that are too large?
Said a little bit about the questions about the gluLookAt function, may be my personal problem, in understanding the function of the time a little effort, this function has nine parameters, divided into three groups, the first group is about the viewpoint of movement, a viewpoint is initially at point (0, 0), if not after the perspective projection transformation of coordinates, then draw the images will appear in the view’s location, similar to someone put something in your eyes, things just don’t see behind, can move through the first coordinate, then draw the solution to the object, But the advantage of Glulookat is that you don’t have to calculate the position of every object. You can view it from any Angle. It doesn’t matter if you just plot on the plane of the xyz axis, but what if you want to see the whole system at 45 degrees or 75 degrees?The position of each object is not easy to calculate. The way I understand this function works is that the developer first draws the whole system in the coordinate system, and then realizes the change of observation Angle through this function, and OpenGL automatically calculates the relative position of each object. This function must be placed before the other coordinate changes, and I feel that it is executed in the last order of the system drawing. The above is irresponsible conjecture, without any theoretical support, hereby declare…
Well, going a bit too far, the second set of parameters are the coordinates of the center of the viewpoint. The perspective projection itself is a four-prism, and the line between the viewpoint and the center is the same as a perpendicular from the vertex to the bottom.
The third parameter is the direction, that is, what do you think of the observer, the tutorial says from the point of (0, 0) to the point of attachment to determine positive direction, such as if set to (0, 0), is similar to normal viewing screen, (0, 1, 0) means the person is in upside down the screen, (0, 0, 1) said looked down at the keyboard, (0, 1) said from behind the display looked down at the keyboard…
There are still some problems with lighting and material Settings, we will talk about it later. The whole project has been uploaded to resources, please download it if necessary.
The first time you set up the project, you mistakenly selected Windows Application, which can be found in Properties ->; Linker-> system-> Subsystem changes to Console.
Modify the icon of the Console program to add resource->; Open Resource. H and set the ID of your icon to a minimum. To open Resource. H, open the.rc file (select View Code) and then open it in an include< file. resource.h> Select Open Document.
I am completely a beginner, with reference to the “OpenGL Introduction Tutorial” this document and some references on the network can be scraped together to complete this simple solar system model. (here to thank the makers of this tutorial and the sharer, I feel to write quite good, there is a download on the Internet, I am from baidu library to get, they also passed a to the resources) why is the solar system model?Because I love it, and a lot of people have done it, and I don’t understand it, but there’s a code to learn. Needless to say, the first on a renderings:
The starting point of any project should be a requirement analysis. The requirement is very simple, which is to display a model that looks like the solar system on the screen, and just look like it. It takes time and effort to make an accurate model of the solar system, and no one pays for it. Then the design phase, as object-oriented programming, look for the object, the eight planets in the solar system as well as the sun itself, in order to look more beautiful point, track should also be mapped, so the object has two, all objects to achieve a draw method, is used to draw themselves, to design a myObj parent class can be easily performed as part of the paint job, I think now that each orbit to a certain object, then the track can be used as a private attribute of the object, it should be a dependency. The class diagram is as follows:
The basic information for the star ASTER includes the radius of the star, the revolution period revolution_solar, the revolution period self, the orbit orbit, and the revolution radius distance. Orbit has only one radius property. There are also some auxiliary properties that are defined in the implementation and are not listed in the class diagram.
With the class diagram, you can enter the coding stage, the first need to configure the development environment, I am using VS2010, development is using OpenGL, download address Baidu Google, I do not remember the original download address, passed a copy to the resources inside. Tutorial there said to be integrated development libraries to vs inside, but I don’t like it, don’t often use it is not necessary to change the development environment, as long as it is good to set a single project, the DLL file to the operation of the generated files,. H file saved to the project folder,..lib file loaded in the code should be able to use relative paths, but I don’t know where the base path is temporarily, so chose to set the attributes of the project, particular way is:
Right-click the project name in the Solution Explorer and select Properties ->; Linker-> General, add an absolute lib directory to Additional Librarydirectories. The lib file is loaded using #pragma comment (lib).
There are many examples in the tutorial, and each knowledge point is also very clear, do not repeat. Inside I met a little problem when system is realized in lesson 5 day month, if you use the tutorial to the parameters of the inside, in the window is what also can’t see, but if I ten times to reduce the parameters of the unified, can appear normal, though I searched some articles of coordinate transformation, but at present still don’t know why will appear this problem, if such as morally scaling should not appear different results?Doesn’t OpenGL accept parameters that are too large?
Said a little bit about the questions about the gluLookAt function, may be my personal problem, in understanding the function of the time a little effort, this function has nine parameters, divided into three groups, the first group is about the viewpoint of movement, a viewpoint is initially at point (0, 0), if not after the perspective projection transformation of coordinates, then draw the images will appear in the view’s location, similar to someone put something in your eyes, things just don’t see behind, can move through the first coordinate, then draw the solution to the object, But the advantage of Glulookat is that you don’t have to calculate the position of every object. You can view it from any Angle. It doesn’t matter if you just plot on the plane of the xyz axis, but what if you want to see the whole system at 45 degrees or 75 degrees?The position of each object is not easy to calculate. The way I understand this function works is that the developer first draws the whole system in the coordinate system, and then realizes the change of observation Angle through this function, and OpenGL automatically calculates the relative position of each object. This function must be placed before the other coordinate changes, and I feel that it is executed in the last order of the system drawing. The above is irresponsible conjecture, without any theoretical support, hereby declare…
Well, going a bit too far, the second set of parameters are the coordinates of the center of the viewpoint. The perspective projection itself is a four-prism, and the line between the viewpoint and the center is the same as a perpendicular from the vertex to the bottom.
The third parameter is the direction, that is, what do you think of the observer, the tutorial says from the point of (0, 0) to the point of attachment to determine positive direction, such as if set to (0, 0), is similar to normal viewing screen, (0, 1, 0) means the person is in upside down the screen, (0, 0, 1) said looked down at the keyboard, (0, 1) said from behind the display looked down at the keyboard…
There are still some problems with lighting and material Settings, we will talk about it later. The whole project has been uploaded to resources, please download it if necessary.
The first time you set up the project, you mistakenly selected Windows Application, which can be found in Properties ->; Linker-> system-> Subsystem changes to Console.
Modify the icon of the Console program to add resource->; Open Resource. H and set the ID of your icon to a minimum. To open Resource. H, open the.rc file (select View Code) and then open it in an include< file. resource.h> Select Open Document.
Read More:
- OpenGL Usage Summary (including problems encountered and solutions)
- Summary of problems encountered by CodeBlocks + OpenGL
- Simple configuration of glfw + glad in vs2015 OpenGL development environment
- OpenGL learning summary (1)
- Summary of problems encountered in compiling opengl code
- Summary of problems encountered in using OpenGL in QT
- The experience of installing OpenGL in vs2017 under win7 system
- The solution of OpenGL not displaying normally in win7 system
- Proteus simulation duplicate part reference error
- Spock + powermock simulation static method reports an error java.lang.classcastexception
- When using quartus for function simulation, “testbench” appears_ vector_ input_ The solution of “file option does not exist”
- [Error report] PSpice frequency domain simulation AC Sweep “ERROR(ORPSIM-16103): Invalid value”
- The problem of nativelink error couldn’t execute invalid argument occurs when starting Modelsim Altera simulation through quartus
- OpenGL learning — problems encountered in compiling OpenGL program for the first time
- C# SevenZip simple operation
- Simple understanding and basic operation of mongodb
- To the brothers who encountered simple bind failed 192.168.1.×××: 636
- [Solved] Imx6qdl Android 5.0 kernel 3.10 can’t mount system file system
- Simple use of namedparameterjdbctemplate of spring
- Debug assembler NTVDM has encountered a system error The equipment connected to the system does not work