Search Results

Search found 8 results on 1 pages for 'user16547'.

Page 1/1 | 1 

  • Android OpenGL ES 2 framebuffer not working properly

    - by user16547
    I'm trying to understand how framebuffers work. In order to achieve that, I want to draw a very basic triangle to a framebuffer texture and then draw the resulting texture to a quad on the default framebuffer. However, I only get a fraction of the triangle like below. LE: The triangle's coordinates should be (1) -0.5f, -0.5f, 0 (2) 0.5f, -0.5f, 0 (3) 0, 0.5f, 0 Here's the code to render: @Override public void onDrawFrame(GL10 gl) { renderNormalStuff(); renderFramebufferTexture(); } protected void renderNormalStuff() { GLES20.glViewport(0, 0, texWidth, texHeight); GLUtils.updateProjectionMatrix(mProjectionMatrix, texWidth, texHeight); GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, fbo[0]); GLES20.glUseProgram(mProgram); GLES20.glClearColor(.5f, .5f, .5f, 1); GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT | GLES20.GL_COLOR_BUFFER_BIT); Matrix.setIdentityM(mModelMatrix, 0); Matrix.multiplyMM(mMVPMatrix, 0, mViewMatrix, 0, mModelMatrix, 0); Matrix.multiplyMM(mMVPMatrix, 0, mProjectionMatrix, 0, mMVPMatrix, 0); GLES20.glUniformMatrix4fv(u_MVPMatrix, 1, false, mMVPMatrix, 0); GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, vbo[0]); GLES20.glVertexAttribPointer(a_Position, 3, GLES20.GL_FLOAT, false, 12, 0); GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, vbo[1]); GLES20.glVertexAttribPointer(a_Color, 4, GLES20.GL_FLOAT, false, 16, 0); GLES20.glBindBuffer(GLES20.GL_ELEMENT_ARRAY_BUFFER, ibo[0]); GLES20.glDrawElements(GLES20.GL_TRIANGLES, indexBuffer.capacity(), GLES20.GL_UNSIGNED_BYTE, 0); GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, 0); GLES20.glBindBuffer(GLES20.GL_ELEMENT_ARRAY_BUFFER, 0); GLES20.glUseProgram(0); } private void renderFramebufferTexture() { GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, 0); GLES20.glUseProgram(fboProgram); GLES20.glClearColor(.0f, .5f, .25f, 1); GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT | GLES20.GL_DEPTH_BUFFER_BIT); GLES20.glViewport(0, 0, width, height); GLUtils.updateProjectionMatrix(mProjectionMatrix, width, height); Matrix.setIdentityM(mModelMatrix, 0); Matrix.multiplyMM(mMVPMatrix, 0, mViewMatrix, 0, mModelMatrix, 0); Matrix.multiplyMM(mMVPMatrix, 0, mProjectionMatrix, 0, mMVPMatrix, 0); GLES20.glUniformMatrix4fv(fbo_u_MVPMatrix, 1, false, mMVPMatrix, 0); //draw the texture GLES20.glActiveTexture(GLES20.GL_TEXTURE0); GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, texture[0]); GLES20.glUniform1i(fbo_u_Texture, 0); GLUtils.sendBufferData(fbo_a_Position, 3, quadPositionBuffer); GLUtils.sendBufferData(fbo_a_TexCoordinate, 2, quadTexCoordinate); GLES20.glDrawElements(GLES20.GL_TRIANGLES, quadIndexBuffer.capacity(), GLES20.GL_UNSIGNED_BYTE, quadIndexBuffer); GLES20.glUseProgram(0); }

    Read the article

  • Progress bar in Super Hexagon using OpenGL ES 2 (Android)

    - by user16547
    I'm wondering how the progress bar in Super Hexagon was made. (see image, top left) Actually I am not very sure how to implement a progress bar at all using OpenGL ES 2 on Android, but I am asking specifically about the one used in Super Hexagon because it seems to me less straightforward / obvious than others: the bar changes its colour during game play. I think one possibility is to use the built-in Android progress bar. I can see from some Stackoverflow questions that you can change the default blue colour to whatever you want, but I'm not sure whether you can update it during the game play. The other possibility I can think of for implementing a progress bar is to have a small texture that starts with a scale of 0 and that you keep scaling until it reaches the maximum size, representing 100%. But this suffers from the same problem as before: you'll not be able to update the colour of the texture during run-time. It's fixed. So what's the best way to approach this problem? *I'm assuming he didn't use a particular library, although if he did, it would be interesting to know. I'm interested in a pure OpenGL ES 2 + Android solution.

    Read the article

  • Displaying and updating score in Android (OpenGL ES 2)

    - by user16547
    I'm using a FrameLayout where I have a GLSurfaceView at the bottom and a few Views on top of it. One of those Views is a TextView that displays the current score. Here's how I'm updating the score TextView based on what happens in my game loop: whenever an event happens that increases the score, I call activity.runOnUiThread(updater), where activity is the activity that has the above FrameLayout (my main game activity) and updater is just a Runnable that increments the score. From my understanding, using runOnUiThread() from the OpenGL thread is standard practice - otherwise you'll get an exception, I can't remember its name. The problem is that there's a very noticeable lag between the event and the score update. For example the character gets a coin, but the coin count is not updated quickly. I tried summing all the score events from my game loop and calling runOnUiThread() only once per loop, but it doesn't seem to make much of a difference - the lag is still noticeable. How can I improve my design to avoid this lag?

    Read the article

  • OpenGL ES 2 jittery camera movement

    - by user16547
    First of all, I am aware that there's no camera in OpenGL (ES 2), but from my understanding proper manipulation of the projection matrix can simulate the concept of a camera. What I'm trying to do is make my camera follow my character. My game is 2D, btw. I think the principle is the following (take Super Mario Bros or Doodle Jump as reference - actually I'm trying to replicate the mechanics of the latter): when the caracter goes beyond the center of the screen (in the positive axis/direction), update the camera to be centred on the character. Else keep the camera still. I did accomplish that, however the camera movement is noticeably jittery and I ran out of ideas how to make it smoother. First of all, my game loop (following this article): private int TICKS_PER_SECOND = 30; private int SKIP_TICKS = 1000 / TICKS_PER_SECOND; private int MAX_FRAMESKIP = 5; @Override public void run() { loops = 0; if(firstLoop) { nextGameTick = SystemClock.elapsedRealtime(); firstLoop = false; } while(SystemClock.elapsedRealtime() > nextGameTick && loops < MAX_FRAMESKIP) { step(); nextGameTick += SKIP_TICKS; loops++; } interpolation = ( SystemClock.elapsedRealtime() + SKIP_TICKS - nextGameTick ) / (float)SKIP_TICKS; draw(); } And the following code deals with moving the camera. I was unsure whether to place it in step() or draw(), but it doesn't make a difference to my problem at the moment, as I tried both and neither seemed to fix it. center just represents the y coordinate of the centre of the screen at any time. Initially it is 0. The camera object is my own custom "camera" which basically is a class that just manipulates the view and projection matrices. if(character.getVerticalSpeed() >= 0) { //only update camera if going up float[] projectionMatrix = camera.getProjectionMatrix(); if( character.getY() > center) { center += character.getVerticalSpeed(); cameraBottom = center + camera.getBottom(); cameraTop = center + camera.getTop(); Matrix.orthoM(projectionMatrix, 0, camera.getLeft(), camera.getRight(), center + camera.getBottom(), center + camera.getTop(), camera.getNear(), camera.getFar()); } } Any thought about what I should try or what I am doing wrong? Update 1: I think I updated every value you can see on screen to check whether the jittery movement is affected by that, but nothing changed, so something must be fundamentally flawed with my approach/calculations.

    Read the article

  • Very basic OpenGL ES 2 error

    - by user16547
    This is an incredibly simple shader, yet I'm having a lot of trouble understanding what's wrong with it. I'm trying to send a float to my fragment shader. Its purpose is to adjust the alpha of the fragment colour. Here is my fragment shader: precision mediump float; uniform sampler2D u_Texture; uniform float u_Alpha; varying vec2 v_TexCoordinate; void main() { gl_FragColor = texture2D(u_Texture, v_TexCoordinate); gl_FragColor.a *= u_Alpha; } and below is my rendering method. I get a 1282 (invalid operation) on the GLES20.glUniform1f(u_Alpha, alpha); line. alpha is 1 (but I tried other values as well) and transparent is true: public void render() { GLES20.glUseProgram(mProgram); if(transparent) { GLES20.glEnable(GLES20.GL_BLEND); GLES20.glBlendFunc(GLES20.GL_SRC_ALPHA, GLES20.GL_ONE_MINUS_SRC_ALPHA); GLES20.glUniform1f(u_Alpha, alpha); } Matrix.setIdentityM(mModelMatrix, 0); Matrix.rotateM(mModelMatrix, 0, angle, 0, 0, 1); Matrix.translateM(mModelMatrix, 0, x, y, z); Matrix.multiplyMM(mMVPMatrix, 0, mViewMatrix, 0, mModelMatrix, 0); Matrix.multiplyMM(mMVPMatrix, 0, mProjectionMatrix, 0, mMVPMatrix, 0); GLES20.glUniformMatrix4fv(u_MVPMatrix, 1, false, mMVPMatrix, 0); GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, vbo[0]); GLES20.glVertexAttribPointer(a_Position, 3, GLES20.GL_FLOAT, false, 12, 0); GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, vbo[1]); GLES20.glVertexAttribPointer(a_TexCoordinate, 2, GLES20.GL_FLOAT, false, 8, 0); //snowTexture start GLES20.glActiveTexture(GLES20.GL_TEXTURE0); GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, textureHandle[0]); GLES20.glUniform1i(u_Texture, 0); GLES20.glBindBuffer(GLES20.GL_ELEMENT_ARRAY_BUFFER, ibo[0]); GLES20.glDrawElements(GLES20.GL_TRIANGLE_STRIP, indices.capacity(), GLES20.GL_UNSIGNED_BYTE, 0); GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, 0); GLES20.glBindBuffer(GLES20.GL_ELEMENT_ARRAY_BUFFER, 0); if(transparent) { GLES20.glDisable(GLES20.GL_BLEND); } GLES20.glUseProgram(0); }

    Read the article

  • Animations / OpenGL (ES 2) in game menu

    - by user16547
    (I am specifically asking for Android) If you look at Angry Birds (and in fact many other games), you can already see a lot of animations & effects going in the main menu and in other places even before starting to play. I assume they are done with OpenGL, more precisely a FrameLayout is used and inside it a GLSurfaceView is somewhere at the bottom of the hierarchy; above the GLSurfaceView you have regular Android buttons and texts. Is this how it's done*? Also would you reuse the same GLSurfaceView when running the actual game or should another one be created? *I am aware an alternative approach would be to make absolutely everything in OpenGL. Of these two I prefer the FrameLayout one, but I don't know whether other developers agree.

    Read the article

  • Particle system lifetimes in OpenGL ES 2

    - by user16547
    I don't know how to work with my particle's lifetimes. My design is simple: each particle has a position, a speed and a lifetime. At each frame, each particle should update its position like this: position.y = position.y + INCREMENT * speed.y However, I'm having difficulties in choosing my INCREMENT. If I set it to some sort of FRAME_COUNT, it looks fine until FRAME_COUNT has to be set back to 0. The effect will be that all particles start over at the same time, which I don't want to happen. I want my particles sort of live "independent" of each other. That's the reason I need a lifetime, but I don't know how to make use of it. I added a lifetime for each particle in the particle buffer, but I also need an individual increment that's updated on each frame, so that when PARTICLE_INCREMENT = PARTICLE_LIFETIME, each increment goes back to 0. How can I achieve something like that?

    Read the article

  • How to create a map-like (clouds) texture [duplicate]

    - by user16547
    This question already has an answer here: How do you generate tileable Perlin noise? 9 answers If you place a map of the world on a sphere, it will look like the image is continuous. Basically the left end of the image is sort of a continuation of the right end. You won't be able to see any cuts. I'm trying to create a clouds texture to add to my planet such that it will seem it has clouds. I managed to create the clouds in GIMP, however, I can't figure out how to make sure the left end of my image is a smooth continuation of the right end. For example if you were to map the below image to your sphere (I removed transparency to make it clearer), there would be a very obvious transition from the right end of the image back to the left end on your sphere. How would I create a texture such that I get rid of that? Sorry for my lack of terminology.

    Read the article

1