OpenGL学习
来源:互联网 发布:临沂关键词优化 编辑:程序博客网 时间:2024/06/05 15:41
项目中要用到OpenGL,其实就是在Android中的实时添加滤镜GPUImage
问题来了,看源码会涉及到OpenGL ,如果不去了解一下,有点对不起作为一个开发人员,所以,本逗比,开始学习,后期遇到其他的问题,会一一列出来,就作为以后的备忘录;
1. 遇到一个很奇葩的问题,当调用GSurfaceView 的时候会出现空指针异常,后来发现原来必须调用这个方法
也就是gl.setRenderer(new GLSurfaceView.Renderer() {}
这个方法,重写他的三个方法如下:
gl.setRenderer(new GLSurfaceView.Renderer() { public void onSurfaceCreated(GL10 gl, EGLConfig config) { // Set the background color to black ( rgba ). gl.glClearColor(0.0f, 0.0f, 0.0f, 0.5f); // OpenGL docs. // Enable Smooth Shading, default not really needed. gl.glShadeModel(GL10.GL_SMOOTH);// OpenGL docs. // Depth buffer setup. gl.glClearDepthf(1.0f);// OpenGL docs. // Enables depth testing. gl.glEnable(GL10.GL_DEPTH_TEST);// OpenGL docs. // The type of depth testing to do. gl.glDepthFunc(GL10.GL_LEQUAL);// OpenGL docs. // Really nice perspective calculations. gl.glHint(GL10.GL_PERSPECTIVE_CORRECTION_HINT, // OpenGL docs. GL10.GL_NICEST); } public void onDrawFrame(GL10 gl) { // Clears the screen and depth buffer. gl.glClear(GL10.GL_COLOR_BUFFER_BIT | // OpenGL docs. GL10.GL_DEPTH_BUFFER_BIT); } public void onSurfaceChanged(GL10 gl, int width, int height) { // Sets the current view port to the new size. gl.glViewport(0, 0, width, height);// OpenGL docs. // Select the projection matrix gl.glMatrixMode(GL10.GL_PROJECTION);// OpenGL docs. // Reset the projection matrix gl.glLoadIdentity();// OpenGL docs. // Calculate the aspect ratio of the window GLU.gluPerspective(gl, 45.0f, (float) width / (float) height, 0.1f, 100.0f); // Select the modelview matrix gl.glMatrixMode(GL10.GL_MODELVIEW);// OpenGL docs. // Reset the modelview matrix gl.glLoadIdentity();// OpenGL docs. }});
阅读全文
0 0
- 学习OPENGL
- OpenGL学习
- opengl 学习
- openGL学习
- openGL学习
- [OpenGL学习]
- OpenGL学习
- OpenGL学习
- openGL学习
- OpenGL学习
- OpenGL 学习
- OpenGL学习
- opengl学习
- OpenGL 学习
- Opengl学习
- OPENGL学习
- opengl学习
- 学习OpenGL
- 远程桌面连接的技巧
- 【kotlin从入门到深坑】之语句
- 刘轩-如何增强自己的演说能力
- c语言基础总结
- 刘轩-我们为什么无法专心?
- OpenGL学习
- 动态规划:Super Washing Machines
- 二分贪心总结
- 4864: [BeiJing 2017 Wc]神秘物质
- ARM 架构和X86架构
- 刘轩-不要让我们的身体骗了我们
- git-osc-android客户端之源码分析1
- Unity场景加载与进度条
- ActiveMQ(二):ActiveMQ的简单入门