OpenGL is used in the Cocos2d-x project, and line antialiasing is turned on using Gl_line_smooth. The code is as follows:
CCDRAWCOLOR4B (50, 26, 12, 255);//Set line width gllinewidth (2.0f); Enable segment anti-aliasing glenable (Gl_line_smooth); Draw the first line ccdrawline (startpoint1,endpoint);//Draw the second line ccdrawline (startpoint2,endpoint);//Turn off segment anti-aliasing gldisable (gl_line_ SMOOTH);
Error when compiling Android project with NDK: ' Gl_line_smooth ' is not declared in this scope
Development Environment Description:
Engine version
cocos2d-x2.2.1
Development tools
Visual Studio 2012
Android NDKR9
System
Windows7
Error: ' Gl_line_smooth ' is not declared in this scope, indicating that Gl_line_smooth did not find the definition.
1. Then open the Cocos2d.h and locate the OpenGL-related header file under the Android platform CCGL.h
2.ccgl.h contains header files in Gl2.h and gl2ext.h two header files,<> is preferred in system path lookup
So we go to the NDK path to find the file, these two header files are in the GLES2 directory, the directory contains OpenGL ES2.0 related header files
The definition of Gl_line_smooth was not found after viewing gl2.h and glext.h, indicating that this could be defined in the OpenGL ES1.0 related header file
3. Then go to the Gles directory to find
So I found the definition of Gl_line_smooth in the gl.h header file.
4. In the CCGL.h header file under the Android platform, # include <GLES/gl.h> will solve the problem.
"Cocos2d-x" prompted error when compiling Android project: ' Gl_line_smooth ' is not declared in this scope