本文整理汇总了Java中android.opengl.GLSurfaceView类的典型用法代码示例。如果您正苦于以下问题:Java GLSurfaceView类的具体用法?Java GLSurfaceView怎么用?Java GLSurfaceView使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
GLSurfaceView类属于android.opengl包,在下文中一共展示了GLSurfaceView类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: init
import android.opengl.GLSurfaceView; //导入依赖的package包/类
/**
* Initialize method.
*/
private void init() {
super.setEGLConfigChooser(8, 8, 8, 8, 16, 0);
/**
* @ TODO in baraye Transparent shodane safhast ke felan commentesh
* kardam dar nahayat bayad commente in ro bardaram
*/
// getHolder().setFormat(PixelFormat.TRANSLUCENT);
// setZOrderOnTop(true);
setZOrderOnTop(true);
getHolder().setFormat(PixelFormat.RGBA_8888);
// setZOrderMediaOverlay(true);
mRenderer = new CurlRenderer(this);
setRenderer(mRenderer);
setRenderMode(GLSurfaceView.RENDERMODE_WHEN_DIRTY);
setOnTouchListener(this);
mPageCurl = new CurlMesh();
stack = new CurlStack(MaxStackItem);
}
示例2: CameraGLSurfaceView
import android.opengl.GLSurfaceView; //导入依赖的package包/类
public CameraGLSurfaceView(Context context, AttributeSet attrs) {
super(context, attrs);
TypedArray styledAttrs = getContext().obtainStyledAttributes(attrs, R.styleable.CameraBridgeViewBase);
int cameraIndex = styledAttrs.getInt(R.styleable.CameraBridgeViewBase_camera_id, -1);
styledAttrs.recycle();
if(android.os.Build.VERSION.SDK_INT >= 21)
mRenderer = new Camera2Renderer(this);
else
mRenderer = new CameraRenderer(this);
setCameraIndex(cameraIndex);
setEGLContextClientVersion(2);
setRenderer(mRenderer);
setRenderMode(GLSurfaceView.RENDERMODE_WHEN_DIRTY);
}
示例3: init
import android.opengl.GLSurfaceView; //导入依赖的package包/类
private void init() {
// Create full scene quad buffer
final byte FULL_QUAD_COORDS[] = {-1, 1, -1, -1, 1, 1, 1, -1};
mFullQuadVertices = ByteBuffer.allocateDirect(4 * 2);
mFullQuadVertices.put(FULL_QUAD_COORDS).position(0);
setEGLContextFactory(new MyContextFactory(this));
setPreserveEGLContextOnPause(true);
setEGLContextClientVersion(2);
setRenderer(this);
setRenderMode(GLSurfaceView.RENDERMODE_WHEN_DIRTY);
setDebugFlags(DEBUG_LOG_GL_CALLS);
}
示例4: onCreate
import android.opengl.GLSurfaceView; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
if (!Utils.supportGlEs20(this)) {
Toast.makeText(this, "GLES 2.0 not supported!", Toast.LENGTH_LONG).show();
finish();
return;
}
mGLSurfaceView = (GLSurfaceView) findViewById(R.id.surface);
mGLSurfaceView.setEGLContextClientVersion(2);
mRenderer = new DemoRenderer(this);
mGLSurfaceView.setEGLConfigChooser(8, 8, 8, 8, 16, 0);
mGLSurfaceView.setRenderer(mRenderer);
mGLSurfaceView.setRenderMode(GLSurfaceView.RENDERMODE_CONTINUOUSLY);
}
示例5: MagicDisplay
import android.opengl.GLSurfaceView; //导入依赖的package包/类
public MagicDisplay(Context context, GLSurfaceView glSurfaceView){
mContext = context;
mGLSurfaceView = glSurfaceView;
mFilters = MagicFilterFactory.getFilters(MagicFilterType.NONE, context);
mFilterAdjust = new MagicFilterAdjuster(mFilters);
mGLCubeBuffer = ByteBuffer.allocateDirect(TextureRotationUtil.CUBE.length * 4)
.order(ByteOrder.nativeOrder())
.asFloatBuffer();
mGLCubeBuffer.put(TextureRotationUtil.CUBE).position(0);
mGLTextureBuffer = ByteBuffer.allocateDirect(TextureRotationUtil.TEXTURE_NO_ROTATION.length * 4)
.order(ByteOrder.nativeOrder())
.asFloatBuffer();
mGLTextureBuffer.put(TextureRotationUtil.TEXTURE_NO_ROTATION).position(0);
mGLSurfaceView.setEGLContextClientVersion(2);
mGLSurfaceView.setRenderer(this);
mGLSurfaceView.setRenderMode(GLSurfaceView.RENDERMODE_WHEN_DIRTY);
}
示例6: CameraView
import android.opengl.GLSurfaceView; //导入依赖的package包/类
public CameraView(Context context, AttributeSet attrs) {
super(context, attrs);
TypedArray typedArray = null;
try {
typedArray = context.obtainStyledAttributes(attrs, R.styleable.CameraView);
mLayoutRatio = typedArray.getFloat(R.styleable.CameraView_layout_ratio, LAYOUT_RATIO_NONE);
} finally {
if (typedArray != null) {
typedArray.recycle();
}
}
mRenderer = new CameraRenderer(this);
setEGLContextClientVersion(2);
setRenderer(mRenderer);
setRenderMode(GLSurfaceView.RENDERMODE_WHEN_DIRTY);
}
示例7: VrShellImpl
import android.opengl.GLSurfaceView; //导入依赖的package包/类
@UsedByReflection("VrShellDelegate.java")
public VrShellImpl(Activity activity) {
super(activity);
mActivity = activity;
mContentViewCoreContainer = new FrameLayout(getContext()) {
@Override
public boolean dispatchTouchEvent(MotionEvent event) {
return true;
}
};
addView(mContentViewCoreContainer, 0, new FrameLayout.LayoutParams(
FrameLayout.LayoutParams.MATCH_PARENT,
FrameLayout.LayoutParams.MATCH_PARENT));
mGlSurfaceView = new GLSurfaceView(getContext());
mGlSurfaceView.setEGLContextClientVersion(2);
mGlSurfaceView.setEGLConfigChooser(8, 8, 8, 8, 0, 0);
mGlSurfaceView.setPreserveEGLContextOnPause(true);
mGlSurfaceView.setRenderer(this);
setPresentationView(mGlSurfaceView);
if (setAsyncReprojectionEnabled(true)) {
AndroidCompat.setSustainedPerformanceMode(mActivity, true);
}
}
示例8: onCreate
import android.opengl.GLSurfaceView; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mGLSurfaceView = new GLSurfaceView(this);
// Check if the system support OpenGL ES 2.0
final ActivityManager activityManager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
final ConfigurationInfo configurationInfo = activityManager.getDeviceConfigurationInfo();
final boolean supportsEs2 = configurationInfo.reqGlEsVersion >= 0x20000;
if (supportsEs2) {
// Request an OpenGL ES 2.0 compatible context.
mGLSurfaceView.setEGLContextClientVersion(2);
// Set the renderer to out demo renderer, define below
// mGLSurfaceView.setRenderer(new LessonThreeRenderer());
mGLSurfaceView.setRenderer(new NativeThreeRenderer());
} else {
// This is where you could create an OpenGL ES 1.x compatible
// renderer if you wanted to support both ES 1 and ES 2
return;
}
setContentView(mGLSurfaceView);
}
示例9: onCreate
import android.opengl.GLSurfaceView; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mGLSurfaceView = new GLSurfaceView(this);
// Check if the system support OpenGL ES 2.0
final ActivityManager activityManager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
final ConfigurationInfo configurationInfo = activityManager.getDeviceConfigurationInfo();
final boolean supportsEs2 = configurationInfo.reqGlEsVersion >= 0x20000;
if (supportsEs2) {
// Request an OpenGL ES 2.0 compatible context.
mGLSurfaceView.setEGLContextClientVersion(2);
// Set the renderer to out demo renderer, define below
// mGLSurfaceView.setRenderer(new LessonTwoRenderer());
mGLSurfaceView.setRenderer(new NativeTwoRenderer());
} else {
// This is where you could create an OpenGL ES 1.x compatible
// renderer if you wanted to support both ES 1 and ES 2
return;
}
setContentView(mGLSurfaceView);
}
示例10: onCreate
import android.opengl.GLSurfaceView; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mGLSurfaceView = new GLSurfaceView(this);
// Check if the system support OpenGL ES 2.0
final ActivityManager activityManager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
final ConfigurationInfo configurationInfo = activityManager.getDeviceConfigurationInfo();
final boolean supportsEs2 = configurationInfo.reqGlEsVersion >= 0x20000;
if (supportsEs2) {
// Request an OpenGL ES 2.0 compatible context.
mGLSurfaceView.setEGLContextClientVersion(2);
// Set the renderer to out demo renderer, define below
// mGLSurfaceView.setRenderer(new LessonOneRenderer());
// or set a native implementation
mGLSurfaceView.setRenderer(new NativeOneRenderer());
} else {
// This is where you could create an OpenGL ES 1.x compatible
// renderer if you wanted to support both ES 1 and ES 2
return;
}
setContentView(mGLSurfaceView);
}
示例11: onCreate
import android.opengl.GLSurfaceView; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mGLSurfaceView = new GLSurfaceView(this);
// Check if the system support OpenGL ES 2.0
final ActivityManager activityManager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
final ConfigurationInfo configurationInfo = activityManager.getDeviceConfigurationInfo();
final boolean supportsEs2 = configurationInfo.reqGlEsVersion >= 0x20000;
if (supportsEs2) {
// Request an OpenGL ES 2.0 compatible context.
mGLSurfaceView.setEGLContextClientVersion(2);
// Set the renderer to out demo renderer, define below
// mGLSurfaceView.setRenderer(new LessonFourRenderer(this));
mGLSurfaceView.setRenderer(new NativeFourRenderer(this));
} else {
// This is where you could create an OpenGL ES 1.x compatible
// renderer if you wanted to support both ES 1 and ES 2
return;
}
setContentView(mGLSurfaceView);
}
示例12: init
import android.opengl.GLSurfaceView; //导入依赖的package包/类
private void init() {
ViewTreeObserver observer = getViewTreeObserver();
if (observer != null) {
observer.addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {
@Override
public boolean onPreDraw() {
if (isDirty()) {
// 只在需要绘制的时候刷新
if (mRenderMode == GLSurfaceView.RENDERMODE_WHEN_DIRTY) {
invalidate();
}
}
return true;
}
});
}
}
示例13: init
import android.opengl.GLSurfaceView; //导入依赖的package包/类
/**
* Initialize method.
*/
private void init(Context ctx) {
mRenderer = new CurlRenderer(this);
setRenderer(mRenderer);
setRenderMode(GLSurfaceView.RENDERMODE_WHEN_DIRTY);
setOnTouchListener(this);
// Even though left and right pages are static we have to allocate room
// for curl on them too as we are switching meshes. Another way would be
// to swap texture ids only.
mPageLeft = new CurlMesh(10);
mPageRight = new CurlMesh(10);
mPageCurl = new CurlMesh(10);
mPageLeft.setFlipTexture(true);
mPageRight.setFlipTexture(false);
}
示例14: init
import android.opengl.GLSurfaceView; //导入依赖的package包/类
private void init() {
setEGLContextClientVersion(2);
setEGLConfigChooser(8, 8, 8, 8, 16, 0);
getHolder().setFormat(PixelFormat.RGBA_8888);
setRenderer(this);
setRenderMode(GLSurfaceView.RENDERMODE_WHEN_DIRTY);
float[] cube = OpenGLUtils.CUBE;
mCubeBuffer = ByteBuffer.allocateDirect(cube.length * 4).order(ByteOrder.nativeOrder()).asFloatBuffer();
mCubeBuffer.put(cube);
float[] textureCords = OpenGLUtils.getTextureCords(90, mCameraId == CameraInfo.CAMERA_FACING_FRONT, true);
mTextureBuffer = ByteBuffer.allocateDirect(textureCords.length * 4).order(ByteOrder.nativeOrder()).asFloatBuffer();
mTextureBuffer.put(textureCords);
List<CameraFilter> filters = new ArrayList<>();
filters.add(mCameraInputFilter);
filters.addAll(initFilters());
mCameraFilterGroup = new CameraFilterGroup(filters);
}
示例15: onCreate
import android.opengl.GLSurfaceView; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_opengl);
Log.d(TAG,"1->" + System.currentTimeMillis());
mGlSurfaceView = (GLSurfaceView) findViewById(R.id.surfaceView);
mGlSurfaceView.setEGLContextClientVersion(EGL_VERSION);
Log.d(TAG,"2->" + System.currentTimeMillis());
// mGlSurfaceView.setEGLContextClientVersion(2);
// mGlSurfaceView.setRenderer(new MyRender(new Square()));
// mGlSurfaceView.setRenderer(new MyRender(new Cube(1.0f,1.0f,1.0f)));
// mGlSurfaceView.setRenderer(new MyRender(new Texture(this)));
mGlSurfaceView.setRenderer(new Example6_3Renderer(this));
GLSurfaceView glSurfaceView = (GLSurfaceView) findViewById(R.id.surfaceView2);
glSurfaceView.setEGLContextClientVersion(EGL_VERSION);
glSurfaceView.setRenderer(new Example6_3Renderer(this));
Log.d(TAG,"6->" + System.currentTimeMillis());
}