admin管理员组文章数量:1565851
2024年5月30日发(作者:)
本文由我司收集整编,推荐下载,如有疑问,请与我司联系
Linux for Ubuntu Clion配置OpenGL(C/C++)开发环境
2018/03/09 19 1.使用 apt 安装 OpenGL 和开发包
sudo apt-get install build-essential libgl1-mesa-dev sudo apt-get install freeglut3-dev
sudo apt-get install libglew-dev libsdl2-dev libsdl2-image-dev libglm-dev libfreetype6-dev
2.写个测试demo
#include GL/glut.h #include cstdio #include cstdlib #include cmath void init(){
glClearColor(1.0, 1.0, 1.0, 0.0); //Set display-window color to white.
glMatrixMode(GL_PROJECTION); //Set projection parameters. gluOrtho2D(0.0, 200.0,
0.0, 150.0);}void lineSegment(){ glClear(GL_COLOR_BUFFER_BIT); //Clear display
window. glColor3f(1.0, 0.0, 0.0); //Set line segment color to red. glBegin(GL_LINES);
glVertex2i(180, 45); //Specify line-segment geometry glVertex2i(10, 145); glEnd();
glFlush(); //Process all OpenGL routines as quickly as possible.}int main(int argc, char
**argv) { glutInit( argc, argv); //Initialize GLUT. glutInitDisplayMode(GLUT_SINGLE |
GLUT_RGB); //Set display mode. glutInitWindowPosition(50, 100); //Set top-left display-
window position. glutInitWindowSize(400, 300); //Set display-window width and height.
glutCreateWindow(“An example OpenGL Program”); //Create display window. init();
//Execute initialization procedure. glutDisplayFunc(lineSegment); //Send graphics to
display window. glutMainLoop(); //Display everything and wait. return 0;} 3.编写
文件
cmake_minimum_required(VERSION
11)set(SOURCE_FILES 3.8)project(cg_test)set(CMAKE_CXX_STANDARD
)add_executable(cg_test
REQUIRED)find_package(GLUT
${SOURCE_FILES})find_package(OpenGL
REQUIRED)include_directories(${OPENGL_INCLUDE_DIRS}
${GLUT_INCLUDE_DIRS})target_link_libraries(${PROJECT_NAME}
${OPENGL_LIBRARIES} ${GLUT_LIBRARY})tips:感谢大家的阅读,本文由我司收
版权声明:本文标题:【IT专家】Linux for Ubuntu Clion配置OpenGL(C-C++)开发环境 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://www.elefans.com/dianzi/1717036937a529545.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论