Menu
  • HOME
  • TAGS

OpenGL: Strange bahaviour of VBO deletion?

c++,opengl,vbo,opengl-3,vao

Reto Koradi already mentioned copy semantics. Another thing to keep in mind is that OpenGL allows context sharing, i.e. some objects are shared between the OpenGL contexts and deleting in one context deletes it from all contexts. Objects transcending shared contexts are textures buffer objects that are bound using glBindBuffer...

OpenGL uniform samplerBuffer: what does it point to?

opengl,glsl,opengl-3

If I understand your question correctly, you are asking how aBuffer knows which buffer object to fetch texel memory from? aBuffer is a sampler (more precisely, a buffer sampler), and it has the value 0 in this example, so it refers to the buffer texture (GL_TEXTURE_BUFFER) that is currently bound...

Mesa + Linux : gl.h does not contain modern OpenGL

c++,linux,opengl,opengl-3

I checked the GL/gl.h, GL/glex.h and noticed that I have only got OpenGL 1.x methods in there. For GL/gl.h, that is actually how it is supposed to be. If you want to use OpenGL in a platform-independent manner, you can only rely on GL 1.1 being exported by the...

Objects placed inside classes to be rendered with OpenGL

c++,class,opengl,c++11,opengl-3

You have two problems that immediately come to mind: this->triangles.size() * sizeof(GLfloat) This problem will not affect anything because GLfloat has the same size as GLuint, but if that was not a typo, it indicates to me you may be thinking about the index buffer wrong. Make this triangles.size ()...

Rendering object causes heightmap not to calculate

c++,opengl-3,vertex-array-object,index-buffer

The problem I found was that I wasn't rebinding the heightmap texture in my draw function. It was only bound once when first created. This is why the heightmap rendered correct initially, then flattened for ever frame afterwards. So in the end, I just had to also put the same...

How to use VBOs without VAOs with OpenGL core profile?

c++,opengl,opengl-3,opengl-4

Using VAOs is required in the core profile. From the OpenGL 3.3 spec, page 342, in the section E.2.2 "Removed Features": The default vertex array object (the name zero) is also deprecated. This means that you can't set up vertex attributes without creating and binding your own VAO....

Why does glDrawBuffer generate a GL_INVALID_OPERATION?

java,opengl,jogl,opengl-3,msaa

I suspect that the error comes from an earlier call. At least there should be numerous errors, for example from the glBindFramebuffer() call immediately preceding the glDrawBuffer() call: gl.glBindFramebuffer(GL3.GL_READ_FRAMEBUFFER, multisampleFbo); checkGLError(); gl.glDrawBuffer(GL3.GL_BACK); // Throws GL_INVALID_OPERATION checkGLError("OpenGL error at glDrawBuffer: 0x%h%n"); multisampleFbo is not a framebuffer object. It was created like...

segmentation fault when using glUniformMatrix in combination with an array

c++,opengl-3

The problem is that the index used for glGetActiveUniform is inconsistent with the actual location for the specific uniform. uniform int arr[3]; uniform int arr2[3]; uniform int i; Here, the indices will be 0,1,2, because glGetActiveUniform will only count the first element in an array, here it will be arr[0]...

Draw Square With Polar Coordinates in OpenGL

c++,opengl,math,programming-languages,opengl-3

I found the solution. int n = 70; int i = 1; glBegin(GL_TRIANGLE_FAN);{ for (float tempAngle = 0.0 ; tempAngle <= 2 * PI ; tempAngle += PI/8) { radius = n * cos(tempAngle); x = baseX + radius * cos(tempAngle); y = baseY + radius * sin(tempAngle); if (i...

Go Lang OpenGL simple shape - blank screen

opengl,go,sdl-2,opengl-3,glew

I finally figured out what my problem was in this code. The first thing I had to do was positionAttrib := program.GetAttribLocation("vertexPosition_modelspace") for all the input variables going into the vertex shader. This was done after binding the VBO for each array. Next, If you notice my code above: gl.BufferData(gl.ARRAY_BUFFER,...

sampler2DRect vs samplerRect

shader,opengl-3

I think you're essentially correct; there's both an Nvidia extension and some ARB history involved here. In the earliest version of ARB_texture_rectangle, the specification referred to samplerRect and samplerRectShadow. You can see that this was changed in early 2005. I see references to samplerRect working on Nvidia cards circa 2005,...

OpenGL 3.3 glDrawArrays for triangles

c++,opengl,glsl,opengl-3

Try changing glPolygonMode to GL_LINE, that should do the trick.

Segmentation fault when trying to wrap glGenVertexArrays call in a method

c++,osx,opengl,opengl-3,sdl-2

std::unique_ptr<Graphics> g; g->createVAO(); Where do you actually populate g with something? Right now it looks like you're dereferencing a NULL pointer. Try this: std::unique_ptr<Graphics> g( new Graphics ); ...

Rendering integers to a separate texture in GLSL

opengl,glsl,opengl-3

Tack on another vertex attribute for the ID and pass that through to your fragment shader. You can set up Multiple Render Targets (MRT) to render your IDs out to another framebuffer attachment....

LWJGL Projection Matrix - Nothing Happens

java,lwjgl,vbo,opengl-3,projection-matrix

I'm making the assumption that model.getModel() will return the identity matrix (just like your view matrix is identity). In that case, you have the following situation: You draw a triangle in the plane z=1.0. If you use identity as projection matrix also, you directly draw in clip space, and the...

How to draw TRIANGLE_FAN with geometry shader created coordinates? (GLSL 3.3)

opengl,opengl-3,geometry-shader

Outputting fans in a Geometry Shader is very unnatural as you have discovered. You are currently outputting the vertices in fan-order, which is a construct that is completely foreign to GPUs after primitive assembly. Fans are useful as assembler input, but as far as output is concerned the rasterizer only...

illegal vector field selection length

vector,glsl,opengl-3,variable-length

The problem is exactly what the error message says: Illegal vector field selection length The only line where you try to use length as a field selector is this one (line break added): float cosine = dot(cameraSpacePosition, cameraSpaceNormal) / (cameraSpacePosition.length * cameraSpaceNormal.length); This usage of length is invalid. There are...

glPolygonMode(GL_FRONT_AND_BACK, GL_LINE) vs. glDraw*(GL_LINE_STRIP…)

opengl,deprecated,glfw,opengl-3

Ad 1: Both methods are perfectly fine in OpenGL Core profile. Ad 2: I'm not sure about this, but I guess that there will not be a huge performance difference. Ad 3: This methods exist because one might also want to draw line objects that are not composed from triangles....

OpenGL drawing several objects

c++,opengl,vbo,opengl-3

It looks like you misunderstood the implications of binding a buffer, and the correct sequence of calls. You expected that in this sequence, the draw call would get its vertices from the VBO with id m_VBO: glBindBuffer(GL_ARRAY_BUFFER, m_VBO); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_IBO); glDrawElements(GL_TRIANGLES, (size-1)*(size-1)*6, GL_UNSIGNED_INT, 0); That's not the way it works....

VAO vs Manual Binding of VBO's and IBO

c++,opengl,opengl-3

It is going wrong here: glBindBuffer(GL_ARRAY_BUFFER,vbo[0]);//Position Buffer glBindBuffer(GL_ARRAY_BUFFER,vbo[1]);//Colour Buffer glEnableVertexAttribArray(0); glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, 0); glEnableVertexAttribArray(1); glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 0, 0); This has nothing to do with VAOs at all, and would fail without VAOs the same way. When switching to VAOs, you also seem to have switched...

Are OpenGL indices and locations the same thing for uniforms and vertex attributes?

opengl,opengl-es,opengl-es-2.0,opengl-3,opengl-4

In your first case, the location for an Uniform is different from the index used for glGetActiveUniform(). For glGetActiveUniform() case, index is just a value between 0 and the value you get from glGetProgram( GL_ACTIVE_UNIFORMS,...) minus one. This API allows you to query any resources of the program, and you...

Porting OpenGL ES Framebuffer to OpenGL

opengl,opengl-es-2.0,opengl-3

If you don't want to render to any color buffers, you need a call that specifies that: glDrawBuffer(GL_NONE); This is per framebuffer state, so it needs to be called while the FBO is bound. If you miss this, you will get the error you're seeing, as specified for the error...

GLM functions not working

c++,opengl,glm,opengl-3

At least in the current version of glm (0.9.6) there is no glm::scale function taking three floats as argument. There is only one overload that takes a matrix which should be scaled a vector containing the scaling factors. The correct solution for your code sample would (according to here) be...

Modern GLSL ( opengl 3+ ) : Implementing phong effect correctly;

glsl,opengl-3

try this: void main() { vec4 texread = texture2D(diffuse, texCoord0); vec3 normal = normalize(normal0); vec3 material_kd = vec3(1.0,1.0,1.0); vec3 material_ks = vec3(1.0,1.0,1.0); vec3 material_ka = vec3(0.2,0.2,0.2); vec3 material_ke = vec3(0.0,0.0,0.0); float material_shininess = 60; vec3 lightpos = vec3(0.0,10.0,5.0); vec3 lightcolor = vec3(1.0,1.0,1.0); vec3 lightdir = normalize(lightpos - worldPosition); float shade...

Opengl best texture compression format on desktop nowadays

format,compression,textures,opengl-3,opengl-4

Seems you already did a deep research about compression formats available. Here goes my 2cents contribution: Most compressed formats are lossy. I guess only GL_OES_compressed_paletted_texture are not lossy, but it only supports 16 or 256 colors and there are some concerns about performance. It's supported by Adreno GPUs, as well...

What is the difference between GL_QUERY_BY_REGION_WAIT and GL_QUERY_WAIT

opengl,glsl,opengl-3

The primary difference is that QUERY_BY_REGION adds an extra test to this. It stipulates that on top of conditionally rendering, parts of the result of any conditional render may be discarded if they occur outside of the region covered by the original query. OpenGL 4.4 Core Profile Specification - 10.10...

How to draw polygon with 3D points in modern openGL?

opengl,opengl-3

1) You have to define an array of vertices, that contain the points of your polygon lines. Like in your example: GLfloat vertices[] = { 20.0f, 150.0f, 0.0f, 1.0f, 220.0f, 150.0f, 0.0f, 1.0f, 200.0f, 160.0f, 0.0f, 1.0f }; 2) You have to define and bind a Vertex Buffer Object (VBO)...

Issue when drawing on a render texture. (OpengGL 3.3)

c++,opengl,opengl-3

You do not supply texture coordinates for your quad rendering. Also your code comments suggest that you set the attribute locations explicitely via the layout qualifier in the GL code, but you do not do that, so the mapping between the attribute variables and locations are undefined or at least...

Problems passing OpenGL 3.0 uniforms through multiple classes

c++,opengl,shader,opengl-3,light

It had to do with the fact that as PointLight and SpotLight were derived from DirectionalLight, they (the PointLight and SpotLight objects) would get casted to their base class, removing their "special attributes" and when I would do light.bindLight(shader); it would call the directionalLight's bindLight function. I solved it by...