47

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 ...


15

The difference is only semantic. Any GLSL vector can be accessed using x/y/z/w, r/g/b/a or s/t/p/q. Typical use is: xyzw for space coordinates rgba for colours stpq for texture coordinates if none of the above applies, any flavour can be used, but when it could be confusing, var[0]/var[1]/var[2]/var[3] can be used instead. You can mix them in expressions: ...


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. ...


15

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) ...


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

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 ...


12

This looks like a case of not drawing with a premultiplied alpha texture correctly. Here's a few helpful links on the subject: http://www.youtube.com/watch?v=dU9AXzCabiM http://blogs.msdn.com/b/shawnhar/archive/2009/11/06/premultiplied-alpha.aspx If you search for "premultiplied alpha" and iOS you might find a direct solution to your problem. I suspect it ...


12

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

might snatch some of the arcane knowledge from here http://glslsandbox.com/


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

For the actual math of warping, this can get very complicated, why don't you start here?. I'll now talk about how you can apply this, assuming you've already got the math for how you will do your deformations down. 2 ways: 1) Every frame, visit every vertex in the cylinder model and offset it in some way. 2) Offset the vertices in the vertex shader as ...


9

You should have a shader pool where all shaders are stored. Once the pool is filled, objects are bound with these shaders (think "bound" as object-references-shader.) Many SceneObjects could share the same shader object (be it OOP or whatever) and only access it by referencing the shader in the pool. Then, for each SceneObject, you just set the attribs/...


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 ...


8

What you're trying to achieve is basically a subset of the topic of mesh deformation. But since you're a begginer, I'm afraid this type of information might be a bit too strange for now. I'll try to lay down the basic notions though. In order to do this you'll need two things: Your mesh needs to have enough vertices for you to transform. For instance if it'...


8

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

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

No. When iOS 4 was introduced, the app store introduced a new rule: "You can't upload binaries which deploy for iOS 2.x". This sent a clear message that Apple doesn't want to have users nor developers trailing in firmware updates. Since today (depending on where you live on the globe) Apple is expected to announce iOS 5, the app store will likely disallow ...


7

< rant > I spent a huge amount of time on this problem, I tried many different solutions and none worked until today, I think this is one of the most awful design decision I even seen, but coming from the Android team I'm not really surprised. < /rant > So, the solution is to move the eglContext member upwards and make it static (global) so it won't ...


7

If you have no or little experience with OpenGL, I would not suggest 2.0. With OpenGL ES 2.x, you will have to write your own routines for matrix manipulation and write your own shaders. This is a lot of work, a lot can go wrong, and debugging a lot of these things is very painful. Only if you think you'll need some of the features that OpenGL ES 2.0 has ...


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

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

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

Just don't write to the depth buffer when rendering the particles. This will allow them to all be rendered and blended with each other. You should still perform depth testing though so that they can be properly occluded by geometry in the scene.


6

This is most presumably the garbage collector kicking in. There is no clean way to solve this problem unless you are willing to ditch Java for another language such as C++. See How can I avoid garbage collection delays in Java games? (Best Practices) for a few hints on how to mitigate the problem.


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