opengl-es-2.0

iphone opengl es 2.0 custom build a gl view failed,but did not know why

自闭症网瘾萝莉.ら 提交于 2020-01-24 21:14:07
问题 I want to build a opengl es 2.0 view extend from UIview. And flow this article:http://www.raywenderlich.com/3664/opengl-es-2-0-for-iphone-tutorial when I finished first step. everything runs wrong. It did not run as I throught. Here is my code: #import <UIKit/UIKit.h> #import <QuartzCore/QuartzCore.h> #import <OpenGLES/ES2/gl.h> #import <OpenGLES/ES2/glext.h> @interface NXGLES2View : UIView - (void) render; @end #import "NXGLES2View.h" @interface NXGLES2View () { CAEAGLLayer *eaglLayer_;

2D opengl rotation causes sprite distortion

早过忘川 提交于 2020-01-24 15:55:07
问题 I am quite new to using OpenGL ES 2.0. Also im using an iPhone and the GLM maths library. As I reference I have been using this tutorial a lot: http://tomdalling.com/blog/modern-opengl/03-matrices-depth-buffering-animation/ But I have found it difficult to find a 2D OpenGL tutorial. I am trying to rotate a 2D sprite but the image is being distorted. For example at a rotation angle of 0 degrees: http://i.imgur.com/yBTN2ST.png and at a rotation angle of 45 degrees: http://i.imgur.com/cY5IJcg

Sprite quads & depth testing correctly in OpenGL ES 2

孤者浪人 提交于 2020-01-23 11:08:09
问题 I am trying to render 2D (flat) sprites in a 3D environment using OpenGL ES 2. The way I create each sprite is pretty standard: I create a quad consisting of two triangles, and I map the texture onto that. Everything works fine, except I noticed something strange: when depth testing is turned on (which it should be in 3D mode), the corners of my sprites are painted using the background color. The easiest way to show this is by illustration: When I turn off depth testing (on the left) it looks

OpenGL ES 2.0 texture not showing on some device

浪子不回头ぞ 提交于 2020-01-21 02:28:09
问题 I found a 3D graphics framework for Android called Rajawali and I am learning how to use it. I followed the most basic tutorial which is rendering a shpere object with a 1024x512 size jpg image for the texture. It worked fine on Galaxy Nexus, but it didn't work on the Galaxy Player GB70. When I say it didn't work, I mean that the object appears but the texture is not rendered. Eventually, I changed some parameters that I use for the Rajawali framework when creating textures and got it to work

Javascript and WebGL, external scripts

99封情书 提交于 2020-01-19 21:34:10
问题 Just curious; How do I place my webgl shaders, in an external file? Currently I'm having; <script id="shader-fs" type="x-shader/x-fragment"> #ifdef GL_ES precision highp float; #endif void main(void) { gl_FragColor = vec4(1.0, 1.0, 1.0, 1.0); } </script> <script id="shader-vs" type="x-shader/x-vertex"> attribute vec3 aVertexPosition; uniform mat4 uMVMatrix; uniform mat4 uPMatrix; void main(void) { gl_Position = uPMatrix * uMVMatrix * vec4(aVertexPosition, 1.0); } </script> In my html header,

Using OpenGL ES 2.0 with iOS, how do I draw a cylinder between two points?

亡梦爱人 提交于 2020-01-17 06:36:10
问题 I am given two GLKVector3 's representing the start and end points of the cylinder. Using these points and the radius, I need to build and render a cylinder. I can build a cylinder with the correct distance between the points but in a fixed direction (currently always in the y (0, 1, 0) up direction). I am not sure what kind of calculations I need to make to get the cylinder on the correct plane between the two points so that a line would run through the two end points. I am thinking there is

Incorrect VBO for mesh: some triangles are connected and shouldn't [2D]

江枫思渺然 提交于 2020-01-14 18:48:50
问题 I'm generating my VBO with this code int SCREEN_WIDTH = 800; int SCREEN_HEIGHT = 480; int PIXEL_PER_VERTEX = 4; int CAVERN_TEXTURE_WIDTH = 1024; int CAVERN_TEXTURE_HEIGHT = 512; final int vertexCount = ((SCREEN_WIDTH / PIXEL_PER_VERTEX) +1 ) * 2; final float[] bufferDataLowerCave = new float[vertexCount * CavernBoundMesh.VERTEX_SIZE]; for(int i=0; i < vertexCount; i += 2) { bufferDataLowerCave[i * CavernBoundMesh.VERTEX_SIZE + CavernBoundMesh.VERTEX_INDEX_X] = PIXEL_PER_VERTEX * i / 2.f;

Incorrect VBO for mesh: some triangles are connected and shouldn't [2D]

谁都会走 提交于 2020-01-14 18:47:07
问题 I'm generating my VBO with this code int SCREEN_WIDTH = 800; int SCREEN_HEIGHT = 480; int PIXEL_PER_VERTEX = 4; int CAVERN_TEXTURE_WIDTH = 1024; int CAVERN_TEXTURE_HEIGHT = 512; final int vertexCount = ((SCREEN_WIDTH / PIXEL_PER_VERTEX) +1 ) * 2; final float[] bufferDataLowerCave = new float[vertexCount * CavernBoundMesh.VERTEX_SIZE]; for(int i=0; i < vertexCount; i += 2) { bufferDataLowerCave[i * CavernBoundMesh.VERTEX_SIZE + CavernBoundMesh.VERTEX_INDEX_X] = PIXEL_PER_VERTEX * i / 2.f;

GLSL ES fragment shader produces very different results on different devices

删除回忆录丶 提交于 2020-01-14 18:45:53
问题 I am developing a game for Android using OpenGL ES 2.0 and have a problem with a fragment shader for drawing stars in the background. I've got the following code: precision mediump float; varying vec2 transformed_position; float rand(vec2 co) { return fract(sin(dot(co.xy ,vec2(12.9898,78.233))) * 43758.5453); } void main(void) { float distance = 10.0; float quantization_strength = 4.0; vec3 background_color = vec3(0.09, 0.0, 0.288); vec2 zero = vec2(0.0, 0.0); vec2 distance_vec = vec2

GLSL ES fragment shader produces very different results on different devices

不羁岁月 提交于 2020-01-14 18:44:31
问题 I am developing a game for Android using OpenGL ES 2.0 and have a problem with a fragment shader for drawing stars in the background. I've got the following code: precision mediump float; varying vec2 transformed_position; float rand(vec2 co) { return fract(sin(dot(co.xy ,vec2(12.9898,78.233))) * 43758.5453); } void main(void) { float distance = 10.0; float quantization_strength = 4.0; vec3 background_color = vec3(0.09, 0.0, 0.288); vec2 zero = vec2(0.0, 0.0); vec2 distance_vec = vec2