cube例子自带的说明文档

2023-11-20


<?xml version="1.0" encoding="UTF-8"?>

Qt 5.6 Qt OpenGL Cube OpenGL ES 2.0 example
Qt 5.6.0 Reference Documentation

Cube OpenGL ES 2.0 example

This example has been written for OpenGL ES 2.0 but it works also on desktop OpenGL because this example is simple enough and for the most parts desktop OpenGL API is same. It compiles also without OpenGL support but then it just shows a label stating that OpenGL support is required.

Screenshot of the Cube example running on N900

The example consist of two classes:

  • MainWidget extends QGLWidget and contains OpenGL ES 2.0 initialization and drawing and mouse and timer event handling
  • GeometryEngine handles polygon geometries. Transfers polygon geometry to vertex buffer objects and draws geometries from vertex buffer objects.

We'll start by initializing OpenGL ES 2.0 in MainWidget.

Initializing OpenGL ES 2.0

Since OpenGL ES 2.0 doesn't support fixed graphics pipeline anymore it has to be implemented by ourselves. This makes graphics pipeline very flexible but in the same time it becomes more difficult because user has to implement graphics pipeline to get even the simplest example running. It also makes graphics pipeline more efficient because user can decide what kind of pipeline is needed for the application.

First we have to implement vertex shader. It gets vertex data and model-view-projection matrix (MVP) as parameters. It transforms vertex position using MVP matrix to screen space and passes texture coordinate to fragment shader. Texture coordinate will be automatically interpolated on polygon faces.

[cpp]  view plain  copy
  1. void main()  
  2. {  
  3.     // Calculate vertex position in screen space  
  4.     gl_Position = mvp_matrix * a_position;  
  5.   
  6.     // Pass texture coordinate to fragment shader  
  7.     // Value will be automatically interpolated to fragments inside polygon faces  
  8.     v_texcoord = a_texcoord;  
  9. }  

After that we need to implement second part of the graphics pipeline - fragment shader. For this exercise we need to implement fragment shader that handles texturing. It gets interpolated texture coordinate as a parameter and looks up fragment color from the given texture.

[cpp]  view plain  copy
  1. void main()  
  2. {  
  3.     // Set fragment color from texture  
  4.     gl_FragColor = texture2D(texture, v_texcoord);  
  5. }  

Using QGLShaderProgram we can compile, link and bind shader code to graphics pipeline. This code uses Qt Resource files to access shader source code.

[cpp]  view plain  copy
  1. <span class="type">void</span> MainWidget<span class="operator">::</span>initShaders()  
  2. {  
  3.     <span class="comment">// Compile vertex shader</span>  
  4.     <span class="keyword">if</span> (<span class="operator">!</span>program<span class="operator">.</span>addShaderFromSourceFile(<span class="type"><a target="_blank" href="../qtgui/qopenglshader.html">QOpenGLShader</a></span><span class="operator">::</span>Vertex<span class="operator">,</span> <span class="string">":/vshader.glsl"</span>))  
  5.         close();  
  6.   
  7.     <span class="comment">// Compile fragment shader</span>  
  8.     <span class="keyword">if</span> (<span class="operator">!</span>program<span class="operator">.</span>addShaderFromSourceFile(<span class="type"><a target="_blank" href="../qtgui/qopenglshader.html">QOpenGLShader</a></span><span class="operator">::</span>Fragment<span class="operator">,</span> <span class="string">":/fshader.glsl"</span>))  
  9.         close();  
  10.   
  11.     <span class="comment">// Link shader pipeline</span>  
  12.     <span class="keyword">if</span> (<span class="operator">!</span>program<span class="operator">.</span>link())  
  13.         close();  
  14.   
  15.     <span class="comment">// Bind shader pipeline for use</span>  
  16.     <span class="keyword">if</span> (<span class="operator">!</span>program<span class="operator">.</span>bind())  
  17.         close();  
  18. }  

The following code enables depth buffering and back face culling.

[cpp]  view plain  copy
  1. <span class="comment">// Enable depth buffer</span>  
  2. glEnable(GL_DEPTH_TEST);  
  3.   
  4. <span class="comment">// Enable back face culling</span>  
  5. glEnable(GL_CULL_FACE);  

Loading Textures from Qt Resource Files

QGLWidget interface implements methods for loading textures from QImage to GL texture memory. We still need to use OpenGL provided functions for specifying the GL texture unit and configuring texture filtering options.

[cpp]  view plain  copy
  1. <span class="type">void</span> MainWidget<span class="operator">::</span>initTextures()  
  2. {  
  3.     <span class="comment">// Load cube.png image</span>  
  4.     texture <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a target="_blank" href="../qtgui/qopengltexture.html">QOpenGLTexture</a></span>(<span class="type"><a target="_blank" href="../qtgui/qimage.html">QImage</a></span>(<span class="string">":/cube.png"</span>)<span class="operator">.</span>mirrored());  
  5.   
  6.     <span class="comment">// Set nearest filtering mode for texture minification</span>  
  7.     texture<span class="operator">-</span><span class="operator">></span>setMinificationFilter(<span class="type"><a target="_blank" href="../qtgui/qopengltexture.html">QOpenGLTexture</a></span><span class="operator">::</span>Nearest);  
  8.   
  9.     <span class="comment">// Set bilinear filtering mode for texture magnification</span>  
  10.     texture<span class="operator">-</span><span class="operator">></span>setMagnificationFilter(<span class="type"><a target="_blank" href="../qtgui/qopengltexture.html">QOpenGLTexture</a></span><span class="operator">::</span>Linear);  
  11.   
  12.     <span class="comment">// Wrap texture coordinates by repeating</span>  
  13.     <span class="comment">// f.ex. texture coordinate (1.1, 1.2) is same as (0.1, 0.2)</span>  
  14.     texture<span class="operator">-</span><span class="operator">></span>setWrapMode(<span class="type"><a target="_blank" href="../qtgui/qopengltexture.html">QOpenGLTexture</a></span><span class="operator">::</span>Repeat);  
  15. }  

Cube Geometry

There are many ways to render polygons in OpenGL but the most efficient way is to use only triangle strip primitives and render vertices from graphics hardware memory. OpenGL has a mechanism to create buffer objects to this memory area and transfer vertex data to these buffers. In OpenGL terminology these are referred as Vertex Buffer Objects (VBO).

Cube faces and vertices

This is how cube faces break down to triangles. Vertices are ordered this way to get vertex ordering correct using triangle strips. OpenGL determines triangle front and back face based on vertex ordering. By default OpenGL uses counter-clockwise order for front faces. This information is used by back face culling which improves rendering performance by not rendering back faces of the triangles. This way graphics pipeline can omit rendering sides of the triangle that aren't facing towards screen.

Creating vertex buffer objects and transferring data to them is quite simple using QOpenGLBuffer. MainWidget makes sure the GeometryEngine instance is created and destroyed with the OpenGL context current. This way we can use OpenGL resources in the constructor and perform proper cleanup in the destructor.

[cpp]  view plain  copy
  1. GeometryEngine<span class="operator">::</span>GeometryEngine()  
  2.     : indexBuf(<span class="type"><a target="_blank" href="../qtgui/qopenglbuffer.html">QOpenGLBuffer</a></span><span class="operator">::</span>IndexBuffer)  
  3. {  
  4.     initializeOpenGLFunctions();  
  5.   
  6.     <span class="comment">// Generate 2 VBOs</span>  
  7.     arrayBuf<span class="operator">.</span>create();  
  8.     indexBuf<span class="operator">.</span>create();  
  9.   
  10.     <span class="comment">// Initializes cube geometry and transfers it to VBOs</span>  
  11.     initCubeGeometry();  
  12. }  
  13.   
  14. GeometryEngine<span class="operator">::</span><span class="operator">~</span>GeometryEngine()  
  15. {  
  16.     arrayBuf<span class="operator">.</span>destroy();  
  17.     indexBuf<span class="operator">.</span>destroy();  
  18. }  
  19.     <span class="comment">// Transfer vertex data to VBO 0</span>  
  20.     arrayBuf<span class="operator">.</span>bind();  
  21.     arrayBuf<span class="operator">.</span>allocate(vertices<span class="operator">,</span> <span class="number">24</span> <span class="operator">*</span> <span class="keyword">sizeof</span>(VertexData));  
  22.   
  23.     <span class="comment">// Transfer index data to VBO 1</span>  
  24.     indexBuf<span class="operator">.</span>bind();  
  25.     indexBuf<span class="operator">.</span>allocate(indices<span class="operator">,</span> <span class="number">34</span> <span class="operator">*</span> <span class="keyword">sizeof</span>(GLushort));  

Drawing primitives from VBOs and telling programmable graphics pipeline how to locate vertex data requires few steps. First we need to bind VBOs to be used. After that we bind shader program attribute names and configure what kind of data it has in the bound VBO. Finally we'll draw triangle strip primitives using indices from the other VBO.


[cpp]  view plain  copy
  1. <span class="type">void</span> GeometryEngine<span class="operator">::</span>drawCubeGeometry(<span class="type"><a target="_blank" href="../qtgui/qopenglshaderprogram.html">QOpenGLShaderProgram</a></span> <span class="operator">*</span>program)  
  2. {  
  3.     <span class="comment">// Tell OpenGL which VBOs to use</span>  
  4.     arrayBuf<span class="operator">.</span>bind();  
  5.     indexBuf<span class="operator">.</span>bind();  
  6.   
  7.     <span class="comment">// Offset for position</span>  
  8.     quintptr offset <span class="operator">=</span> <span class="number">0</span>;  
  9.   
  10.     <span class="comment">// Tell OpenGL programmable pipeline how to locate vertex position data</span>  
  11.     <span class="type">int</span> vertexLocation <span class="operator">=</span> program<span class="operator">-</span><span class="operator">></span>attributeLocation(<span class="string">"a_position"</span>);  
  12.     program<span class="operator">-</span><span class="operator">></span>enableAttributeArray(vertexLocation);  
  13.     program<span class="operator">-</span><span class="operator">></span>setAttributeBuffer(vertexLocation<span class="operator">,</span> GL_FLOAT<span class="operator">,</span> offset<span class="operator">,</span> <span class="number">3</span><span class="operator">,</span> <span class="keyword">sizeof</span>(VertexData));  
  14.   
  15.     <span class="comment">// Offset for texture coordinate</span>  
  16.     offset <span class="operator">+</span><span class="operator">=</span> <span class="keyword">sizeof</span>(QVector3D);  
  17.   
  18.     <span class="comment">// Tell OpenGL programmable pipeline how to locate vertex texture coordinate data</span>  
  19.     <span class="type">int</span> texcoordLocation <span class="operator">=</span> program<span class="operator">-</span><span class="operator">></span>attributeLocation(<span class="string">"a_texcoord"</span>);  
  20.     program<span class="operator">-</span><span class="operator">></span>enableAttributeArray(texcoordLocation);  
  21.     program<span class="operator">-</span><span class="operator">></span>setAttributeBuffer(texcoordLocation<span class="operator">,</span> GL_FLOAT<span class="operator">,</span> offset<span class="operator">,</span> <span class="number">2</span><span class="operator">,</span> <span class="keyword">sizeof</span>(VertexData));  
  22.   
  23.     <span class="comment">// Draw cube geometry using indices from VBO 1</span>  
  24.     glDrawElements(GL_TRIANGLE_STRIP<span class="operator">,</span> <span class="number">34</span><span class="operator">,</span> GL_UNSIGNED_SHORT<span class="operator">,</span> <span class="number">0</span>);  
  25. }  

Perspective Projection

Using QMatrix4x4 helper methods it's really easy to calculate perpective projection matrix. This matrix is used to project vertices to screen space.

[cpp]  view plain  copy
  1. <span class="type">void</span> MainWidget<span class="operator">::</span>resizeGL(<span class="type">int</span> w<span class="operator">,</span> <span class="type">int</span> h)  
  2. {  
  3.     <span class="comment">// Calculate aspect ratio</span>  
  4.     <span class="type"><a target="_blank" href="../qtcore/qtglobal.html#qreal-typedef">qreal</a></span> aspect <span class="operator">=</span> <span class="type"><a target="_blank" href="../qtcore/qtglobal.html#qreal-typedef">qreal</a></span>(w) <span class="operator">/</span> <span class="type"><a target="_blank" href="../qtcore/qtglobal.html#qreal-typedef">qreal</a></span>(h <span class="operator">?</span> h : <span class="number">1</span>);  
  5.   
  6.     <span class="comment">// Set near plane to 3.0, far plane to 7.0, field of view 45 degrees</span>  
  7.     <span class="keyword">const</span> <span class="type"><a target="_blank" href="../qtcore/qtglobal.html#qreal-typedef">qreal</a></span> zNear <span class="operator">=</span> <span class="number">3.0</span><span class="operator">,</span> zFar <span class="operator">=</span> <span class="number">7.0</span><span class="operator">,</span> fov <span class="operator">=</span> <span class="number">45.0</span>;  
  8.   
  9.     <span class="comment">// Reset projection</span>  
  10.     projection<span class="operator">.</span>setToIdentity();  
  11.   
  12.     <span class="comment">// Set perspective projection</span>  
  13.     projection<span class="operator">.</span>perspective(fov<span class="operator">,</span> aspect<span class="operator">,</span> zNear<span class="operator">,</span> zFar);  
  14. }  

Orientation of the 3D Object

Quaternions are handy way to represent orientation of the 3D object. Quaternions involve quite complex mathematics but fortunately all the necessary mathematics behind quaternions is implemented in QQuaternion. That allows us to store cube orientation in quaternion and rotating cube around given axis is quite simple.

The following code calculates rotation axis and angular speed based on mouse events.

[cpp]  view plain  copy
  1. <span class="type">void</span> MainWidget<span class="operator">::</span>mousePressEvent(<span class="type"><a target="_blank" href="../qtgui/qmouseevent.html">QMouseEvent</a></span> <span class="operator">*</span>e)  
  2. {  
  3.     <span class="comment">// Save mouse press position</span>  
  4.     mousePressPosition <span class="operator">=</span> QVector2D(e<span class="operator">-</span><span class="operator">></span>localPos());  
  5. }  
  6.   
  7. <span class="type">void</span> MainWidget<span class="operator">::</span>mouseReleaseEvent(<span class="type"><a target="_blank" href="../qtgui/qmouseevent.html">QMouseEvent</a></span> <span class="operator">*</span>e)  
  8. {  
  9.     <span class="comment">// Mouse release position - mouse press position</span>  
  10.     QVector2D diff <span class="operator">=</span> QVector2D(e<span class="operator">-</span><span class="operator">></span>localPos()) <span class="operator">-</span> mousePressPosition;  
  11.   
  12.     <span class="comment">// Rotation axis is perpendicular to the mouse position difference</span>  
  13.     <span class="comment">// vector</span>  
  14.     QVector3D n <span class="operator">=</span> QVector3D(diff<span class="operator">.</span>y()<span class="operator">,</span> diff<span class="operator">.</span>x()<span class="operator">,</span> <span class="number">0.0</span>)<span class="operator">.</span>normalized();  
  15.   
  16.     <span class="comment">// Accelerate angular speed relative to the length of the mouse sweep</span>  
  17.     <span class="type"><a target="_blank" href="../qtcore/qtglobal.html#qreal-typedef">qreal</a></span> acc <span class="operator">=</span> diff<span class="operator">.</span>length() <span class="operator">/</span> <span class="number">100.0</span>;  
  18.   
  19.     <span class="comment">// Calculate new rotation axis as weighted sum</span>  
  20.     rotationAxis <span class="operator">=</span> (rotationAxis <span class="operator">*</span> angularSpeed <span class="operator">+</span> n <span class="operator">*</span> acc)<span class="operator">.</span>normalized();  
  21.   
  22.     <span class="comment">// Increase angular speed</span>  
  23.     angularSpeed <span class="operator">+</span><span class="operator">=</span> acc;  
  24. }  

QBasicTimer is used to animate scene and update cube orientation. Rotations can be concatenated simply by multiplying quaternions.

[cpp]  view plain  copy
  1. <span class="type">void</span> MainWidget<span class="operator">::</span>timerEvent(<span class="type"><a target="_blank" href="../qtcore/qtimerevent.html">QTimerEvent</a></span> <span class="operator">*</span>)  
  2. {  
  3.     <span class="comment">// Decrease angular speed (friction)</span>  
  4.     angularSpeed <span class="operator">*</span><span class="operator">=</span> <span class="number">0.99</span>;  
  5.   
  6.     <span class="comment">// Stop rotation when speed goes below threshold</span>  
  7.     <span class="keyword">if</span> (angularSpeed <span class="operator"><</span> <span class="number">0.01</span>) {  
  8.         angularSpeed <span class="operator">=</span> <span class="number">0.0</span>;  
  9.     } <span class="keyword">else</span> {  
  10.         <span class="comment">// Update rotation</span>  
  11.         rotation <span class="operator">=</span> <span class="type"><a target="_blank" href="../qtgui/qquaternion.html">QQuaternion</a></span><span class="operator">::</span>fromAxisAndAngle(rotationAxis<span class="operator">,</span> angularSpeed) <span class="operator">*</span> rotation;  
  12.   
  13.         <span class="comment">// Request an update</span>  
  14.         update();  
  15.     }  
  16. }  

Model-view matrix is calculated using the quaternion and by moving world by Z axis. This matrix is multiplied with the projection matrix to get MVP matrix for shader program.

[cpp]  view plain  copy
  1. <span class="comment">// Calculate model view transformation</span>  
  2. QMatrix4x4 matrix;  
  3. matrix<span class="operator">.</span>translate(<span class="number">0.0</span><span class="operator">,</span> <span class="number">0.0</span><span class="operator">,</span> <span class="operator">-</span><span class="number">5.0</span>);  
  4. matrix<span class="operator">.</span>rotate(rotation);  
  5.   
  6. <span class="comment">// Set modelview-projection matrix</span>  
  7. program<span class="operator">.</span>setUniformValue(<span class="string">"mvp_matrix"</span><span class="operator">,</span> projection <span class="operator">*</span> matrix);  

Files:

© 2016 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners.
The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation.
Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.



from: http://blog.csdn.net/fu851523125/article/details/51169440



本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

cube例子自带的说明文档 的相关文章

  • glBitmap 问题

    我正在使用一些遗留代码来工作 它使用 glBitmap 调用来绘制位图图标 我的问题是 一旦你一次绘制大约 1000 个图标 它就会变得相当慢 它会减慢到大约 1 到 2 秒的刷新率 我想看看是否可以让它更快 首先我应该描述当前代码是如何工
  • OpenGL:仅使用一个帧缓冲区并切换目标纹理

    我是否可以只创建一个帧缓冲区对象并通过在需要时切换其目标纹理来实现相同的结果 而不是使用多个帧缓冲区对象 在所有情况下这都是一个坏主意吗 如果是 为什么 我一直在实现一个功能render SetTargetTexture 在我的程序的 AP
  • 模拟绘画应用的笔触

    我正在尝试编写一个应用程序 可用于使用模拟笔触创建看起来像绘画的图片 是否有任何好的资源可以提供模拟笔触的简单方法 例如 给定用户拖动鼠标经过的鼠标位置列表 画笔宽度和画笔纹理 如何确定要在画布上绘制的内容 我尝试将画笔纹理倾斜到鼠标移动的
  • glGenerateMipmap 是否在 sRGB 纹理的线性空间中执行平均?

    OpenGL 3 3 规范似乎没有要求 mipmap 生成在线性空间中完成 我能找到的只有以下内容 派生的 mipmap 数组的内部格式都与 levelbase 数组和派生数组的维度如下 第 3 8 14 节中描述的要求 的内容 派生数组是
  • VBO - 没有指数化的指数化

    我正在尝试将 VBO 与元素数组缓冲区一起用于我的三角形 如下所示 glBindBuffer GL ARRAY BUFFER g Buffer 0 glVertexPointer 3 GL FLOAT 0 BUFFER OFFSET 0 g
  • 将 CVPixelBuffer 渲染到 NSView (macOS)

    我有一个CVPixelBuffer我正在尝试在屏幕上有效地绘制 转变为低效率的方式NSImage可以工作 但速度非常慢 丢掉了大约 40 的帧数 因此 我尝试使用将其渲染在屏幕上CIContext s drawImage inRect fr
  • OpenGL NURBS 曲面

    我正在学习 OpenGL 我想要一个中间有轻微驼峰的表面 我目前正在使用这段代码 但我不确定如何调整 ctrl 点以使其达到我想要的方式 它目前就像 我想要这样的 我不完全确定我应该使用哪些控制点 并且我对其工作原理感到困惑 include
  • 没有着色器的 OpenGL

    我已经阅读了一些教程来编写以下代码 唯一的区别是原始教程使用 SDL 而不是 GLEW 我不明白这段代码有什么问题 它可以编译 但我没有看到三角形 教程也没有使用着色器 include
  • 纹理openGl。 C++、qt

    我试图用草纹理覆盖我的地形 由高度图制成 但它没有按预期工作 我什至无法在简单的 GL QUAD 上获取纹理 结果是多色网络 void GLWidget initializeGL glEnable GL TEXTURE 2D 在 QGLwi
  • CPU 到 GPU 法线映射

    我正在创建一个地形网格 然后这个答案 https stackoverflow com a 5284527 1356106我正在尝试将 CPU 计算法线迁移到基于着色器的版本 以便通过降低网格分辨率并使用在片段着色器中计算的法线贴图来提高性能
  • glutPostRedisplay 不在循环内工作

    我试图让一个人在 y 轴上跳跃 所以我使用 2 秒的循环 第一秒它应该向下移动并弯曲膝盖 第二秒它应该向上移动 然后在起始位置完成 现在我刚刚开始让这个人在第一秒内跪下并弯曲膝盖 我还没有编写动画的其余部分 问题是 glutPostRedi
  • QOpenGLFunctions 缺少重要的 OpenGL 函数

    QOpenGLFunctions 似乎缺少重要的函数 例如 glInvalidateFramebuffer 和 glMapBuffer 据我了解 QOpenGLFunctions 加载桌面 OpenGL 函数和 ES 函数的交集 如果是这样
  • OpenGL 和加载/读取 AoSoA(混合 SoA)格式的数据

    假设我有以下 AoSoA 格式的简化结构来表示顶点或点 struct VertexData float px 4 position x float py 4 position y 也就是说 每个实例VertexData存储4个顶点 我见过的
  • gluPerspective 与 gluOrtho2D

    我查看了 MSDN 上关于这两个函数的文档 但是 我不太明白这两个功能之间的区别 一个是用于设置 3D 相机视图 另一个是用于设置 2D 相机视图 如果能得到解答就太好了 预先感谢您的评论 正交投影基本上是没有透视的 3D 投影 本质上 这
  • OpenGL 中连续暂停

    void keyPress unsigned char key int x int y int i switch key case f i 3 while i x pos 3 sleep 100 glutPostRedisplay 上面是在
  • glut 库中缺少 glutInitContextVersion()

    我正在练习一些 opengl 代码 但是当我想通过以下方式强制 opengl 上下文使用特定版本的 opengl 时glutInitContextVersion 它编译过程失败并给出以下消息 使用未声明的标识符 glutInitContex
  • 为什么OpenGL使用float而不是double? [关闭]

    就目前情况而言 这个问题不太适合我们的问答形式 我们希望答案得到事实 参考资料或专业知识的支持 但这个问题可能会引发辩论 争论 民意调查或扩展讨论 如果您觉得这个问题可以改进并可能重新开放 访问帮助中心 help reopen questi
  • 无法在 WSL2 上运行 OpenGL

    我尝试在 WSL2 上运行 OpenGL 代码 但在尝试运行可执行文件时出现以下错误 GLFW error 65543 GLX Failed to create context GLXBadFBConfig Unable to create
  • 为什么拥有单独的投影矩阵但结合模型和视图矩阵会有好处?

    当您学习 3D 编程时 您会被告知用 3 个变换矩阵来思考是最简单的 模型矩阵 该矩阵对于每个模型都是独立的 它根据需要旋转和缩放对象 最后将其移动到 3D 世界中的最终位置 模型矩阵将模型坐标转换为世界坐标 视图矩阵 对于大量对象 如果不
  • 将带有 glut 的点击坐标添加到向量链接列表中

    我想创建一个向量链接列表 并在 GLUT 库的帮助下获取点击的位置并将它们附加到链接列表中 这些是我写的结构 typedef struct vector int x int y Vector typedef struct VectorLis

随机推荐

  • 图解GitHub和SourceTree入门教程

    http blog csdn net collonn article details 39259227
  • 想去游戏公司做游戏,最重要的是什么素养?

    首先 要学会沟通 话说 动过去游戏公司的念头 做游戏 感觉很酷 但是 想想自己一不会编程 二不会画画 做策划 那好像是两边受气里外不是人出事第一个背锅的角色 想想也就想想 不过正好前些天我们发过一篇讲去日本学游戏的文章 说不定能派上用场 前
  • 华为OD机试真题- 学校的位置【2023Q1】【JAVA、Python、C++】

    题目描述 为了解决新学期学生暴涨的问题 小乐村要建所新学校 考虑到学生上学安全问题 需要所有学生家到学校距离最短 假设学校和所有的学生家 走在一条直线上 请问 学校要建在什么位置 能使得学校到各个学生家的距离之和最短 输入描述 输入的第一行
  • sql语句中的空值(null)

    含null值的表达式都为null null null 在判断某个数是否为null的时候不是用等号来表示 而是用 is null 在过滤的时候 可以使用in null 但是使用not in null的时候会报错 因为in函数 是指满足里面的情
  • java入门的第一个程序代码 hello world

    很多人说 学Java真的很难 其实 这是真的 但是高薪之所以为高薪 就是因为它比普通的活难的多 今天是我第一篇的博客 我还是想鼓励想学java技术的小伙伴一起来学 很多事只有去做了 你才能知道自己能不能成功 好了 接下来看Java入门的第一
  • 网易云音乐财报解读:收入大增亏损收窄,“云村”草长莺飞

    独家版权时代结束后 在线音乐产业进入了新的发展阶段 各家音乐平台经营状况备受关注 2月23日 网易云音乐公布了2022年全年财务业绩 财报显示 网易云音乐2022年全年收入为90亿元 较2021年同比增长28 5 值得一提的是 得益于盈利能
  • 数组的一些简单操作,列表改数组,数组合并,数组存取

    数组的简单操作 总用的一些操作 记录一下 要不总忘 1列表改数组 import numpy as np a 1 2 3 4 a np array a 输出a array 1 2 3 4 2数组合并 延竖轴拼接数组 aa np vstack
  • hive中取最大值最小值的函数

    max 和min 函数 select a max b from t group by a select a min b from t group by a max和min函数是取某一列中的最大或者最小值 greatest 和least 函数
  • R数据科学-第九章使用lubridate处理日期和时间

    本章将会使用以下三个包 gt library tidyverse gt library lubridate gt library nycflights13 一 创建日期或时间 表示日期或时间的数据有三种 日期 在tibble中显示为date
  • C#学习笔记 事件

    事件为委托提供了一种发布 订阅机制 声明事件的类被称为发行者类 其他类可以订阅发行者类中的事件 当发行者类触发其中的事件时 所有订阅该事件的类都会收到这个变化 在图形界面框架中 这种情况非常常见 事件发布者 首先需要创建一个事件发布者类 该
  • python自动化笔记(十一)——openpyxl之封装

    封装一个可以读取任意excel文件的方法 可以指定读取的表单 当我们多次从excel中读取数据时 就不用重复地写代码 只需调用封装的类即可 一 封装的excel类实现的需求是什么 1 读取表头数据 2 读取表头以外的所有数据 返回值 列表
  • DHCP的配置(以华为eNSP为例)

    如有错误 敬请谅解 此文章仅为本人学习笔记 仅供参考 如有冒犯 请联系作者删除 基础知识介绍 络组建步骤 1 拓扑设计 2 IP地址规划 按照拓扑中划分的 络范围 规划 络位不同的IP地址 3 配置 1 配置各个节点的IP地址 2 路由 全
  • qbytearray的append是浅拷贝还是深拷贝_前端深拷贝和浅拷贝

    在前端攻城狮的工作实际应用中 有很多情况下在处理数据的时候 会用到数据的深拷贝和浅拷贝 例如 vue中数据是双向绑定的 页面显示依赖于从后台获取到的数据 但要将这个数据当做参数发送给另外一个接口的时候 其中有几个字段是多余的 此时 如果将原
  • 时间序列 R 07 时间序列分解 Time series decomposition

    一个时间序列可以分解为多个模型的组合 1 1 时间序列的组成 1 1 1 时间序列组成模式 三种时间序列模式 不计剩余残差部分 1 趋势Tend 比如线性趋势 先增加后降低的整体趋势 2 季节性Seasonal 以时间为固定周期 呈现循环的
  • IT项目管理个人作业8

    质量标准 量度 学历 博士以上 教学经验 5年以上 论文发布 10篇以上 逻辑表达能力 思路清晰 讲话清楚 性格 耐心 热情 同行评价 良好及以上 画出QQ图 因为数据量太少 可以推测它是符合正态分布的
  • 我的图床解决方案,超详细!

    图床就是将你的本地图片上传到相关服务商或者个人服务器 然后获取图片对应的网络访问地址 使用者可以方便快速的将图片插入到文章中 后续图片二次使用 迁移 分享都会非常简单 我之前常用的图床方案是使用Gitee的仓库来实现 我的博客 1 周刊 2
  • yaml学习

    1 yaml是专门用来写配置文件的语言 非常强大和简洁 远比json格式方便 可用之作为自动化测试框架的配置文件或者用例文件 2 使用场景 做配置文件 做测试用例 3 语法基本规则 大小写敏感 使用缩进表示层级关系 缩进的空格数目不重要 只
  • MySql笔记

    全部案例sql语句 https blog csdn net weixin 46002478 article details 109158249 视频学习地址 https www bilibili com video BV1KW411u7vy
  • 大端模式和小端模式转化

    在工作中遇到一个问题 数据是以大端模式存储的 而机器是小端模式 必须进行转换 否则使用时会出问题 一 定义 大端模式 Big Endian 数据的高字节 保存在内存的低地址中 数据的低字节 保存在内存的高地址中 小端模式 Little En
  • cube例子自带的说明文档

    Qt 5 6 Qt OpenGL Cube OpenGL ES 2 0 example Qt 5 6 0 Reference Documentation Contents Initializing OpenGL ES 2 0 Loading