- 博客(29)
- 资源 (1)
- 收藏
- 关注
原创 Qt 游戏开发(06) - 为游戏增加健康值和得分
之前写的文章中,大多数属于贴代码的类型,经过一段时间后,自己对于代码的理解并没什么什么裨益,反而让自己觉得写代码就是贴代码,丧失很多兴趣,水平也得不到提高。在看过那么多大牛写的文章之后,也决心结合自己的长处开始写些比较好的文章。 闲话少说,此文章是之前C++ Qt Game Tutorial的续集,只是把标题换成更中文一些。1. 新建一个widget工程,工程名字为tutorial6,删
2017-01-23 18:20:15 2037
原创 qt opengl lesson6 给立体图形绘制纹理
给一个立方体绘制纹理,加载图片,使立方体围绕X,Y,Z轴旋转。#-------------------------------------------------## Project created by QtCreator 2017-01-21T10:04:18##-------------------------------------------------QT
2017-01-21 11:08:30 773
原创 qt opengl lesson5 绘制3d立体旋转图形
继续上一篇lesson,先将3d立体各个面写完,然后进行旋转,感觉每个面单独写比较费时,这大概是3d比较麻烦和难以理解的地方,需要建立良好的空间想象力。#-------------------------------------------------## Project created by QtCreator 2017-01-20T22:32:22##---------------
2017-01-20 23:48:03 2460
原创 qt opengl lesson4 围绕不同轴旋转图形
在上一篇lesson的基础上进行图形的旋转,设置一个timer,每经过一个周期开始增加旋转角度。#-------------------------------------------------## Project created by QtCreator 2017-01-20T21:24:37##-------------------------------------------
2017-01-20 22:30:49 655
原创 C++ Qt Game Tutorial 5 - Adding Enemies
给游戏新增加敌人,利用cllidingItem()方法表示两个物体是否相交。#-------------------------------------------------## Project created by QtCreator 2017-01-19T23:17:02##-------------------------------------------------QT
2017-01-20 01:52:31 548
原创 qt opengl lesson3 给三角形和正方形上色
之前每章的结构基本相同,很多函数不需要现在明白什么道理,可能设计到一些空间图形和计算机学的知识,可以放在需要的时候专门学习。#-------------------------------------------------## Project created by QtCreator 2017-01-19T22:12:43##-----------------------------
2017-01-19 23:03:00 635
原创 qt opengl lesson2 绘制一个三角形和一个正方形
在lesson1的基础上加入一个三角形和一个正方形。#-------------------------------------------------## Project created by QtCreator 2017-01-19T20:33:38##-------------------------------------------------QT += co
2017-01-19 21:03:56 1231
原创 qt opengl lesson1 建立一个opengl窗口
这是一个系列的文章,这个系列来自于github上的一个开源项目https://github.com/chenzilin/qt-opengl之前也看到其它的博客上有翻译到这些文章,但是那些实例都比较旧,到新版本qt creator中不大不能运行,所以就有了新翻译一个系列的方法。还有就是git上的提交相比于之前增加了很多lesson,有助于想学习qt opengl的程序员更深入学习理解op
2017-01-19 20:29:44 720
原创 使用github和jekyll搭建自己的blog
偶然的机会听说可以在github建立自己的网站,然后就搜了搜网上的例子,搭建了一个。如果用过git的程序员,整个过程非常简单。1.安装jekyllubuntu为例,安装jekyll需要安装ruby,ubuntu中的ruby版本太旧,会碰到类似的安装错误的问题如果没有安装gem,安装 sudo apt-get install gem$ sudo gem install j
2017-01-19 17:22:34 553
原创 C++ Qt Game Tutorial 4 - Cleaning Up
飞机离开scene框之后,需要把它清除。#include #include "bullet.h"#include Bullet::Bullet(){ setRect(0, 0, 10, 50); QTimer *timer = new QTimer(); connect(timer, SIGNAL(timeout()), this, SLOT(move()));
2017-01-19 09:51:03 506
原创 qt 保存为svg图片
添加#include #include QT += core gui svg一些重要的头文件以及声明。创建menu bar, 命名一个Save as SVG,添加一个slog,源码如下;#include "basicshapewindow.h"#include "ui_basicshapewindow.h"#include #include BasicShapeW
2017-01-19 01:12:22 3444
原创 qt 使用QPainter绘图
QPainter 绘制一些简单的图形,也可以设置文字,设置笔,路径等。需要实现paintEvent这个方法,然后使用QPainter需要传入this指针,表示父类会调用。#include "basicshapewindow.h"#include "ui_basicshapewindow.h"BasicShapeWindow::BasicShapeWindow(QWidget *par
2017-01-19 00:07:30 1827
原创 C++ Qt Game Tutorial 3 - Shooting With the Spacebar
移动矩形,在第一个例子基础上,建立一个矩形类,实现keyPressEvent方法。空格键的地方写了一个子弹(bullet), 里面有一个定时器,不停地向上移动, 利用到了qt 的一个很重要的特性,signal and slot.#-------------------------------------------------## Project created by QtCreator
2017-01-18 09:11:55 636
原创 C++ Qt Game Tutorial 2 - Moving With the Arrow Keys
移动矩形,在第一个例子基础上,建立一个矩形类,实现keyPressEvent方法。空格键的地方写了一个子弹(bullet), 里面有一个定时器,不停地向上移动, 利用到了qt 的一个很重要的特性,signal and slot.#-------------------------------------------------## Project created by QtCreator
2017-01-17 21:43:54 529
原创 C++ Qt Game Tutorial 1 - Drawing the Player (rectangle)
一看代码就不用多做什么解释,新建一个举行,将它显示在window小窗口上,需要弄清楚三个概念, QGraphicsScene, QGraphicsRectItem, QGraphicsView三个类各起到什么作用。#include #include #include #include /*Prereqs:-basic knowledge of c++ (pointers an
2017-01-17 21:13:26 576
转载 OpenGL,glut,glew,glfw,mesa等
一、OpenGLOpenGL函数库相关的API有核心库(gl),实用库(glu),辅助库(aux)、实用工具库(glut),窗口库(glx、agl、wgl)和扩展函数库等。gl是核心,glu是对gl的部分封装。glx、agl、wgl 是针对不同窗口系统的函数。glut是为跨平台的OpenGL程序的工具包,比aux功能强大(aux很大程度上已经被glut库取代。)。扩展函数库是硬件厂商为
2017-01-17 15:40:15 1189
原创 QT5提示can not find -lGL的解决方法
这是由于 Qt5.0 默认将OpenGL加入了工程,但是在机器上没有安装OpenGL,所以jonas只需要在机器上安装OpenGL即可 。安装建立基本编译环境首先不可或缺的,就是编译器与基本的函式库,如果系统没有安装的话,请依照下面的方式安装:$ sudo apt-get install build-essential 安装OpenGL Library接
2017-01-17 02:39:27 775
原创 qt 可开关的toggle按钮
在写一个dialog的时候,想实现一个效果,按点击按钮,如果此时是false,则下一次就为true,即true和false参数轮流切换。需要实现这个目标,可以在dialog中定义一个isTrue私有成员变量,每次对其取非实现。即 isTrue = !isTrue;也可以将checkable选项勾选,完成上面的功能,connect(moreButton, SIGNAL(toggled
2017-01-13 11:07:50 8081
原创 qt 利用QSortFilterProxyModel写一个address book程序
源码在http://doc.qt.io/qt-5/qtwidgets-itemviews-addressbook-example.html显示效果:
2017-01-11 21:10:23 551
原创 qt 利用qml编写控制程序
TEMPLATE = appQT += qml quickCONFIG += c++11SOURCES += main.cppRESOURCES += qml.qrc# Additional import path used to resolve QML modules in Qt Creator's code modelQML_IMPORT_PATH =# Default
2017-01-10 14:48:16 1107
原创 qt 一个简单的表格程序
#-------------------------------------------------## Project created by QtCreator 2017-01-10T10:36:15##-------------------------------------------------QT += core guigreaterThan(QT_MAJOR
2017-01-10 10:59:52 4997
原创 qt打开和编辑文件
Opening FilesIn this section, we implement the functionality of the on_actionOpen_triggered() slot. The first step is asking the user for the name of the file to open. Qt comes withQFileDialog, wh
2017-01-09 17:05:38 1757
翻译 在qt中使用opengl绘制图形动画
可以使用Qt OpenGL模块的功能实现图形的绘制,实现3d动画效果,以下例子介绍如何使用Qt OpenGL相关功能。1. 2D图像绘制:该示例使用QPainter和QGLWidget展示一个动态的加速的二维图形。2.
2017-01-06 14:20:31 2228
原创 qt 井字游戏编写
画一个3*3的方格,轮流下棋,哪方先到横竖斜三个连在一起就为胜,其余为和。此游戏可以将棋盘扩大成为五子棋,有兴趣的朋友可以试试。
2017-01-06 10:04:28 1565
原创 Computer Graphic with opengl第一个例子
在窗口上画一条线#include // (or others, depending on the system in use)void init (void){glClearColor (1.0, 1.0, 1.0, 0.0);// Set display-window color to white.glMatrixMode (GL_PROJECTION);//
2017-01-03 11:35:22 696
原创 opengl superbible第一个程序
渲染生成一个蓝色背景的窗口#include void RenderScene(void){ glClear(GL_COLOR_BUFFER_BIT); glFlush();}void SetupRC(void){ glClearColor(0.0f, 1.0f, 1.0f, 1.0f);}int main(int argc, char *argv[]
2017-01-03 10:49:17 600
原创 Qt load image
qt load image1. set up a Qt widget Application2. next, add the QPainter class header to mainwindow.h#include 3. After that, declare the paintEvent() virtual function like tovirtual void pain
2017-01-02 10:35:53 1646
原创 decltype c++11
Sometimes we want to define a variable with a type that the compiler deduces from a expression but do not want to use that expression to initialize the variable. For such cases, the new standard intro
2017-01-01 14:00:27 342
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人