---------------------------------------------------------------------------------------------------
学习: http://www.blogjava.net/youxia/archive/2006/12/09/86513.html
---------------------------------------------------------------------------------------------------
1. 下载并安装OpenGL插件:
下载地址: http://www.eclipse.org/swt/opengl/
2. 给本项目添加依赖:
双击 plugin.xml 打开编辑窗口,选择 "Dependencies" 选项卡, 点击 "Required Plug-ins" 下的 "Add...",输入 "org.eclipse.opengl" , 如下图:
回到前一界面,可在项目的 "Plug-in Dependencies" 下发现加入了 ogl.jar, 如下图:
3. 新建视图 OpenGLView:
package hellorcp.opengl;
import org.eclipse.opengl.GL;
import org.eclipse.opengl.GLU;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.ControlAdapter;
import org.eclipse.swt.events.ControlEvent;
import org.eclipse.swt.events.DisposeEvent;
import org.eclipse.swt.events.DisposeListener;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.opengl.GLCanvas;
import org.eclipse.swt.opengl.GLData;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.part.ViewPart;
public class OpenGLView extends ViewPart {
GLCanvas canvas;
@Override
public void createPartControl(Composite parent) {
GLData data = new GLData();
data.depthSize = 1;
data.doubleBuffer = true;
canvas = new GLCanvas(parent, SWT.NO_BACKGROUND, data);
canvas.addControlListener(new ControlAdapter() {
public void controlResized(ControlEvent e) {
Rectangle rect = canvas.getClientArea();
GL.glViewport(0, 0, rect.width, rect.height);
// 选择投影矩阵
GL.glMatrixMode(GL.GL_PROJECTION);
// 重置投影矩阵
GL.glLoadIdentity();
// 设置窗口比例和透视图
GLU.gluPerspective(45.0f, (float) rect.width
/ (float) rect.height, 0.1f, 100.0f);
// 选择模型观察矩阵
GL.glMatrixMode(GL.GL_MODELVIEW);
// 重置模型观察矩阵
GL.glLoadIdentity();
// 黑色背景
GL.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
// 设置深度缓存
GL.glClearDepth(1.0f);
// 启动深度测试
GL.glEnable(GL.GL_DEPTH_TEST);
// 选择深度测试类型
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 自动生成方法存根
}
}
4. 修改 Perspective.java 为:
package hellorcp;
import org.eclipse.ui.IPageLayout;
import org.eclipse.ui.IPerspectiveFactory;
public class Perspective implements IPerspectiveFactory {
public void createInitialLayout(IPageLayout layout) {
// FirstView
String editorArea = layout.getEditorArea();
// layout.addView("hellorcp.view.FirstView", IPageLayout.RIGHT, 0.2f,
// editorArea);
// SecondView
// layout.setEditorAreaVisible(false);
// layout.addView("hellorcp.view.SecondView", IPageLayout.RIGHT, 0.5f,
// editorArea);
// OleView
// layout.addView("hellorcp.ole.OleView", IPageLayout.RIGHT, 0.5f,
// editorArea);
// CanvasView
// layout.addView("hellorcp.canvas.CanvasView", IPageLayout.RIGHT, 0.5f,
// editorArea);
// OpenGLView
layout.addView("hellorcp.opengl.OpenGLView", IPageLayout.RIGHT, 0.5f,
editorArea);
}
}
5. 在 plugin.xml 中配置view:
<view
class="hellorcp.opengl.OpenGLView"
id="hellorcp.opengl.OpenGLView"
name="OpenGL" />
6. 保存,运行,效果如下:
- 大小: 39.3 KB
- 大小: 71.1 KB
- 大小: 13.9 KB
分享到:
相关推荐
eclipse rcp 插件开发学习笔记.pdf 15-24章
eclipse rcp 插件开发学习笔记.pdf 1-14章
Eclipse RCP允许开发者使用eclipse结构风格设计弹性的可扩展的应用程序,可重用Eclipse中已存在的方法和编码模式。俗话说,万事开头难。Eclipse RCP入手可能会比较困难、费时。接下来我们将主要讲述如何让RCP工作. ...
1.2 ECLIPSE RCP 建设风格——插件,扩展和扩展点 ..................................................................... 9 1.3 RCP与PLUGIN ....................................................................
Eclipse RCP开发教程,RCP入门教程,教你如何使用SWT Eclipse RCP开发教程,RCP入门教程,教你如何使用SWT Eclipse RCP开发教程,RCP入门教程,教你如何使用SWT Eclipse RCP开发教程,RCP入门教程,教你如何使用SWT
一个 Eclipse RCP 的入门教程
Eclipse RCP 开发资料打包下载 目录如下: RCP程序设计.pdf(推荐) Addison.Wesley.Eclipse.Rich.Client.Platform.Designing.Coding.and.Packaging.Java.Applications.Oct.2005.chm Eclipse+RCP入门.pdf example_...
ECLIPSE RCP应用系统开发方法与实战.pdf ECLIPSE RCP应用系统开发方法与实战.pdf
网络中最全面最合适学习或开发...包含eclipse rcp开发入门教程; eclipse rcp基础教程;eclipse rcp开发自学教程; eclipse rcp开发培训教程及ppt等相关资料;教程中包含一步步操作实例,包含对开发原理的讲解与说明;
通过例子学习EclipseRCP开发通过例子学习EclipseRCP开发
[Eclipse.RCP深入浅出].Jeff.McAffer等.扫描版.pdf 还有其他两本在我的资源分享页面.
eclipse rcp应用系统开发方法与实战源代码.zip
Eclipse RCP入门,初级的RCP开发介绍。
rcp org.eclipse.ui.newWizards扩展点例子,模仿新建java项目
最近抽些时间,更新到eclipse3.6上来,既作为为广大Eclipser入门plugin/RCP开发的一个方便之门,也是对自己近年来学习的一个总结吧。 每一章都会单独提取出来,并尽可能的独立于其他章节,更新中的源代码工程也会...
eclipse RCP Plug-in开发自学教程 , 只要java基础好,自学没问题的。。。
org.eclipse.equinox.p2.examples.rcp.cloud.rarorg.eclipse.equinox.p2.examples.rcp.cloud.rarorg.eclipse.equinox.p2.examples.rcp.cloud.rar
Eclipse IDE for RCP and RAP Developers(eclipse-rcp-2022-06-R-linux-gtk-x86_64.tar.gz) 适用于Linux x86_64: A complete set of tools for developers who want to create Eclipse plug-ins, Rich Client ...
《Eclipse RCP深入浅出》内容简介:Eclipse不只是一个单纯的流行IDE,其Rich Client Platform(RCP)插件几乎是所有桌面应用程序的坚实基础,从聊天应用程序到前端的企业级应用程序,不一而足。《Eclipse RCP深入浅...
EclipseRCP系统开发与实战(书).rar,pdf格式,下了不后悔