Skip to main content
27 votes

Difference in glDrawArrays and glDrawElements

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*...
Maximus Minimus's user avatar
21 votes

What is the purpose of glScissor?

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 ...
tuket's user avatar
  • 485
10 votes
Accepted

OpenGL - texture releasing

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 ...
Maximus Minimus's user avatar
7 votes

Difference between "texture" vs "texture2d" in OpenGL ES?

texture2D is the same as texture, but it's used in the older versions of glsl. Between glsl 120 and 130 they changed the ...
Bálint's user avatar
  • 14.9k
7 votes
Accepted

Is Opengl 2.x still usable?

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 ...
Nicol Bolas's user avatar
  • 26.1k
6 votes
Accepted

Any fast alternative to sine in GLSL?

ATI made an announcement that the sine / cosine instructions in their newest GPUs now requires only a single clock cycle... in 2004! Modern GPUs in fact have special function units specifically for ...
Philipp's user avatar
  • 120k
5 votes
Accepted

How can I determine how widespread support of OpenGL ES 3 is?

The amount of how many devices support different APIs is usually easy to figure out by looking at public hardware stats of popular engines, such as unity and unreal. I recommend using multiple sources ...
Lasse's user avatar
  • 3,241
5 votes
Accepted

How to preserve EGL context when pausing Android ndk app

Introduction to terminology and description state transitions are in the Android Understand the Activity Lifecycle guide. There are basicaly three states: First state is CREATED, which is reported ...
Ivorne's user avatar
  • 201
4 votes

Shader FloodFill Alogrithm

The above method was not only outdated for 2017, but extra-ordinarily slow. There are dedicated algorithms to do what you're talking about on the GPU that take maximal advantage of GPU parallelism. ...
Krupip's user avatar
  • 1,763
4 votes
Accepted

OpenGL calculate UV sphere vertices

Let's start by generating all unique vertices. You can then decide whether to index those vertices, or copy them into strips/fans, depending on your needs. Here's some example code showing how to ...
DMGregory's user avatar
  • 135k
4 votes

OpenGL ES 2.0 Shadow Mapping - depth only FBO not working due to GL_FRAMEBUFFER_INCOMPLETE_ATTACHMEN

You will need to implement multiple alternative solutions depending on the GPU. Not only are there many choices (GL_DEPTH_COMPONENT16, GL_DEPTH_COMPONENT24, GL_DEPTH_COMPONENT32, ...
Stephane Hockenhull's user avatar
3 votes
Accepted

2D Collision in tilemap - ArrayOutOfBounds

For accessing the array i suggest you make a function like the following: ...
Greffin28's user avatar
  • 989
3 votes
Accepted

GL_CLAMP_TO_BORDER - OpenGL ES 3

GL_CLAMP_TO_BORDER became legal in GL ES 3.2 (link to specification), but may otherwise be available by one (or more) of the following extensions: GL_NV_texture_border_clamp ...
Maximus Minimus's user avatar
3 votes
Accepted

OpenGL ES 1.1: Is it more efficient to use glClear or use glDrawArrays with primitives that render over used frames?

It depends Sometimes glClear can be a signal to the driver and/or GPU that you're done with the prior contents of the framebuffer, which it can then use to optimize internally. Sometimes glClear ...
Maximus Minimus's user avatar
3 votes

GLSL wrong data read from attribute

Unreferenced variables are removed by compiler What you are seeing is a kind of compilation optimisation (Though strictly speaking it is not considered an optimization). When you declare inputs you ...
Blindman67's user avatar
2 votes

How to convert from OpenGL to OpenGL ES?

This Qt4 example has some information about porting from OpenGL to OpenGL ES: https://doc.qt.io/archives/qt-4.8/qt-opengl-hellogl-es-example.html
jcoffland's user avatar
  • 121
2 votes

Workaround to losing the OpenGL context when Android pauses?

Some of the answers here are reasonable for early uses of OpenGL ES on Android. The first GLES devices only supported a single context, so GLSurfaceView was designed to aggressively discard state. ...
fadden's user avatar
  • 381
2 votes
Accepted

OpenGL Regarding Frame/Buffer Caching

OpenGL doesn't specify this; individual implementations are allowed to cache data and/or results so long as the output is conformant with the specification. Note that this kind of caching is probably ...
Maximus Minimus's user avatar
2 votes
Accepted

OpenGL ES 2.0 Without The Use of Shaders

OpenGL ES 2.0 requires you to provide a set of shaders (vertex and fragment). Those examples use the old shader-less OpenGL ES. For an introduction use the old GLES1. Make sure you can draw ...
Stephane Hockenhull's user avatar
2 votes

Transparency in GLSurfaceView

...
Troy's user avatar
  • 121
2 votes

Can't understand why transformation doesn't work

Usually you should include more details than just "doesn't work" (symptoms, example input-output, etc), but here the errors are pretty obvious: Missing negative sign (for a rotation matrix, your ...
DMGregory's user avatar
  • 135k
2 votes
Accepted

Best way to add and remove quads in a VBO?

You don't need a dictionary for this, just use an infinite array (c++ - vector, java - arraylist, c# - list) and store an id in the order they can be found in the vbo. If you want to remove one of ...
Bálint's user avatar
  • 14.9k
2 votes

How can I determine how widespread support of OpenGL ES 3 is?

According to this wiki check... In June 2018, Apple deprecated OpenGL APIs on all of their platforms (iOS, macOS and tvOS), strongly encouraging developers to use their proprietary Metal API, which ...
thatGuy's user avatar
  • 25
2 votes
Accepted

Aligning a weapon model with a first-person camera

One old trick for FPS games is that the player's weapon is rendered separately. What that means in practice is that you render your scene in (at least) two parts: first the world, then the player ...
congusbongus's user avatar
  • 14.8k
2 votes
Accepted

Edit Part of a Texture

glTexSubImage2D will do exactly what you wish. Assume that you have already created the base texture: ...
Maximus Minimus's user avatar
2 votes

Would directly modifying vertex array be a good idea in 2D?

This is a micro-optimization. How would you modify the vertex array? Would you upload it to the card again from main memory? If so, that will be much slower than 4 vertices doing a matrix multiply in ...
user1118321's user avatar
  • 2,632
2 votes

How reliable is glLineWidth() for parameters greater than 1?

If the WebGL stats are anything to go by it looks like as of recently, 22% of all polled devices from WebGL stats data set only support a line width up to 1. Note that this data is skewed as OpenGL ES ...
Cobertos's user avatar
  • 1,644
2 votes

How reliable is glLineWidth() for parameters greater than 1?

Your question as posed is impossible to answer. How many drivers? Any answer will be wrong in a few months time as new devices come out. Assuming that you're trying to draw thicker lines, you can do ...
user1118321's user avatar
  • 2,632

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