public void onSurfaceChanged(GL10 gl, int w, int h) { _width = w; _height = h; gl.glViewport(0, 0, w, h); }
public void onSurfaceCreated(GL10 gl, EGLConfig config) { gl.glMatrixMode(GL10_GL_PROJECTION); float size = .01f * (float)java.lang.Math.tan(java.lang.Math.toRadians(45.0) / 2); float ratio = _width / _height; // perspective: gl.glFrustumf(-size, size, -size / ratio, size / ratio, 0.01f, 100.0f); // orthographic: //gl.glOrthof(-1, 1, -1 / ratio, 1 / ratio, 0.01f, 100.0f); gl.glViewport(0, 0, (int)_width, (int)_height); gl.glMatrixMode(GL10_GL_MODELVIEW); gl.glEnable(GL10_GL_DEPTH_TEST); // define the color we want to be displayed as the "clipping wall" gl.glClearColor(0f, 0f, 0f, 1.0f); // enable the differentiation of which side may be visible gl.glEnable(GL10_GL_CULL_FACE); // which is the front? the one which is drawn counter clockwise gl.glFrontFace(GL10_GL_CCW); // which one should NOT be drawn gl.glCullFace(GL10_GL_BACK); gl.glEnableClientState(GL10_GL_VERTEX_ARRAY); gl.glEnableClientState(GL10_GL_COLOR_ARRAY); initTriangle(); }
private void Sync(bool pollEvents) { double dt = 1 / 60.0; double currentTime = GLFW.glfwGetTime(); // Main loop while (GLFW.glfwWindowShouldClose(Handle) == 0) { double newTime = GLFW.glfwGetTime(); double frameTime = newTime - currentTime; currentTime = newTime; while (frameTime > 0) { double deltaTime = Math.Min(frameTime, dt); frameTime -= deltaTime; for (var i = 0; i < blocks.Length; i++) { blocks[i].UseDelta = useDelta; blocks[i].Update(deltaTime, width, height); } } // Render a background and enable some stuff for 2d rendering with alpha GL10.glMatrixMode(GL11.GL_PROJECTION); GL10.glLoadIdentity(); GL10.glOrtho(0, width, height, 0, -1, 1); GL10.glMatrixMode(GL11.GL_MODELVIEW); GL10.glLoadIdentity(); GL10.glEnable(GL11.GL_BLEND); GL10.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL10.glViewport(0, 0, Width, Height); GL10.glClearColor(0, 0, 0, 1); GL10.glClear(GL11.GL_COLOR_BUFFER_BIT); // Render for (var i = 0; i < blocks.Length; i++) { blocks[i].Render(); } GLFW.glfwSwapBuffers(Handle); GLFW.glfwPollEvents(); } GLFW.glfwDestroyWindow(Handle); }
private void Sync(bool pollEvents) { // Main loop while (GLFW.glfwWindowShouldClose(Handle) == 0) { // Update // Render a background and enable some stuff for 2d rendering with alpha GL10.glEnable(GL11.GL_BLEND); GL10.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL10.glViewport(0, 0, Width, Height); GL10.glClearColor(0, 0, 0, 1); GL10.glClear(GL11.GL_COLOR_BUFFER_BIT); // Render GLFW.glfwSwapBuffers(Handle); GLFW.glfwPollEvents(); } GLFW.glfwDestroyWindow(Handle); }
public void onSurfaceChanged(GL10 gl, int w, int h) { gl.glViewport(0, 0, w, h); }
public virtual void onSurfaceChanged(GL10 gl, int width, int height) { gl.glViewport(0, 0, width, height); }