Directx11 Study Notes 10-use a file to store the vertex Layout

Source: Internet
Author: User

In this section, we need to write the vertex layout in the file. For convenience, it is inconvenient to place a large string of very abstract coordinates together with CPP and programs.

The following are all c ++ knowledge to read data in a specific format in the file:

Vertex Count: 36Data:-1.0  1.0 -1.0 0.0 0.0  0.0  0.0 -1.0 1.0  1.0 -1.0 1.0 0.0  0.0  0.0 -1.0-1.0 -1.0 -1.0 0.0 1.0  0.0  0.0 -1.0-1.0 -1.0 -1.0 0.0 1.0  0.0  0.0 -1.0 1.0  1.0 -1.0 1.0 0.0  0.0  0.0 -1.0 1.0 -1.0 -1.0 1.0 1.0  0.0  0.0 -1.0 1.0  1.0 -1.0 0.0 0.0  1.0  0.0  0.0 1.0  1.0  1.0 1.0 0.0  1.0  0.0  0.0 1.0 -1.0 -1.0 0.0 1.0  1.0  0.0  0.0 1.0 -1.0 -1.0 0.0 1.0  1.0  0.0  0.0 1.0  1.0  1.0 1.0 0.0  1.0  0.0  0.0 1.0 -1.0  1.0 1.0 1.0  1.0  0.0  0.0 1.0  1.0  1.0 0.0 0.0  0.0  0.0  1.0-1.0  1.0  1.0 1.0 0.0  0.0  0.0  1.0 1.0 -1.0  1.0 0.0 1.0  0.0  0.0  1.0 1.0 -1.0  1.0 0.0 1.0  0.0  0.0  1.0-1.0  1.0  1.0 1.0 0.0  0.0  0.0  1.0-1.0 -1.0  1.0 1.0 1.0  0.0  0.0  1.0-1.0  1.0  1.0 0.0 0.0 -1.0  0.0  0.0-1.0  1.0 -1.0 1.0 0.0 -1.0  0.0  0.0-1.0 -1.0  1.0 0.0 1.0 -1.0  0.0  0.0-1.0 -1.0  1.0 0.0 1.0 -1.0  0.0  0.0-1.0  1.0 -1.0 1.0 0.0 -1.0  0.0  0.0-1.0 -1.0 -1.0 1.0 1.0 -1.0  0.0  0.0-1.0  1.0  1.0 0.0 0.0  0.0  1.0  0.0 1.0  1.0  1.0 1.0 0.0  0.0  1.0  0.0-1.0  1.0 -1.0 0.0 1.0  0.0  1.0  0.0-1.0  1.0 -1.0 0.0 1.0  0.0  1.0  0.0 1.0  1.0  1.0 1.0 0.0  0.0  1.0  0.0 1.0  1.0 -1.0 1.0 1.0  0.0  1.0  0.0-1.0 -1.0 -1.0 0.0 0.0  0.0 -1.0  0.0 1.0 -1.0 -1.0 1.0 0.0  0.0 -1.0  0.0-1.0 -1.0  1.0 0.0 1.0  0.0 -1.0  0.0-1.0 -1.0  1.0 0.0 1.0  0.0 -1.0  0.0 1.0 -1.0 -1.0 1.0 0.0  0.0 -1.0  0.0 1.0 -1.0  1.0 1.0 1.0  0.0 -1.0  0.0

The data is like the above, so there will be no index points, and each vertex will automatically repeat.

# Include <iostream> # include <fstream> using namespace STD; int main () {ifstream in; In. Open ("cube.txt"); If (! In) {cout <"Open failed" <Endl ;}else {cout <"Open successful" <Endl ;}char ch; int count; float f [8]; while (CH = in. get (), ch! = ':'); // Skip "vertex count:" In> count; cout <count <Endl; while (CH = in. Get (), ch! = ':'); // Skip "data:" While (! In. EOF () {for (INT I = 0; I <8; I ++) in> F [I]; for (INT I = 0; I <8; I ++) cout <F [I] <""; cout <Endl;} In. close (); In. clear (); getchar ();}

The above is pure C ++ code, just a read column. Next, we will update how to apply it in model initialization.

Please note: younfor blog notes, http://blog.csdn.net/cq361106306/article/details/40300205


Directx11 Study Notes 10-use a file to store the vertex Layout

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.