12 2011 档案
摘要:init/main.c首先我们贴上main.c中main函数的代码void main(void) /* This really IS void, no error here. */{ /* The startup routine assumes (well, ...) this *//* * Interrupts are still disabled. Do necessary setups, then * enable them */ ROOT_DEV = ORIG_ROOT_DEV; drive_info = DRIVE_INFO; ...
阅读全文
摘要:用法:初始化后,在需要绑定的地方,比如onDrawFrame里边调用Texture.bind()函数。public class Texture { private String fileName; private AssetManager asset; private GL10 gl; private int minFilter; private int magFilter; private int textureId; public Texture(GL10 gl, AssetManager asset, String fil...
阅读全文
摘要:1 public class MyRenderer implements Renderer 2 { 3 FloatBuffer verticesBuffer; 4 private final int VERTEX_SIZE = (2 + 2) * 4; 5 private AssetManager asset; 6 private int textureID; 7 8 public MyRenderer(Context context) 9 {10 asset = context.getAssets();11 ...
阅读全文
摘要:public class MyRenderer implements Renderer { FloatBuffer verticesBuffer; private final int VERTEX_SIZE = (2 + 4) * 4; @Override public void onDrawFrame(GL10 gl) { gl.glViewport(0, 0, 320, 480); gl.glClear(GL10.GL_COLOR_BUFFER_BIT); gl.glMatrixMode(GL10.GL_PROJEC...
阅读全文
摘要:1 public class MyRenderer implements Renderer 2 { 3 FloatBuffer verticesBuffer; 4 5 @Override 6 public void onDrawFrame(GL10 gl) 7 { 8 gl.glViewport(0, 0, 320, 480); 9 gl.glClear(GL10.GL_COLOR_BUFFER_BIT);10 gl.glMatrixMode(GL10.GL_PROJECTION);11 g...
阅读全文
摘要:下期预告:Android的OpenGL ES版的碰到边界返回的方块#include <GL/glut.h>// 方块的初始位置和大小GLfloat x1 = 0.0f;GLfloat y1 = 0.0f;GLfloat rsize = 25;// 在x和y方向上的步进大小GLfloat xstep = 1.0f;GLfloat ystep = 1.0f;// 追踪窗口的宽度和高度的变化GLfloat windowWidth;GLfloat windowHeight;void ChangeSize(GLsizei w, GLsizei h){ GLfloat aspectRatio;
阅读全文
摘要:// 利用ChangeSize函数在屏幕形状发生改变时重建viewport并且重新设置坐标系#include <GL/glut.h>#define WINDOW_WIDTH 640#define WINDOW_HEIGHT 480void ChangeSize(GLsizei w, GLsizei h){ GLfloat aspectRatio; // 防止被0除 if(h == 0) { h = 1; } glViewport(0, 0, w, h); // 重置坐标系统 glMatrixMode(GL_PROJECTION);...
阅读全文
摘要:首先我们在屏幕中心显示一个矩形,效果如图:// 代码没有经过优化,为的是容易理解public class OpenGLTestActivity extends Activity { GLSurfaceView glView; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE); getWindow(...
阅读全文
摘要:接下来的代码效果如图:// 我们定义了一个200X200的窗口// 设置视口为整个窗口// 横坐标范围为-100到100// 纵坐标范围为-100到100// 所以一个left, top, right, bottom为-50.0f, 50.0f, 50.0f, -50.0f的矩形应该在屏幕中间// 程序运行结果正如预期#include <GL/gl.h>#include <GL/glut.h>void RenderScene(){ glClear(GL_COLOR_BUFFER_BIT); glColor3f(1.0f, 0.0f, 0.0f); glRectf(-50
阅读全文