技术标签: 笔记
直接在项目文件夹内配置,不需要到处复制的方法。
关于 MinGW 的 配置跳过,可以参考https://blog.csdn.net/zwx19921215/article/details/83306119
配置 OpenGL 步骤:
project(OpenGL) #填你的项目名
include_directories(include)
link_directories(lib/x64)
set(CMAKE_C_STANDARD 14) #我选的是 C++14 版本
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY bin)
#测试
add_executable(main main.cpp) #前为编译完成后的exe文件名,随便写就行了, 后面是 cpp 源文件的相对路径
target_link_libraries(main libopengl32.a libfreeglut.a glu32.dll) #链接对应的库文件
测试代码:
#include <GL/glut.h>
GLsizei winWidth = 600, winHeight = 500;
GLubyte label[36] = {
'J', 'a', 'n', 'F', 'e', 'b', 'M', 'a', 'r',
'A', 'p', 'r', 'M', 'a', 'y', 'J', 'u', 'n',
'J', 'u', 'l', 'A', 'u', 'g', 'S', 'e', 'p',
'O', 'c', 't', 'N', 'o', 'v', 'D', 'e', 'c'};
GLint dataValue[12] = {
420, 342, 324, 310, 262, 185, 190, 196, 217, 240, 312, 438};
void initWindow(int argc, char* argv[]) {
glutInit(&argc, argv);
glutInitWindowSize(winWidth, winHeight);
glutInitWindowPosition(100, 100);
glutCreateWindow("P105");
}
void initBackground() {
glClearColor(1, 1, 1, 0);
glMatrixMode(GL_PROJECTION);
//glOrtho(0, winWidth, 0, winHeight, -1, 1);
gluOrtho2D(0, winWidth, 0, winHeight);
}
void lineGraph() {
GLint xRaster = 25, yRaster = 150;
glClear(GL_COLOR_BUFFER_BIT);
glColor3d(0, 0, 1);
glBegin(GL_LINE_STRIP);
for (GLint k = 0; k < 12; k ++) {
glVertex2i(xRaster + k * 50, dataValue[k]);
}
glEnd();
glColor3d(1, 0, 0);
for (GLint k = 0; k < 12; k ++) {
glRasterPos2i(xRaster + k * 50, dataValue[k] - 4);
glutBitmapCharacter(GLUT_BITMAP_9_BY_15, '*');
}
glColor3d(0, 0, 0);
xRaster = 20;
for (GLint month = 0; month < 12; month ++) {
glRasterPos2i(xRaster, yRaster);
for (GLint k = 3 * month; k < 3 * month + 3; k ++) {
glutBitmapCharacter(GLUT_BITMAP_HELVETICA_12, label[k]);
}
xRaster += 50;
}
glFlush();
}
void barChart() {
GLint xRaster = 20, yRaster = 150;
glClear(GL_COLOR_BUFFER_BIT);
glColor3f(1, 0, 0);
for (GLint k = 0; k < 12; k ++) {
glRecti(20 + k * 50, 165, 40 + k * 50, dataValue[k]);
}
glColor3d(0, 0, 0);
for (GLint month = 0; month < 12; month ++) {
glRasterPos2i(xRaster, yRaster);
for (GLint k = 3 * month; k < 3 * month + 3; k ++) {
glutBitmapCharacter(GLUT_BITMAP_HELVETICA_12, label[k]);
}
xRaster += 50;
}
glFlush();
}
void winReshapeFcn(GLint newWidth, GLint newHeight) {
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0, (GLdouble)newWidth, 0, (GLdouble)newHeight, -1, 1);
glClear(GL_COLOR_BUFFER_BIT);
}
int main(int argc, char* argv[]) {
initWindow(argc, argv);
initBackground();
//glutDisplayFunc(lineGraph);
glutDisplayFunc(barChart);
glutReshapeFunc(winReshapeFcn);
glutMainLoop();
return 0;
}
生成以下结果:
文章浏览阅读1.2k次,点赞21次,收藏32次。GBase8c GDCA题库_如何查看用户test被恶意锁定 (多选题,3分) a.打开运行日志,搜索关键字进行查询 b.
文章浏览阅读2.2k次,点赞4次,收藏11次。参考资料:1.泰勒公式、泰勒定理、泰勒级数、泰勒展开式之间的关系2.这一切都从指数函数开始(2)——Fourier级数和变换3.傅里叶级数_整体泰勒公式和局部泰勒公式区别
文章浏览阅读436次,点赞18次,收藏14次。msg_box = QMessageBox(QMessageBox.Warning, ‘错误提示’, ‘用户名或者密码错误’)msg_box = QMessageBox(QMessageBox.Warning, ‘错误提示’, ‘该用户不存在’)msg_box = QMessageBox(QMessageBox.Warning, ‘错误提示’, ‘系统错误’)msg_box = QMessageBox(QMessageBox.Warning, ‘错误提示’, ‘系统错误’)
文章浏览阅读1.8k次。#include<stdio.h>int dyh(int n){ int i; int sum=0; for(i=1;i<=n;i++) { sum=i*i+sum; printf("sum=%d\n",sum); }}int main(){ int n; scanf("%d",&n); dyh(n);}..._使用函数的调用计算sum=1!+2!+3!+......+n!其中n!=1*2*3*....n;设置一个计算阶乘
文章浏览阅读214次。python 装饰器分类_python装饰器种类
文章浏览阅读1.7w次,点赞12次,收藏22次。问题描述在学习案例的时候遇到一个知识点,顺手在源文件空白处编辑了一段,发现vs开始报错严重性说明错误(活动)此声明没有存储类或类型说明符在函数体外进行赋值的时候就会出现这个问题。比如out_type convert(const in_value& t) { //sample1 stringstream stream; stream << t; out_type result; stream >> result; return r_此声明没有存储类或类型说明符
文章浏览阅读601次,点赞9次,收藏9次。基于STM32单片机的智能公交车语音报站系统设计RFID射频识别站台信息JR6001语音播报电机控制开关门DIY开发板套件100。_基于stm32的rfid读卡器可以播报吗
文章浏览阅读722次。网易云音乐的歌单推荐算法是怎样的呢?最近有很多人关心这个问题。调查了一些网易云音乐的重度患者,小咖带你来看一些路过大神的精辟分析。分析一:“商品推荐”系统的算法( Collaborati..._网易云音乐推荐算法csdn
文章浏览阅读1.4k次,点赞6次,收藏10次。定义bind() 方法创建一个新的函数,在 bind() 被调用时,这个新函数的 this 被指定为 bind() 的第一个参数,而其余参数将作为新函数的参数,供调用时使用。由定义可知,函数调用bind()方法的时候,会返回一个新函数,并且this指向bind函数的第一个参数,简单来表示。fn.bind(obj对象)执行 返回一个函数,想调用的时候,fn.bind(obj)()这样来执行;举个例子:var name = '炒米粉';var obj = { name: '程序员米粉'};f_js手写bind
文章浏览阅读95次。问题分析主要是如何确定格子在图形内部还是外部#include <cstdio>#include <cstring>#include <iostream>#include <cmath>#include <vector>#include <utility>using namespace std;char s[..._ascii area uva - 1641
文章浏览阅读134次。International CES Asia在我眼中,过去的这两天从参展商、参展品种、展会规模以及媒体评论来看,有趋之若鹜的,有嗤之以鼻,有来了如鱼得水的,有置之度外装高冷的……无论怎样,四十多年历史的CES focus亚洲的首秀就结束了。Anyway,明年5月11-13,SeeYouAgain。物联网,一个精彩的时代虽然是老美隔了个太平洋来亚..._ibm大中华区全球企业咨询服务部汽车及工业产品行业总经理王涛
文章浏览阅读3.6k次。直接放源码import 'package:flutter/gestures.dart';import 'package:flutter/material.dart';class FixTabBarView extends StatefulWidget { const FixTabBarView({ Key key, @required this.children, ..._flutter tabbarview 设置默认值不起作用