Game Engine Architecture Reading Note 1-C + + in the game engine

Source: Internet
Author: User

At the end of March, I temporarily ended the work in Beijing, from the original company, mainly to learn the game development of the underlying knowledge and 3D engine related content, and technology transformation, in order to spur their own learning, the future blog update will be more frequent, at this stage is mainly "game engine architecture" Reading Notes series and Unity Learning notes series.

"Game engine architecture" was bought two years ago, and I have seen it in general, because I want to learn the underlying knowledge of the engine, so re-find the book to read again, and according to their own understanding to write some reading notes here to communicate with you, in addition, because want to have a new beginning, Recently in the blog park here to write a technical blog, a few days ago made a own website (www.manshuoquan.cn) But the server has some problems, the latter will still try to build their own station, and the blog to pass up.

Gossip less continued, the first part of this book is the Foundation, the first chapter outlines some of the engine concepts, the second chapter explains the use of some tools (Visual studio, etc.), the third chapter introduces C + +, and the general C + + book is not the same, the book explains the C + + Should be more in the engine commonly used in some concepts, but also includes some of the basic software engineering ideas, I think the more important to have the following points

First, "Make the wrong program obvious", which was introduced in the introduction of the coding standard, which featured an article called "Making the Wrong program obvious" (http://chinesetrad.joelonsoftware.com/Articles/ wrong.html), this article introduces the nature of the prefix reaction variable by naming it, thus making the wrong procedure obvious and introducing the use of the Hungarian nomenclature.

Then there is the memory layout of the object, which is very helpful in optimizing the performance of the program, in class and struct, where the compiler does not wrap the data programmer tightly together, because each data has its natural alignment for the CPU to read/write efficiently from memory. The alignment means that the memory address is a multiple of the aligned byte size, and the compiler may add padding at the end for array alignment, and the following are the sizes (in bytes) of each type under the 32-bit system:

Int:4 bytes; float:4 bytes; double:8 bytes; bool:1 bytes; char:1 bytes; short:2 bytes; long:4 bytes or 8 bytes

It is necessary to note that when there is a virtual function in class, or a virtual function in an inherited class, a virtual table pointer is usually added to the front of the class's layout, pointing to a data structure called the virtual function table, because the pointer is of type int.

Understanding the meaning of memory layout is that when we write classes and structs, the most optimized way is to arrange the data according to the memory layout rules, so as to reduce the size of the class or struct.

Also need to explain is the type size problem, because the standard C + + basic data type is set to portable, so do not make explicit provisions, in the development of the game engine, sometimes need to know the exact size of certain variables, most game engine will customize the basic data type, plus big and small end of the conversion problem, The Wii, Xbox360, and PS, a small-end device developed using PowerPC, may involve data conversion issues.

Finally, the implementation of error detection and processing, the assertion is divided into two macros in order to facilitate the release of unnecessary assertions to avoid unnecessary loss of efficiency.

Game Engine Architecture Reading Note 1-C + + in the game engine

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.