osg for android (一) 简单几何物体的加载与显示
- 1. 首先需要一个OSG for android的环境.
- (1).NDK 现在Eclipse 对NDK已经相当友好了,已经不需要另外cygwin的参与,具体可以参考
- Android NDK开发篇(一):新版NDK环境搭建(免Cygwin,超级快)
- (2).osg for android的编译,参考 osg for android学习之一:windows下编译(亲测通过) 建议编译OpenGL ES2版本.
- 2.然后加载OSG自带的Example:osgAndroidExampleGLES2
- (1)点击菜单键加载文件路径,输入/sdcard/osg/cow.osg(必须先往sdcard创建文件夹osg并把cow.osg放到该文件夹里边)

(2)接着经典的牛出现了:)

3.自带的example太多的代码,这样的代码无论对于NDK的初学者或OSG很不直观,所以本人重写了一个HelloWolrd for osg的例子。例子很简单,就是简单加载一个四边形并附上颜色。
(1)Java 代码:
package com.example.helloosg;
import android.app.Activity;
import android.opengl.GLSurfaceView;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.TextView; public class MainActivity extends Activity { private GLSurfaceView mGLSurfaceView; @Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mGLSurfaceView = new GLSurfaceView(this);
mGLSurfaceView.setEGLContextClientVersion();
NDKRenderer renderer = new NDKRenderer();
this.mGLSurfaceView.setRenderer(renderer);
this.setContentView(mGLSurfaceView);
} @Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
} @Override
protected void onResume() {
// TODO Auto-generated method stub
super.onResume();
mGLSurfaceView.onResume();
} @Override
protected void onPause() {
// TODO Auto-generated method stub
super.onPause();
mGLSurfaceView.onPause();
} @Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
}
osg for android (一) 简单几何物体的加载与显示的更多相关文章
- 携程Android App插件化和动态加载实践
携程Android App的插件化和动态加载框架已上线半年,经历了初期的探索和持续的打磨优化,新框架和工程配置经受住了生产实践的考验.本文将详细介绍Android平台插件式开发和动态加载技术的原理和实 ...
- 一个简单的AMD模块加载器
一个简单的AMD模块加载器 参考 https://github.com/JsAaron/NodeJs-Demo/tree/master/require PS Aaron大大的比我的完整 PS 这不是一 ...
- android中滑动SQLite数据库分页加载
今天用到了android中滑动SQlit数据库分页加载技术,写了个测试工程,将代码贴出来和大家交流一下: MainActivity package com.example.testscrollsqli ...
- iview简单使用+按需加载组件的方法(全局和局部)
1,简单使用 vue项目中使用iview非常简单: 首先安装依赖: $ npm install iview --save 会安装最新版本的依赖,安装完成后package.json会出现如下图配置 表示 ...
- 免插件,简单实现上拉加载loading
上拉加载是前端经常遇到的问题,采用插件往往能够轻松解决,这里介绍一种免插件简单实现上拉加载的方法,参考一下,下面分享一下代码. html <body> <ul> <li& ...
- 实现简单的 JS 模块加载器
实现简单的 JS 模块加载器 1. 背景介绍 按需加载是前端性能优化的一个重要手段,按需加载的本质是从远程服务器加载一段JS代码(这里主要讨论JS,CSS或者其他资源大同小异),该JS代码就是一个模块 ...
- android快捷开发之Retrofit网络加载框架的简单使用
大家都知道,安卓最大的特点就是开源化,这自然会产生很多十分好用的第三方API,而基本每一个APP都会与网络操作和缓存处理机制打交道,当然,你可以自己通过HttpUrlConnection再通过返回数据 ...
- android使用PullToRefresh实现上拉加载和下拉刷新效果
其实很早前就在博客园中也写过官方的下拉刷新控件SwipeRefreshLayout,但是这个控件仅仅支持下拉刷新,用起来还算可以.然而在我们实际开发应用中,很多地方都不止有下拉刷新,而且还有上拉加载的 ...
- Android之Socket通信、List加载更多、Spinner下拉列表
Android与服务器的通信方式主要有两种,一是Http通信,一是Socket通信.两者的最大差异在于,http连接使用的是“请求—响应方式”,即在请求时建立连接通道,当客户端向服务器发送请求后,服务 ...
随机推荐
- 转:7个鲜为人知却超实用的PHP函数
PHP have lots of built-in functions, and most developers know many of them. But a few functions are ...
- org.quartz.utils.UpdateChecker Checking for available updated version of Quartz..
<dependency> <groupId>org.quartz-scheduler</groupId> <artifactId>quartz</ ...
- go官网教程A Tour of Go
http://tour.golang.org/#1 中文版:http://go-tour-cn.appsp0t.com/#4 package main import ( "fmt" ...
- COJ 0650 绝世难题(一) 可爱的仙人掌
传送门:http://oj.cnuschool.org.cn/oj/home/problem.htm?problemID=620 绝世难题(一) 可爱的仙人掌 难度级别:E: 运行时间限制:1000m ...
- 透过Extjs学习JavaScript---闭包篇
目录 一.前言 二.基础讲解 三.知识应用 四.总结 五.常见问题 一.前言 JavaScript设计得最出色的就是它的函数的实现,它几乎接近于完美.我们现在现就来介绍它其中一个功能“闭包”.我们可以 ...
- Search a 2D Matrix ——LeetCode
Write an efficient algorithm that searches for a value in an m x n matrix. This matrix has the follo ...
- HDOJ 1020 Encoding
Problem Description Given a string containing only 'A' - 'Z', we could encode it using the following ...
- UVAlive3713 Astronauts(2-SAT)
题目链接:http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=18511 [思路] 2-SAT. 设分得A或B类任务为1 C类任务为 ...
- shell中条件判断if中的-z到-d的意思【转载】
本文转载自[http://blog.csdn.net/utstarm/article/details/6536916] [ -a FILE ] 如果 FILE 存在则为真. [ -b FILE ] ...
- 绘图(CGContext)
转自 http://blog.csdn.net/zhenyu5211314/article/details/24230581 0 CGContextRef context = UIGraphicsGe ...