OpenGL -- 位图 glBitmap
来源:互联网 发布:mysql w10 编辑:程序博客网 时间:2024/06/16 10:22
直接代码和结果
代码
#include <gl\glut.h> #include <gl\GLU.h>#include <gl\GL.h>#include <math.h>#include <windows.h>#include <stdio.h>#include <stdlib.h>#define PI 3.1415926 int WinWidth, WinHeight;void Draw(){ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glColor3f(1.0f, 0.0f, 0.0f); // 一个向上的箭头 GLubyte bitShape[20] = { 0x1c, 0x00, 0x1c, 0x00, 0x1c, 0x00, 0x1c, 0x00, 0x1c, 0x00, 0xff, 0x80, 0x7f, 0x00, 0x3e, 0x00, 0x1c, 0x00, 0x08, 0x00 }; glPixelStorei(GL_UNPACK_ALIGNMENT,1); glRasterPos2i(100, 100); glBitmap(9, 10, 0.0, 0.0, 100, 100, bitShape); glutSwapBuffers();}void Reshape(int w, int h){ WinWidth = w; WinHeight = h; // //改变显示区域,起始位置为客户端窗口左下角(非坐标原点) glViewport(0, 0, w, h); glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho(0, w, 0, h, -1.0, 1.0); glMatrixMode(GL_MODELVIEW);}int main(int argc, char *argv[]){ WinWidth = 400; WinHeight = 400; glutInit(&argc, argv); glutInitDisplayMode(GLUT_DEPTH | GLUT_RGB | GLUT_DOUBLE); //glutInitWindowPosition(100, 100); glutInitWindowSize(WinWidth, WinHeight); glutCreateWindow("HelloOpenGL"); /* 目的:当窗口尺寸改变时,图形比例不发生变化 思路:窗口宽高比改变时,通过改变窗口显示区域大小,并利用投影矩阵改变观测物体大小使之适应变化。 */ glutReshapeFunc(&Reshape); glutDisplayFunc(&Draw); glutMainLoop(); return 0;}
截图
参考
《计算机图形学》(第四版)Page 58.
http://www.cnblogs.com/tekkaman/p/3918245.html
OpenGL 位图和图像概念
http://www.cnblogs.com/wendao/archive/2011/12/23/ogl_bitmap_image_learning.html
位图是由1和0组成的矩形数组,作为窗口中一个矩形区域的绘图掩码。 假设我们正在绘制一副位图,并且当前的光栅颜色是红色。在位图中为1的地方,帧缓冲区中的对应像素就用红色像素(或者根据实际生效的片段操作,与红色像素进行混合)代替。对于位图中为0的地方,就不会生成片段,像素的内容不受影响。位图的最常见用途就是在屏幕上绘制字符。
0 0
- OpenGL: glBitmap光栅位图
- OpenGL -- 位图 glBitmap
- 使用位图(glBitmap)在OpenGL中输出中文
- 《高效学习OpenGL》 之 位图与字体 glRasterPos(), glWindowPos(), glBitmap()
- 由glBitmap想到OpenGL编程涉及的坐标系
- 由glBitmap想到OpenGL编程涉及的坐标系
- opengl位图
- OpenGL--位图
- OpenGL位图和图像
- OpenGL:位图与图像
- opengl创建位图文字
- OpenGL位图操作
- OpenGL: 位图字体
- 位图、图像(openGL)
- 14.OpenGL--位图
- android opengl es 位图字体
- OpenGL的位图和图像
- OpenGL中位图的操作
- 【软考总结】网络安全
- Redis编程实践【pipeline和事务】
- bzoj1003: [ZJOI2006]物流运输
- Android Context完全解析,你所不知道的Context的各种细节
- 《奇异博士》+片尾两彩蛋
- OpenGL -- 位图 glBitmap
- Linux 进程和网络端口相关命令
- UDP 多播服务模型
- 【排序】直接插入
- Android中图片的裁剪和徐徐展开控件ClipDrawable
- [Android开发]从Android官方Demo谈RecyclerView的用法
- jQuery select下拉选框操作小结
- Javascript基础——利用定时器实现的图片无缝滚动(offsetLeft)
- 本地套接字domain通信