49

They are more complementary than alternatives to each other. You almost always want to set the scissor rectangle to the same values as the viewport. glViewport() specifies a transformation from normalized projection space to screen space. Polygons are clipped to the edge of projection space, but other draw operations like glClear() are not. So, you use ...


16

The problem with using texture atlases and adjacent texels leaking has to do with the way linear texture filtering works. For any point in the texture that is not sampled exactly at the center of a texel, linear sampling will sample 4 adjacent texels and compute the value at the location you asked as the weighted (based on distance from the sample point) ...


16

Each glDraw* is a draw call. 1 glDrawArrays is 1 draw call. 1 glDrawElements is 1 draw call. It doesn't matter (so far as draw call count is concerned) how many vertices or indices you use, 1 glDraw* is 1 draw call. The simple cases of drawing quads (assuming the GL version you use hasn't removed quads) or triangles are not a good example for comparing ...


15

The main rationale for using binary shaders is if compiling the text shaders is too big of a workload for your target device. Binary GLSL shaders don't have a standardized format, so you'd need different ones for each GPU/driver you plan to support. I'd recommend you distribute the shaders in source form and then on the first run cache them into binary form ...


15

You propose running each separate "system" in parallel. The problem with this is that you will have to lock every single piece of shared state. CLARITY EDIT: When you have two parallel operations using all of the same data, lock contention and synchronization is going to slow things down so that you're not gaining many benefits from the parallelization. ...


13

They operate at two completely different parts of the graphics pipeline. glViewport actually specifies a transformation, and it's a transformation that happens after the vertex shader but before the fragment shader. If it helps to see where it conceptually fits in, think in terms of it being part of the transforms that are used to get your vertex data from ...


13

TL; DR: If you multiply stuff together, you need to start with a 1 Forget about matrices for a second, let's talk about numbers. Suppose to rotate by 90, you multiply by 90. So P' = 90*P Now you do other transforms - a rotation R, a translation T, a scale S and so on. So P' = T*R*S*P Since you will apply all these transforms to a lot of points, you want ...


10

The performance cost of branching can be not trivially small too. In your case all vertices and fragments being drawn will be taking the same path through your shaders, so on modern desktop hardware it would not be as bad as it could be, but you're using ES2 which implies that you're not using modern desktop hardware. The worst case with branching will go ...


9

I'd like to add another answer to this that was passed on to me a year or two back by Chris Pruett (Replica Island, Wind-Up Knight, etc). It's especially useful here in 2013 since setPreserveEglContextOnPause(true) doesn't seem to work on 4.3. (I could be wrong about that but that's how it looks to me right now as I update game code last touched in 2011). ...


9

ES2 has neither glVertexAttribDivisor nor floating point textures so your options are quite limited. Definitely put your chair model into a VBO if you're not doing so already. From there you're more or less restricted to individual draw calls - one per chair - so it's a question of getting the transformation matrix for each chair to the GPU as efficiently ...


9

A matrix is used to convert a vector from one coordinate system to another (say, from coordinate system 'A' to coordinate system 'B'). The inverse of a matrix is a matrix which converts the other direction (say, from 'B' back into 'A') In games, we commonly have a matrix which will transform positions from world-space into homogenous eye-space, since ...


8

I like this kind of things explained visually. In OnpenGL we have 2D coordinates that go from -1 to +1 for both the X and Y axis. Then this image needs to be mapped to window coordinates. Let's imagine that we have window that has a dark color as back ground, and we have white as the clear color. The most common case is having viewport and scissor cover ...


8

The way most drivers operate is by using a "lazy state changes" model. What this means is that the vast majority of your gl* calls will actually do nothing much more than recording a state, storing off some parameters, then return immediately. This works perfectly fine up until a gl* call is made that actually needs to do something with all that state (or ...


7

OpenGL and OpenGL ES, despite the similar names, are two different specifications. They may have similarly named functions, but there will be semantic differences between what these functions do. And of course, there will be differences in what features they support. PBOs are not supported on ES (except for ES 3.0, which recently came out but isn't widely ...


7

Vertices: Every triangle you submit to OpenGL must be checked against the view frustum. If you send geometry which is out of view, it still must be transformed (by your vertex shader) to find out that it is out of view. The more vertices in your scene, the more useful it is to cull vertices in your code before sending them to the GPU. If this is a ...


7

Your best bet is to use an instancing approach pretty similar to skinned models. Create a VBO that will hold many copies of your chair, all of them identical. Now, every vertex must have a byte attribute that will hold the index to the transform matrix that it will be applied to it. Send an array of matrices to your shader and use them as the world transform ...


7

Look into the (horribly named) AssImp asset importer library (http://assimp.sourceforge.net/). It allows loading a variety of 3D file formats into memory, which you can then use to generate your preferred in-memory format for rendering models. You might consider using AssImp as a preprocessor pipeline stage. That is, have a separate tool to covert the ...


7

The Solution Hell yeah!!! I'm one happy chap now! :D OK, I finally manage to get Stencil working with texture :) (also learned a number of things along the way, e.g. we can check color.alpha and use discard as a way to remove transparent pixel and the glBlend(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA) trick becomes obsolete) So the first thing I noticed I ...


7

I solved the problem with the EGLConfigChooser. I have no idea what that is doing... but it works very fine. I just copyed the code from here: http://code.google.com/p/gdc2011-android-opengl/source/browse/trunk/src/com/example/gdc11/MultisampleConfigChooser.java in a new class and made as it told me: To use this, call myGLSurfaceView....


7

It's easy to produce an effect like this in a pixel shader, using threshold animation. The idea is that you have a monochrome texture and apply a threshold value to it; wherever the texture is lower than the threshold, the material is colored, and where the texture is higher than the threshold the material is blank. You animate the threshold value from 0 ...


7

If I call glDeleteTextures, will it release memory immediately? glDeleteTextures After a texture is deleted, it has no contents or dimensionality, and its name is free for reuse. This says absolutely nothing about the backing storage for a texture, i.e the memory used for it. From that we can infer that behaviour is entirely up to the GL implementation....


7

First of all, you are very confused. There is OpenGL ES 2.0, and there is desktop OpenGL 2.0 and 2.1. These are very different things, which run on entirely different platforms. ES runs on primarily mobile hardware, while desktop GL runs primarily on desktop hardware. The core/compatibility distinction only exists for desktop GL, not OpenGL ES. Raspberry ...


6

I've been the graphics performance guy for a few big-name 3D iOS titles, so I completely feel your pain on this one. My experience has been that transparent pixels are the most expensive thing you can render on modern iOS devices. Your conjecture is right; the greater number of pixels on the iPhone4 really kills its performance in general, and transparent ...


6

This: http://30.media.tumblr.com/tumblr_m06qv6OREt1r2qjpao1_500.png is an example of a map I've done some time ago. I had a XML representing the map and different types of tiles. Each type would have a few attributes: Height Position Merge Type: Which kind of merging this tile would do, ALL (if it should merge to any tile around it), EQUAL (only merge with ...


6

glTranslatef glTranslatef translates (a special case of "transforming") the matrix corresponding to the currently selected matrix mode. So calling it after glMatrixMode(GL_MODELVIEW) means you transform the model-view matrix, and after glMatrixMode(GL_TEXTURE) you transform the texture matrix. See the Wikipedia article about translation matrices to learn ...


6

You are overwriting your vertex data by writing 3 floats but only incrementing the index once. You might want to change your loop to increment 3 at a time or multiplying by 3. for(int x=0;x<total_verts;x++) { vertices[x] = xCoord; // should be vertices[3*x] vertices[x+1] = yCoord; // should be vertices[3*x+1] vertices[x+2] = zCoord; // ...


6

See the paper in the GPU Gems series treating this subject: http://http.developer.nvidia.com/GPUGems/gpugems_ch01.html What you can do is to adapt that idea (Gerstner waves) and compute the normals for each of your rendered fragment. The way to do that would be to assign a water texture (without too much light information in it, since you're gonna compute ...


6

USE GLES2 AndEngine is a little tricky to get configured properly the first time you try. I recommend installing the version stored at RealMayo's github, which is a stable version. That's a version of GLES2 and yes, it's definitely worthwhile to use GLES2 over GLES1. Many new features were added that make life easier, improve performance, and add great ...


6

Instead of using an ImageView and transparent GLSurfaceView you should instead render your background using a fullscreen quad (just like you do with your sprites, but sized to fit the entire screen). Render this fullscreen background first (very important) and then also remove the gl.glClear(GL10.GL_COLOR_BUFFER_BIT); call in from onDrawFrame. You no longer ...


Only top voted, non community-wiki answers of a minimum length are eligible