Hot answers tagged

24

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


19

Replica Island has a modified version of GLSurfaceView that deals with this issue (and works with earlier Android versions). According to Chris Pruett: Basically, I hacked up the original GLSurfaceView to solve a very specific problem: I wanted to go to different Activities within my app without throwing all of my OpenGL state away. The major ...


19

Alas, not one of the answers so far is both complete and fully correct. Really, OpenGL-ES does two things OpenGL does not: 1) it strips down and then extends OpenGL APIs to make it suitable for a mobile platform. That is, first they strip out APIs and features you really don't need, and are burdensome for mobile implementations, such as rendering polygons ...


18

OpenGL ES 2.0 supports Point Sprites; i use them for particles. Just use glDrawElements with GL_POINTS. In vertex shader, you set the size with gl_PointSize and use gl_PointCoord in fragment shader for texture mapping. My vertex shader: uniform mat4 uMvp; uniform float uThickness; attribute vec3 aPosition; attribute vec2 aTexCoord; attribute vec4 ...


16

Shaders of any complexity aren't generally the kind of thing you can download and drop in to your project like interchangeable cogs. Typically the more interesting effects require a fair bit of coupling to the CPU-side rendering subsystem in order to achieve their results. The same is generally true of performance -- performance tradeoffs with respect to ...


16

Before understanding what is the world or eye space, what is a space? In an abstract sense, a geometrical space (e.g. Euclidean Space) is a boundless extent where objects tend to exist. The space defines basic properties that objects living in this space should satisfy. For example in euclidean space distance is defined as Sqrt( vector dot product with ...


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


15

Try this: highp int index = int(indexf); I found it here.


14

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


14

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

What you are looking for is called a billboard or projective sprite. A billboard is basically a quad that always faces the camera. If you don't need it to always face the camera then the code/math will be much simpler. You can read more about how to implement them here: http://www.lighthouse3d.com/opengl/billboarding/index.php3?billCyl ...


12

In my OpenGL ES 2.X engine, i compute the MVP matrix (Model View Projection) on CPU Side and inject it in vertex shader. The Orthogonal projection is a 4*4 matrix. When i have the MVP, i inject it in the vertex shader with: mMvpLoc = getUniformLocation("uMvp"); glUniformMatrix4fv(mMvpLoc, 1, false, mMvp.pointer()); The mMvp is my matrix 4*4 on CPU ...


12

Not much, but at least a couple of basic shaders to get started with can also be found between my open sorce engines files: general stuff specialized stuff the .vsh files contain the vertex shaders and the .fsh files the fragment shaders, but I guess thats selfexplaining... On current mobile hardware, you should do as much as possible within the vertex ...


11

OpenGL ES (Embedded Systems) is a stripped down version of OpenGL. There are a lot of differences between those two and if you want to go way into the details, then you can read this 128 specification paper. But ES is a subset of OpenGL so all ES apps work on non ES systems but not the opposite. There is no one place where you can easily define what is in ...


11

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


10

In such highly dynamic environment, such as computer game scene is, what is the point of using VBOs, if the VBOs would need to be constructed on per-frame basis anyway? If you are reconstructing the vertex data for every object every frame, you're doing it wrong. Or at least, you're probably doing it inefficiently. Moving objects in a scene ...


10

Here's what I would do. Step 1: Don't sort. Just do it. See if it's a problem. Most likely isn't. Step 2: Limit particles into such that do not really need sorting, such as: Just solids (with possibly alpha-to-coverage edges) let zbuffer take care of the sorting. Just additive bits a+b = b+a, so order doesn't matter Step 3: if more is needed, ...


10

This is easily done. Set the view transform to orthographic for the 2D stuff, and render it. Then, before clearing the framebuffer, draw the effects with a perspective projection. The projection will only effect the geometry drawn after it, so just set the desired mode prior to drawing. This is the same way we handle HUDs in our FPS. :) The only ...


10

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


10

glm::quat myquaternion = glm::quat(glm::vec3(angle.x, angle.y, angle.z)); Where angle is a glm::vec3 containing pitch, yaw, roll respectively. PS. If in doubt, just go to the headers and look. The definition can be found in glm/gtc/quaternion.hpp: explicit tquat(tvec3<T> const & eulerAngles) { tvec3<T> c = glm::cos(eulerAngle * ...


9

The WebGL wiki contained a section in its FAQ hierarchy for "WebGL and OpenGL Differences" which seems to focus on differences in WebGL from "desktop" OpenGL implementations and, alas, isn't very detailed (mostly it's about behavior, not the API). If that does not go into enough detail for you, you may need to compare the latest WebGL draft with the OpenGL ...


9

Have you checked the latestp WebGL draft? According to the draft in case of a contradiction, the OpenGL ES 2.0 specification is the final authority. Chapter 6 outlines the differences from OpenGL ES 2.0 to WebGL. http://www.khronos.org/registry/webgl/specs/latest/


9

What you'd need to do to "bend" an object is to apply some appropriate combination of translation/rotation/scaling to only some subset of the vertices of the object in question -- probably weighting that transformation accordingly. Doing this is a pleasant-looking fashion will necessitate using more vertices than may be otherwise strictly necessary to ...


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


9

OpenGL ES 2.0 is very different from ES 1.1. You don't have a fixed-function pipeline anymore, so your familiar "push matrix, translate, rotate", etc are all gone. Instead, you have the concept of shaders: vertex and fragment. They're little programs that get executed for each vertex and each pixel. That's where all the transformation and other effects ...


8

Eigen is a C++ header only math library that supports SSE, AltiVec and ARM Neon vectorisation.


8

From the glOrtho doc, with values substituted: 2 ------------ 0 0 -1 XSize 2 0 ------------ 0 1 - Ysize 0 0 -2 -1 0 0 0 1 Store this ...


8

The range of the values written to the depth buffer are whatever you want them to be. Typically they fall in the 0-to-1 range. The actual value that is written in to the depth buffer is computed during the viewport transformation, based on the Z value of vertex in NDC space (after the perspective divide by w in clip space). The NDC depth value (Z, after ...


8

Since you have the replay system in place, I'd suggest you only store the replay-data during gameplay and then render a video from that replay offline. Eg. after the game has finished and the user chooses to post the replay as video, then you would render the video from the replay-data (by playing the replay and using glReadPixels).



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