OpenGL 太阳系行星拾取例子(GL_SELECT) VS2008 + glut实现
太阳系:Solar System
以太阳(Sun)为中心,由内到外分别是:
水星(Mercury)
金星(Venus)
地球(Earth)
火星(Mars)
木星(Jupiter)
土星(Saturn)
天王星(Uranus)
海王星(Neptune)
冥王星(Pluto)
原来是太阳系九大行星,但是最后一个冥王星被除名,就变成八大行星了~
1
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 |
//#include <windows.h>
#include <afx.h> #include <gl/gl.h> #include <gl/glu.h> #include <gl/glut.h> #include <math.h> #pragma comment(linker, "/subsystem:\"windows\" /entry:\"mainCRTStartup\"") #define glRGB(x, y, z) glColor3ub((GLubyte)x, (GLubyte)y, (GLubyte)z) // 太阳 GLfloat fAspect; // Called to draw scene // Save the matrix state and do the rotations // Translate the whole scene out and into view // Initialize the names stack // Set material color, Yellow // Draw Mercury // Draw Venus // Draw the Earth // Draw Mars // Draw Jupiter // Draw Saturn // Draw Uranus // Draw Neptune // Draw Pluto // Restore the matrix state void Display(void) // Present the information on which planet/sun was selected and displayed case MERCURY: case VENUS: case EARTH: case MARS: case JUPITER: case SATURN: case URANUS: case NEPTUNE: case PLUTO: default: // Process the selection, which is triggered by a right mouse void ProcessSelection(int xPos, int yPos) // Hit counter and viewport storeage // Setup selection buffer // Get the viewport // Switch to projection and save the matrix // Change render mode // Establish new clipping volume to be unit cube around // Apply perspective matrix // Draw the scene // Collect the hits // If a single hit occured, display the info. ; i < hits ; i++) // Restore the projection matrix // Go back to modelview for normal rendering void init(void) // Process the mouse click void ChangeSize(int w, int h) // Set Viewport to window dimensions // Calculate aspect ratio of the window // Set the perspective coordinate system // Field of view of 45 degrees, near and far planes 1.0 and 425 // Modelview matrix reset int main(int argc, char *argv[]) glutMainLoop(); ; |
OpenGL 太阳系行星拾取例子(GL_SELECT) VS2008 + glut实现的更多相关文章
- Modern OpenGL用Shader拾取VBO内单一图元的思路和实现
Modern OpenGL用Shader拾取VBO内单一图元的思路和实现 什么意思? 拾取 最简单的理解拾取的方式大概是到(http://www.yakergong.net/nehe/course/t ...
- Modern OpenGL用Shader拾取VBO内单一图元的思路和实现(3)
Modern OpenGL用Shader拾取VBO内单一图元的思路和实现(3) 到上一篇为止,拾取一个VBO里的单个图元的问题已经彻底解决了.那么来看下一个问题:一个场景里可能会有多个VBO,此时每个 ...
- 使用css3的动画模拟太阳系行星公转
本文介绍使用css3的animation画一个太阳系行星公转的动画,再加以改进,讨论如何画椭圆的运行轨迹.然后分析京东和人人网使用animation的实际案例,最后结合css3的clip-path做一 ...
- OpenGL中的拾取模式( Picking)
1. Opengl中的渲染模式有三种:(1)渲染模式,默认的模式:(2)选择模式, (3)反馈模式.如下 GLint glRenderMode(GLenum mode) mode可以选取以下三种模式之 ...
- html+ccs3太阳系行星运转动画之土星有个环,地球有颗小卫星
在上一篇<html+ccs3太阳系行星运转动画>中实现了太阳系八大行星的基本运转动画. 太阳系又何止这些内容,为丰富一下动画,接下来增加“土星环”和“月球”来充盈太阳系动画. 下面是充盈后 ...
- Modern OpenGL用Shader拾取VBO内单一图元的思路和实现(2)
Modern OpenGL用Shader拾取VBO内单一图元的思路和实现(2) 上一篇里介绍了Color-Coded Picking的思路和最基本的实现.在处理GL_POINTS时已经没有问题,但是处 ...
- three.js模拟实现太阳系行星体系
概况如下: 1.SphereGeometry实现自转的太阳: 2.RingGeometry实现太阳系星系的公转轨道: 3.ImageUtils加载球体和各行星贴图: 4.canvas中createRa ...
- html+ccs3太阳系行星运转动画
做一个太阳系八大行星的运转动画,不包括行星的卫星,所有行星围绕太阳公转,行星采用纯色,暂时没有自转. 效果静态图: 动画中包括:太阳及各行星,运行轨道,行星公转动画. 先画好草图,设计好大小和位置,根 ...
- OpenGL红宝书例子2.2 uniform变量的使用
1. 简单介绍一下OpenGL可编程渲染管线的流程 顶点着色 --> 细分着色 --> 几何着色 --> 片元着色 --> 计算着色 一般我们主要参与的阶段是顶点着色和片元着色 ...
随机推荐
- 移动端html页面优化
对于访问量大的网站来说,前端的优化是必须的,即使是优化1KB的大小对其影响也很大,下面来看看来自ISUX的米随随讲讲移动手机平台的HTML5前端优化,或许对你有帮助和启发. 概述 1. PC优化手段在 ...
- cached-query 将缓存和查询数据库高速连接起来的轻类库
介绍 我们经常有这种需求:当我们把memcached增加到项目后我还还要写一个 cacheUtils 或者 cacheManager 之类的类来操作memcached. 而且一般的操作不外乎是这种操作 ...
- c++对象工厂
一.简单工厂 #pragma once struct IObjectA { virtual void Test1()=0; }; class ObjectA:public IObjectA { p ...
- git存储用户名与密码
git config credential.helper store git config --global credential.helper cache ... which tells git t ...
- Kubernetes中的亲和性与反亲和性
通常情况下,Pod分配到哪些Node是不需要管理员操心的,这个过程会由scheduler自动实现.但有时,我们需要指定一些调度的限制,例如某些应用应该跑在具有SSD存储的节点上,有些应用应该跑在同一个 ...
- Autonomous driving - Car detection YOLO
Andrew Ng deeplearning courese-4:Convolutional Neural Network Convolutional Neural Networks: Step by ...
- nodejs sass安装报错一招解决
背景: 这个问题不是一天两天了,有时候是网速不行,有时候是被墙了,有时候是github把node-sass的包转移目录导致下载失败. Cannot download "https://git ...
- Spark实现K-Means算法
K-Means算法是一种基于距离的聚类算法,采用迭代的方法,计算出K个聚类中心,把若干个点聚成K类. MLlib实现K-Means算法的原理是,运行多个K-Means算法,每个称为run,返回最好的那 ...
- 使用Guava的ComparisonChain实现自定义的排序
可以看到使用比较器前,先要写一个实体类,还要实现comparable接口,实现compareTo方法.这个方法一般会返回-1 0 1三个int类型数字,分别表示,对象和传入的对象比较,排序应该在传入的 ...
- Windows视频桌面壁纸实现(libvlc)(类似于wall paper engine效果)
简介 这个项目是很久之前的事情了,当时一个朋友正在研究一个国外的软件(wall paper engine ),可以在桌面壁纸层播放视频,也就差不多是动态壁纸的意思. 后来我也动手来实现这个功能,因为手 ...