• Advertisement

EddieK

Member
  • Content count

    26
  • Joined

  • Last visited

Community Reputation

113 Neutral

About EddieK

  • Rank
    Member

Personal Information

  • Interests
    Programming
  1. I'm using OpenGL ES 2.0 which doesn't have the glMapBufferRange or glBufferStorage so I think I can't use streaming.
  2. I figured out that I need to use glBufferSubData() instead. Tried it, but it was even slower
  3. Well because I need to update the vertex positions and their colors every frame. How else am I supposed to update the vertices? Sorry, but I am a newbie when it comes to OpenGL.
  4. My shaders look like this: Fragment shader: precision lowp float; uniform sampler2D texture; varying vec4 outColor; varying vec2 outTexCoords; varying vec3 outNormal; void main() { vec4 color = texture2D(texture, outTexCoords) * outColor; gl_FragColor = vec4(color.r,color.g,color.b,color.a); } Vertex shader: uniform mat4 MVPMatrix; // model-view-projection matrix uniform mat4 projectionMatrix; attribute vec4 position; attribute vec2 textureCoords; attribute vec4 color; attribute vec3 normal; varying vec4 outColor; varying vec2 outTexCoords; varying vec3 outNormal; void main() { outNormal = normal; outTexCoords = textureCoords; outColor = color; gl_Position = MVPMatrix * position; } My rendering code: public void bind(){ int stride = (2 + 3 + 4) * 4; vertexBuffer.put(vertexArray, 0, vertexCount); indexBuffer.put(indexArray, 0, indexCount); this.vertexBuffer.position(0); this.indexBuffer.position(0); GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, buffers[0]); GLES20.glBufferData(GLES20.GL_ARRAY_BUFFER, vertexBytesAdded, vertexBuffer, GLES20.GL_STATIC_DRAW); ShaderAttributes attributes = graphicsSystem.getShader().getAttributes(); GLES20.glVertexAttribPointer(attributes.getAttributeID(Attribute.Position), dimensions, GLES20.GL_FLOAT, false, stride, 0); attributes.enableAttribute(Attribute.Position); GLES20.glVertexAttribPointer(attributes.getAttributeID(Attribute.Color), 4, GLES20.GL_FLOAT, false, stride, 3 * 4); attributes.enableAttribute(Attribute.Color); GLES20.glVertexAttribPointer(attributes.getAttributeID(Attribute.TextureCoords), 2, GLES20.GL_FLOAT, false, stride, (4 + 3) * 4); attributes.enableAttribute(Attribute.TextureCoords); GLES20.glBindBuffer(GLES20.GL_ELEMENT_ARRAY_BUFFER, buffers[1]); GLES20.glBufferData(GLES20.GL_ELEMENT_ARRAY_BUFFER, indexBytesAdded, indexBuffer, GLES20.GL_STATIC_DRAW); vertexBytesAdded = 0; indexBytesAdded = 0; vertexCount = 0; indexCount = 0; } public void draw(int mode, int count){ if(hasIndices){ GLES20.glDrawElements(GLES20.GL_TRIANGLES, count, GLES20.GL_UNSIGNED_SHORT, 0); }else{ GLES20.glDrawArrays(mode, 0, count); } } Is there anything I can improve to increase the framerate? I'm really out of ideas here, it seems like I tried everything and I still can't get past 3000 triangles without the framerate dropping below 60. I read somewhere that MALI-400 is capable of 30 million polygons per second and I am getting only around 500,000.
  5. Hi, so I have this game which I'm working on and I have implemented A* pathfinding algorithm, but the problem is that the game framerate drops significantly if there are more than 50-100 enemies which need to find path to player. I did some code analyzing and noticed that the part which takes longest to process is part where it searches for node with the lowest F score. Is there anyway I could speed the process up? Here's the code I'm using: public ArrayList<Node> getPath(Node start, Node end){ closedSet.clear(); openSet.clear(); openSet.add(start); cameFrom.clear(); start.gScore = 0; start.fScore = heuristicCostEstimate(start, end); while(openSet.size() > 0){ Node currentNode = lowestFScoreNode(openSet);//openSet.findLowestFScoreNode(); if(currentNode.equals(end)){ return reconstructPath(cameFrom, currentNode); } openSet.remove(currentNode); closedSet.add(currentNode); Node [] neighbours = getNeighbours(currentNode); for(int i = 0; i < neighboursCount; i++){ if(closedSet.contains(neighbours[i])) continue; openSet.add(neighbours[i]); float tentativeGScore = currentNode.gScore + heuristicCostEstimate(start, neighbours[i]); if(tentativeGScore >= neighbours[i].gScore) continue; cameFrom.put(neighbours[i], currentNode); neighbours[i].gScore = tentativeGScore; neighbours[i].fScore = neighbours[i].gScore + heuristicCostEstimate(neighbours[i], end); } } return null; } The lowestFScore node function just returns result of Collections.min() Thanks in advance.
  6. Hi I am having this problem where I am drawing 4000 squares on screen, using VBO's and IBO's but the framerate on my Huawei P9 is only 24 FPS. Considering it has 8-core CPU and a pretty powerful GPU, I don't think it is not capable of drawing 4000 textured squares at 60FPS. I checked the DMMS and found out that most of the time spent was by the put() method of the FloatBuffer, but the strange thing is that if I'm drawing these squares outside of the view frustum, the FPS increases. And I'm not using frustum culling. If you have any ideas what could be causing this, please share them with me. Thank you in advance.
  7. Thanks for trying to help, but I already solved the issue. The glitching was because I stored the data in to buffer incorrectly. Instead of XYZRGBA XYZRGBA format, it was XYZ XYZ RGBA RGBA
  8. Hi, so I am trying to implement packed VBO's with indexing on OpenGL but I have run across problems. It worked fine when I had separate buffers for vertex positions, colors and texture coordinates. But when I tried to put everything into a single packed buffer, it completely glitched out. Here's the code which I am using: this.vertexData.position(0); this.indexData.position(0); int stride = (3 + 4 + 2) * 4; GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, buffers[0]); GLES20.glBufferData(GLES20.GL_ARRAY_BUFFER, vertexData.capacity()*4, vertexData, GLES20.GL_STATIC_DRAW); ShaderAttributes attributes = graphicsSystem.getShader().getAttributes(); GLES20.glEnableVertexAttribArray(positionAttrID); GLES20.glVertexAttribPointer(positionAttrID, dimensions, GLES20.GL_FLOAT, false, stride, 0); GLES20.glEnableVertexAttribArray(colorAttrID); GLES20.glVertexAttribPointer(colorAttrID, 4, GLES20.GL_FLOAT, false, stride, dimensions * 4); GLES20.glEnableVertexAttribArray(texCoordAttrID); GLES20.glVertexAttribPointer(texCoordAttrID, 2, GLES20.GL_FLOAT, false, stride, (dimensions + 4) * 4); GLES20.glBindBuffer(GLES20.GL_ELEMENT_ARRAY_BUFFER, buffers[3]); GLES20.glBufferData(GLES20.GL_ELEMENT_ARRAY_BUFFER, indexData.capacity()*2, indexData, GLES20.GL_STATIC_DRAW); GLES20.glDrawElements(mode, count, GLES20.GL_UNSIGNED_SHORT, 0); The data in vertex buffer is ordered like this: Vertex X, vertex Y, vertex Z, Color r, color g, color b, color a, Tex coord x, tex coord z and so on... (And I am pretty certain that the buffer I'm using is in this order) This is the version of the code which worked fine: this.vertexData.position(0); this.vertexColorData.position(0); this.vertexTexCoordData.position(0); this.indexData.position(0); GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, buffers[0]); GLES20.glBufferData(GLES20.GL_ARRAY_BUFFER, vertexPositionData.capacity()*4, vertexPositionData, GLES20.GL_STATIC_DRAW); ShaderAttributes attributes = graphicsSystem.getShader().getAttributes(); GLES20.glEnableVertexAttribArray(positionAttrID); GLES20.glVertexAttribPointer(positionAttrID, 4, GLES20.GL_FLOAT, false, 0, 0); GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, buffers[1]); GLES20.glBufferData(GLES20.GL_ARRAY_BUFFER, vertexColorData.capacity()*4, vertexColorData, GLES20.GL_STATIC_DRAW); GLES20.glEnableVertexAttribArray(colorAttrID); GLES20.glVertexAttribPointer(colorAttrID, 4, GLES20.GL_FLOAT, false, 0, 0); GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, buffers[2]); GLES20.glBufferData(GLES20.GL_ARRAY_BUFFER, vertexTexCoordData.capacity()*4, vertexTexCoordData, GLES20.GL_STATIC_DRAW); GLES20.glEnableVertexAttribArray(textCoordAttrID); GLES20.glVertexAttribPointer(textCoordAttrID, 4, GLES20.GL_FLOAT, false, 0, 0); */ GLES20.glBindBuffer(GLES20.GL_ELEMENT_ARRAY_BUFFER, buffers[3]); GLES20.glBufferData(GLES20.GL_ELEMENT_ARRAY_BUFFER, indexData.capacity()*2, indexData, GLES20.GL_STATIC_DRAW); GLES20.glDrawElements(mode, count, GLES20.GL_UNSIGNED_SHORT, 0); This is the output of the non working code: From this picture I can see that some of the vertex positions are good, but for some reason every renderable object from the game has a at least one vertex position of value 0 Thank in advance, Ed
  9. Killer Jack (Dev Blog #2)

    Thanks! I tried implementing the more complex behavior for zombies, but I had some problems with the A* algorithm and its performance. I might revisit this problem and try some different things. Map will be changed as well later on
  10. Killer Jack (Dev Blog #2)

    A week ago I decided to scrap the RPG idea for the game, as it would require way too much time to complete. Instead, I will be making zombie shooter game for android. During this week I added smooth camera movement, camera shakes, bigger and faster bullets and blood particles to make the shooting more enjoyable. You can see the current state of the game here:
  11. Game I'm making is not fun

    Guys, big thanks for the replies, you helped me out alot, I added blood particles, shaky screen, smooth camera movement, bigger and faster bullets, louder shooting sounds and now it feels a lot more satisfying to kill stuff
  12. So I am working on this top down shooter game which at first was supposed to be an RPG, but I now decided to make it a simpler shooter. And the problem is that it's not fun. All you do is run around shooting zombies, leveling up and collecting new weapons. I need to make it more challenging, but I have no ideas. I also need to make so that the player would feel rewarded if he plays well, but I don't know how to do it well. If you guys have any ideas for game objectives, or fun game mechanics that would fit my game, please share it with me. You can see the footage of my game here:
  13. Hi, so I am creating an Android game. My first idea was to make it an RPG, but after realizing that creating quests and huge maps would require way too much time, I decided to remove quests. The leveling up system is still there, you can loot items, upgrade your weapons and collect ammo. My question would be: what kind of objective or feature could I add to make the game more fun? Right now it's pretty dull. All you do is walk around while shooting enemies and seeing as your level goes up.
  14. Untitled Android RPG (Dev Blog #1)

    Actually I really do need some pixel art Currently I mainly need animated sprites for main character and some monsters. All I could find online were copyrighted material which I cannot use. So if you really could help me out, that would be fantastic :))
  15. Untitled Android RPG (Dev Blog #1)

    Thanks I will change the sprite later on, because I don't want to infringe copyrights after releasing it on Google play. I will probably add more pixels to show that he's holding a gun, but I really suck at drawing so I don't know how it will go
  • Advertisement