Tag Archives: c++

[learning opengl 22 step by step] – OpenGL importing 3D models with assimp Library

Tutorial 22
OpenGL imports 3D models using the ASSIMP library

Original: http://ogldev.atspace.co.uk/www/tutorial22/tutorial22.html
CSDN full version column: http://blog.csdn.net/column/details/13062.html


background
Through the previous learning we have achieved a lot of good results, but we are not good at creating complex models, you can imagine through the code to define every vertex position and other properties of the object is not feasible. A box, pyramid or simple surface mapping is fine, but what about a three-dimensional face?In fact, in games, in some commercial game applications, the mesh of the model is created by artists using modeling software such as Blender,Maya,3ds Max, etc. These software provide powerful tools to help artists create complex models. After the model is created, it is saved into a file. 3D model files are available in many formats, such as OBJ format. The 3D model file contains the entire geometry definition of the model, which can then be imported into the game engine (if the game engine can, of course)

The corresponding solutions to the problems of various external symbols that cannot be resolved

When using a VS2008 debugger, it is common to have problems with external symbols that cannot be resolved. There are many possible reasons. Here are some of the things I have learned over the past year.
For reference only.
 
Consider possible reasons:
[0] can’t parse may be because the.lib file is not correct, such as a 64 – bit compiler configuration, the results using the 32-bit lib package.
[1] is only to write a class declaration, but I haven’t write the implementation class, causing a call cannot resolve
[2] declaration and definition is not regulated, cause inconsistent links, cannot resolve
[3] is not in the project properties page of the linker command line options to join the corresponding class package.
[4] in the c + + contains, to join the corresponding class package repository directory path
[5] file directory to be tested in test engineering of measured classes may need to include the CPP definition file
[6] ICE interface test, cannot resolve may be because the file is not being measured include relevant CPP file, in addition, in TestSuite_ProjectRun. H file needs to contain IProjectRun. H header file, and the relevant header files (for example).
[7]import related contents cannot be resolved, the solution is to add the corresponding dynamic library in the linker dependencies
[8] The following error is usually caused by the fact that the dynamic library does not have a package. __imp
ProjectRun. Obj: error LNK2019: cannot resolve __imp__StartHistoryLocalModule external symbols, the symbol in the function “protected: virtual int __thiscall HiRTDB: : CProjectRun: : DoStart (void)” (?DoStart@CProjectRun @hirtdb @@maehxz)
[9] ERROR LNK2001: __imp___CrtDbgReportW
project properties, C/C++, code generation, runtime library select MDD,
[9] cannot resolve the external symbol “__declspec (dllimport) public: int __thiscall HiRTDB: : CTagTree: : GetObjectA (int, struct HiRTDB: : SBaseReadProps const & amp; ,struct HiRTDB::SBaseReadValues &) ” (__imp_?Public: int __thiscall hirtDB :: cStringImpl ::Get(int,struct hirtDB :: sStringReadprops const & ,struct HiRTDB::SStringReadValues &) “(?Get @cStringImpl @hirtdb @@qaehhabusStringReadProps @2 @aausStringReadValues @2@@Z
The reason may be that there are extra options in the project configuration file, please refer to the configuration options of other modules, do not have extra configuration.

Visual studio 2017 experience

On March 7, 2017, Microsoft released the 20th official version of Visual Studio — VS2017. I also can’t wait, the first time to download and install the community version, after all, this is the first IDE in the universe ah, on the VS2017 relative to the VS2015 improvement overview, please move to open source China, here to say that I as C++ installation and use experience.
Install the feeling
Installation interface for personal depth customization
About the installer
VS2017 has a new installation logic and steps, I use the way of network installation. VS2017 uses a separate installer to download and install VS components. The first installer downloaded from the official website is very small, with a space footprint of only 0.99M. (This is a real thing, the MS VS team must know that I have poor C disk space!) .

but this is not the real installer, real installer is needed by this small program to download and install, and then you can use. Installer volume……

wnload quickly, after the completion of the installation will automatically install the system under the C disk, and open the VS2017 installation version selection interface, I installed the VS2017 community version, enough to use, the focus is personal use does not spend money on the legal version.

Modular customization
Choose a good version, load for a while will enter the VS2017 module selection interface, the overall feeling is very refreshing, customization is very simple, you can choose a large module, such as.NET desktop development, or C++ development, or Windows development and so on, see the picture by yourself… . (I haven’t chosen any here, only the core editor, which takes up only 764MB of space! Heaven and earth conscience! ╮ (╯ del ╰) ╭)

in choosing a good big modules, also can undertake the choice of a single component, it is important to note that between components are interdependent, and some of the dependence between components is mandatory, some of it is not mandatory, for C disk will be lost comrades, Suggestions can seriously customization, unnecessary, or can be configured after installation, don’t need to use the installer installed, like a Win10 SDK is likely to be the hard disk C; For cross-platform development using VS, such as Android development, develop the required suite (JDK, NDK, SDK, Ant…) Basic can be installed after VS to configure, after all, it takes time to download, and the general VS installation path will be placed in the default C disk, so the VS components you choose will be installed C disk by default!


the installer can be directly the optional language pack, it’s a fine details of the changes, I personally before I hope I can a installation on English language and Chinese language pack, every time is to the other from the website to download the language pack, feel quite troublesome.

ah

Vs error prompt: “unable to open source file XXXX. H” possible reasons and Solutions

Unable to open source file xxx.h
Symptoms cause medicine friendship hint

symptoms
When learning the teacher’s example code, I found an error.

udaoplaceholder0
clock function and clock_t type are undefined identifiers?

see the library reference can not find the header file, tip “unable to open the source file time. The h”
The cause of
The code given by the teacher is not wrong in theory, it should be the problem of my development environment.
So my first reaction was: VS is broken?Can’t find time.h?Do I need to change the IDE configuration?Find the location of the header file to add?

Reference
VS cannot open source file “XXX. H”
10:57:14 on June 8, 2016 May the peace of the world Mr. W read number: 16405

https://blog.csdn.net/u014800094/article/details/51611636 project properties – & gt; Configure properties ->; C/C + + & gt; Conventional – & gt; Additional include directory ->; $(ProjectDir)

I tried it, but it was no use.
I think again, this project is written by the teacher VS2005, I am now 9012 years old, using VS2017 to open, is it possible that the version difference caused the problem! ?
Baidu, sure enough, I found someone with the same problem as me.

ah

[pit filling] problem summary of upgrading VS2010 project to vs2017

Question:
1, VS2010 MFC project upgrade to VS2017, open the resource file (open the RC file or open the resource view), resulting in VS software stuck.
2. Upgrade the VS2010 MFC project to VS2017, open the class wizard, resulting in VS software stuck.
Solution:
1. Backup platform toolset (properties ->; Conventional – & gt; Platform toolset) to Visual Studio 2010(V100)
2, reset the solution goal, select the latest SDK version and the latest toolset

PS:
1, can be deleted. Vs file folder (configuration) new beginning.
2, you can delete suo file, this is the old version of the configuration file
Other questions:
1 turn, Vs2010 project Vs2017 problem summary

2, explore https://blog.csdn.net/myruo/article/details/79277817 Visual Studio generated. Vs folders internal structure and function of the
https://shiyousan.com/post/636441130259624698
3, in the Visual Studio. Suo (Solution The User Options) file
https://shiyousan.com/post/636445373691512313

Clion compiles and runs a single C / cpp file

C/CPP is all right, but you need to create a new project first. You can only have one main at a time, so you need to be able to let it compile and execute a single file
Installing a plug-in

in the Settings to find the plug-in installation, after the completion of the open folder, you first create a new Cmakelist files, and right click on the need to perform the c file

choose the bottom of the add, you will see the main function on the left side of a small arrow, direct execution

Solving the problem of Chinese garbled code in qtring

Qt solves the problem of Chinese gibberish

qt generally set in the designer interface Chinese title what can be displayed normally.

but in QString, for example, when QPainter is painting Text, if the char* passed in contains Chinese, it will usually show a garbled code. At this time, two places need to be set:

    in main. CPP set QTextCodecQString using static method fromLocal8Bit(char*)
    for the first place, set in main. CPP as follows:
#include "MainWindow.h"

#include <QApplication>
#include <QTextCodec>

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    QTextCodec* codec = QTextCodec::codecForName("GB2312");
    QTextCodec::setCodecForLocale(codec);
    MainWindow w;
    w.show();
    return a.exec();
}

For the second place, use the following method in a char* containing Chinese characters:

QString::fromLocal8Bit(char*)

Where you want to pass in a QString, if Chinese is included, you need to do the above two Settings.

Format control of cout cout.width () and cout.fill ()

When I was doing C++ high-precision template output today, I found that the high-precision template output used cout.width() and cout.fill() in order to output the four-digit Numbers stored in each unit
We looked for information about cout.width() and Cout.fill ()
About cout. Width () :

a, control int width() will be used to adjust the width of the field. Since width is a member function, it will be called by an object. For example, cout.width() will display the current field width, which defaults to 0, and cout.width(3) will set the field width to 3. Note how C++ accommodates fields by assigning them just the right width to accommodate fields, so the default width in C++ is 0 to accommodate all fields.
b, width default alignment is right, that is, if cout.width(12) if the field is not so wide, the left side of the field will be filled with Spaces to reach the width of 12 fields.
c. Also note that width only affects the next output after it is set. After the output of the next field, subsequent fields are restored to their default values, such as cout.width(12); cout< < 2< < 3; Output 2 will be displayed as the width of 12 fields, but 3 will be displayed as the default.
d, int width() will reverse the previous field width value when it is called.
About cout. The fill () :
The member function fill() can be used to change the fill characters, such as cout.fill(‘ *’), which fills in the blank with *.
But be warned: the fill function will remain in effect after it is set, unless it is reset. This is quite different from width(). Width only affects the next output after it is set. After the next output, the following fields are restored to the default value of 0.
And cout. The fill (‘ * ‘) returns the set ‘*’ before the fill characters’ so if cout< < Fill (‘*’) will print this space
So the output of the following program is:
123456789
****** 123 // (note the space between asterisks and Numbers)

#include <iostream>
using namespace std;

void main()
{
cout<<"123456789"<<endl;
cout.width(8);
cout<<cout.fill('*')<<123<<endl;
} 

C++ also has a setw() function similar to cout.width()
These two functions do the same thing. Both control the width of the output character field and are not filled with Spaces. In C++, setw(int n) is used to control the output interval.
for example: cout< < ‘s'< < setw(8)< < ‘a'< < endl;
is displayed on the screen with 7 Spaces between
s a
s and a, and setw() only affects the output immediately following it. In the above example, means ‘a’ occupies 8 positions, and the insufficient space is filled.
If the input exceeds the length set by setw(), the actual length is output.
setw() defaults to Spaces, which can be filled with other characters using setfill().
Such as cout. The fill (‘ * ‘); After cout< < ‘s’ & lt; < setw(8)< < ‘a'< < endl; Output S ******a with seven asterisks between S and A
When setw(n) is used to set the output width, the default is right alignment. If you want it to be left aligned, you just insert STD ::left, and again, right aligned just insert STD ::right, but right aligned is the default and you don’t have to declare it explicitly.
In c++, the following functions are interusable:
setw or width()
setfill or fill()
setprecision or precision()
where the preceding set* requires header #include< iomanip>
 
 
There are some other format controls, just to mention:
Ios ::dec in decimal notation integer
ios::hex in hexadecimal notation
ios::hex in hexadecimal notation
ios::hex in hexadecimal notation
setfill(*) set padding characters *
setprecision(n) set display decimal precision n
setw(n) set field width n characters
setiosflags(ios::fixed) fixed floating point display
The index of setiosflags(ios::scientific) indicates that
setiosflags(ios::left) is left-align
setiosflags(ios::right) right-align
setiosflags(ios::skipws) ignores the leading blank
setiosflags(ios::uppercase) and outputs
Setiosflags (ios:: Lowercase) lowercase hexadecimal number output
Ios ::dec represents integers in decimal
ios::hex represents integers in hexadecimal
ios::oct represents integers in decimal
ios::showbase adds a prefix for integers in decimal
ios::internal inserts a number of padding characters in the middle of the symbol bit and value to align both ends of the string
ios::left inserts padding characters at the end of the string to align the string to the left
The padding characters are inserted before the string to cause the string to come right aligned
ios::boolalpha will represent values of the bool type as true or flase, Instead of 1 or 0
the ios: : fixed will be treated as character points according to the common fixed point format (not scientific notation)
the ios: : scientific will be treated as character points according to the scientific notation (with index domain)
the ios: : showpoint in decimal floating-point said forced insert decimal point (the default is don’t show the decimal floating-point representation of the integer)
the ios: : showpos forced to add in front of the positive number +
the ios: : skipws Empty the cache
in ios::unitbuf after an insert (each output) operation
 

Eclipse reset annotation shortcuts

I recently switched to a virtual machine and found that eclipse Settings on someone else’s virtual machine were a little bit bad. The biggest problem was that Ctrl+/ (keypad) was disabled, but Ctrl+/ (query key) can still be commented quickly.
I checked online blogs, and using what they said was the way to change the Toggle Comment Settings still didn’t work when writing C++
When I checked the Ctrl+/ setting, It turned out it wasn’t Toggle Comment, it was Comment/Uncomment
Process:
1. Click Window-& gt; preferences

2. Search for Comment/Uncomment, bind related keys in binding, and define when to take effect in when

There’s a weird thing here, Ctrl+/ (keypad) in the binding is Ctrl+ numpad_divide
Click copy Command, you can copy the same comment command, you can add your own shortcut to comment, I’ll add Ctrl+/ (big keyboard key) here

This allows you to annotate the
code with Ctrl+/ (small keyboard) and Ctrl+/ (large keyboard)

C++ —Return multiple values of different types

we usually use functions that return one or no return value.
More than one different type of return value was recently returned on a project. You can use vector to return multiple parameters of the same type. If you can use the C++11 standard, you can use my method below
(1)import the header file.

#include <tuple>
using namespace std;

(2)defined function,you can refer to the following code:

std::tuple<vector<Mat>, bool,Mat, bool,bool,bool,bool,bool,Mat,Mat,int> Table_Detection(Mat srcImage,double firstblackline_rows_ratio_thresh,bool isHorizonLine,double left_right_cols_ratio_thresh,double up_down_rows_ratio_thresh,Mat srcImageBin);

(3)function,you can refer to the following code:The type returned should be the same as the defined type.

std::tuple<vector<Mat>, bool,Mat, bool,bool,bool,bool,bool,Mat,Mat,int> Table_Detection(Mat srcImage,double firstblackline_rows_ratio_thresh,bool isHorizonLine,double left_right_cols_ratio_thresh,double up_down_rows_ratio_thresh,Mat srcImageBin)
{
;
return std::make_tuple(CUT_Table,table_new,Page_Info,isHorizonLine,table_new_cut,istablerecognition,Integrity_Check_Bottom,Integrity_Check_Top,Bottom_Integrity,Top_Integrity,tablesize);
}

(4)Now,you can call the return value. you can refer to the following code:Define a variable to receive the return parameter,the following code defines is the same as the define function.

std::tuple<vector<Mat>, bool,Mat, bool,bool,bool,bool,bool,Mat,Mat,int> data;

You also can use the auto to define. Auto is an adaptive variable in the C++11 standard.

auto data;

You can use the get method to get the data. you can refer to the following code. The code of the get<0>data actually get is CUT_Table.

std::get<0>(data);
std::get<1>(data);
std::get<2>(data);

I hope I can help you,If you have any questions, please  comment on this blog or send me a private message. I will reply in my free time.