opengl-es-2.0

Declaring constants instead of literals in vertex shader. Standard practice, or needless rigor?

我的梦境 提交于 2019-12-01 03:57:10
问题 In a vertex shader , there is of course a limited amount of uniform storage allowed, and it is my understanding that different systems may implement GLSL in slightly different ways in terms of compiling code. I've heard the recommendation to use constants instead of writing out literals in the vertex shader code. For instance, the following code could supposedly result in a reduction in available uniform storage. (I don't quite understand how.) Example 1: With literals vec4 myVector = vec4(1

glCreateShader and glCreateProgram fail on android

北城以北 提交于 2019-12-01 02:57:28
I'm having a very difficult problem creating a shader program on android. when I call glCreateShader or glCreateProgram each always returns 0. I've covered all my bases with regards to troubleshooting: I checked to make sure I had an ogl context (I do, i tested this by clearing the frame buffer with various colors, which worked). I tried glGetError but it returned nothing (GL_NO_ERROR) I'm not an opengl or android expert so I don't know of any thing else that could be causing this. I've been running my app on a nexus 7 tablet and I use OpenGL ES 2.0, and I target the latest version of Android

Is there any Android device with screen size greater than GL_MAX_TEXTURE_SIZE?

五迷三道 提交于 2019-12-01 02:45:23
问题 I've been searching through glbenchmark.com for a device with screen size (width or height) greater than GL_MAX_TEXTURE_SIZE . I've found over a hundred devices with GL_MAX_VIEWPORT_WIDTH and GL_MAX_VIEWPORT_HEIGHT greater than GL_MAX_TEXTURE_SIZE (for example Acer A110), but no device with screen size greater than GL_MAX_TEXTURE_SIZE . So I assume there is no such device. Is there any specification that guarantees that every device (or Android device) has screen size less or equal to GL_MAX

Is it Possible to give effect like Vertex Shader and Fragment Shader to the Android Camera Preview , and Save the Captured image with OpenGLES?

谁说胖子不能爱 提交于 2019-12-01 00:13:14
This two are My VertexShader and Fragment Shader file: Vertex Shader File: attribute vec4 position; attribute vec4 inputTextureCoordinate; varying vec2 textureCoordinate; varying vec4 co; void main() { gl_Position = position; textureCoordinate = inputTextureCoordinate.xy; co = inputTextureCoordinate; } Fragment Shader File: uniform sampler2D videoFrame; // the texture with the scene you want to blur varying mediump vec2 textureCoordinate; varying mediump vec4 co; precision mediump float; vec4 nightVision() { float luminanceThreshold = 0.2; // 0.2 float colorAmplification = 2.0; // 4.0 float

OpenGL ES 2.0 Camera Issues

心已入冬 提交于 2019-11-30 21:15:19
I'm working with Android and OpenGL ES 2.0 and I am having an issue that I can't really formulate into a solid question. In the image, http://i.imgur.com/XuCHF.png , I basically have a shape to represent a ship in the middle and when it's moved to the side it gets stretched toward the vanishing point. What I am wanting to accomplish is to have the ship maintain most of its shape when it is moved. I believe it may be due to my matrices but every resource I've looked seems to use the same method. //Setting up the projection matrix final float ratio = (float) width / height; final float left =

How to create Stencil buffer with texture (Image) in OpenGL-ES 2.0

痞子三分冷 提交于 2019-11-30 19:59:41
Can I have Stencil prepared with a texture (Image) in OpenGL 2.0 So that some part of the Image will be transparent and as a result it will be transfered as is to Stencil buffer and then will use this use this stencil buffer for further drawing. EDIT by datenwolf to account for OPs question update in a answer: By @InfiniteLoop: @datenwolf thanks a lot for ur reply but no success :( here is my code - (void)render { [EAGLContext setCurrentContext:context]; glBindFramebuffer(GL_FRAMEBUFFER, defaultFramebuffer); glUseProgram(program); glClearColor(0, 104.0/255.0, 55.0/255.0, 1.0); glViewport(0, 0,

Is it possible for a vertex attribute to be an array in GLSL-ES 2.0?

僤鯓⒐⒋嵵緔 提交于 2019-11-30 19:31:42
In GLSL-ES it's possible to have arrays. For example, the GLSL ES Specification gives the following example of a uniform variable that's an array: uniform vec4 lightPosition[4]; Is it possible to have vertex attributes that are arrays? In other words, is the following legal according to the spec? attribute vec4 foo[3]; // three vec4s per vertex Is the answer (either yes or no) explicitly mentioned anywhere in the GLSL ES Specification? (I can't find it, but I haven't read every line of the spec.) Also, if it is legal, how does one initialize such an attribute using the OpenGL ES 2.0 API?

GLSurfaceView - how to make translucent background

被刻印的时光 ゝ 提交于 2019-11-30 18:55:11
I try to render using GLSurfaceView, and by docs I set format: getHolder().setFormat(PixelFormat.TRANSLUCENT); The I use GLSurfaceView.Renderer, which draws in onDrawFrame: GLES20.glClearColor(0, 0, 1, .5f); GLES20.glClear(GLES20.GL_DEPTH_BUFFER_BIT | GLES20.GL_COLOR_BUFFER_BIT); However, the GL rendering in GLSurfaceView is not translucent, and is fully blue. If I omit glClear call, then it's fully black. How do I make GL rendering to have transparent background, so that it is blended with views drawn behind it? EDIT : here is my GLSurfaceView: class GLView extends GLSurfaceView{ MyRenderer r

Can I specify per face normal in OpenGL ES and achieve non-smooth/flat shading?

ぐ巨炮叔叔 提交于 2019-11-30 18:51:12
I want to display mesh models in OpenGL ES 2.0, where it clearly shows the actual mesh, so I don't want smooth shading across each primitive/triangle. The only two options I can think about are Each triangle has its own set of normals, all perpendicular to the triangles surface (but then I guess I can't share vertices among the triangles with this option) Indicate triangle/primitive edges using black lines and stick to the normal way with shared vertices and one normal for each vertex Does it have to be like this? Why can't I simply read in primitives and don't specify any normals and somehow

OpenGL ES 2.0 Camera Issues

落花浮王杯 提交于 2019-11-30 17:03:22
问题 I'm working with Android and OpenGL ES 2.0 and I am having an issue that I can't really formulate into a solid question. In the image, http://i.imgur.com/XuCHF.png, I basically have a shape to represent a ship in the middle and when it's moved to the side it gets stretched toward the vanishing point. What I am wanting to accomplish is to have the ship maintain most of its shape when it is moved. I believe it may be due to my matrices but every resource I've looked seems to use the same method