使用Eclipse RCP进行桌面程序开发(六):向OpenGL进军 - 编程入门网
作者 佚名技术
来源 NET编程
浏览
发布时间 2012-06-17
//僉夲侮業霞編窃侏 GL.glDepthFunc(GL.GL_LESS); //尼喘咐唹峠錆 GL.glShadeModel(GL.GL_SMOOTH); //娼聾俐屎邑篇夕 GL.glHint(GL.GL_PERSPECTIVE_CORRECTION_HINT, GL.GL_NICEST); //賠茅徳鳥才侮業産贋 GL.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); //嶷崔輝念議庁侏鉱賀裳專 GL.glLoadIdentity(); } }); canvas.addDisposeListener(new DisposeListener() { public void widgetDisposed(DisposeEvent e) { dispose(); } }); /**//* */ Refresher rf = new Refresher(canvas); rf.run(); } @Override public void setFocus() { // TODO 徭強伏撹圭隈贋功 } } class Refresher implements Runnable { public static final int DELAY = 100; private GLCanvas canvas; private float rotate = 0.0f; public Refresher(GLCanvas canvas) { this.canvas = canvas; } public void run() { if (this.canvas != null && !this.canvas.isDisposed()) { if(!canvas.isCurrent()){ canvas.setCurrent(); } //宸戦耶紗OpenGL紙夕旗鷹 GL.glLoadIdentity(); GL.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); GL.glTranslatef(0, 4.5f, -11); //律汎y已廬軟栖 rotate += 0.5; GL.glRotatef(rotate, 0, 1.0f, 0); //距喘弓拷痕方?紙崙眉曹弑裳專 drawPyramid(0,0,0,4); canvas.swapBuffers(); this.canvas.getDisplay().timerExec(DELAY, this); } } public void drawPyramid(float x, float y, float z, int n){ if(n == 0)return; //鮫匯倖眉曹弑 GL.glBegin(GL.GL_TRIANGLES); //鮫嘘中 GL.glColor3f(1.0f,0.0f,0.0f); GL.glVertex3f( x, y, z); GL.glColor3f(0.0f,1.0f,0.0f); GL.glVertex3f(x+1.0f,y-1.63f,z-0.57f); GL.glColor3f(0.0f,0.0f,1.0f); GL.glVertex3f( x-1.0f,y-1.63f,z-0.57f); //鮫久中 GL.glColor3f(1.0f,0.0f,0.0f); GL.glVertex3f( x,y-1.63f,z+1.15f); GL.glColor3f(0.0f,1.0f,0.0f); GL.glVertex3f(x-1.0f,y-1.63f,z-0.57f); GL.glColor3f(0.0f,0.0f,1.0f); GL.glVertex3f( x+1.0f,y-1.63f,z-0.57f); //鮫恣迦中 GL.glColor3f(1.0f,0.0f,0.0f); GL.glVertex3f( x,y,z); GL.glColor3f(0.0f,1.0f,0.0f); GL.glVertex3f(x-1.0f,y-1.63f,z-0.57f); GL.glColor3f(0.0f,0.0f,1.0f); GL.glVertex3f( x,y-1.63f,z+1.15f); //鮫嘔迦中 GL.glColor3f(1.0f,0.0f,0.0f); GL.glVertex3f( x,y,z); |
凌众科技专业提供服务器租用、服务器托管、企业邮局、虚拟主机等服务,公司网站:http://www.lingzhong.cn 为了给广大客户了解更多的技术信息,本技术文章收集来源于网络,凌众科技尊重文章作者的版权,如果有涉及你的版权有必要删除你的文章,请和我们联系。以上信息与文章正文是不可分割的一部分,如果您要转载本文章,请保留以上信息,谢谢! |
你可能对下面的文章感兴趣
- Ubuntu中如何自定义菜单快捷键 HTTP/1.1 401 Access Denied
关于使用Eclipse RCP进行桌面程序开发(六):向OpenGL进军 - 编程入门网的所有评论