spot7.org logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML Categories
  Home » OPENGL » Page 1
mouse movement with glut
There are multiple coordinate systems in openGL, screen coordinate, eye coordinate, world coordinate, ... The x and y you get from the mouse callback function are referring to the screen coordinates, which starts from (0,0) from the upper-left corner of the window. The camera, on the other hand, works on a different level. You didn't mention which version of OpenGL you are using ... but anyway

Categories : Opengl

Mathematical view of z-fighting
To get from object space ("local coordinate system") you have to take the model (object-to-world) and view (world-to-eye) transformations into account. Usually, these are affine transforms described by some matrices. The model and view transform might be composed to a modelView matrix, since the world space is not explicitely needed. And that is the way the old GL fixed-function pipeline worked.

Categories : Opengl

GLSL compilation error #132
OpenGL does not load files for you, it does not even know about the concept of files at all. glShaderSource expects the source code as a string (or a series of separate strings). You just provide a file name, which is now interpreted as GLSL source code, and of course is not a valid program. Note that the arcsynthesis tutorial comes with full source code, so there is no need to improvise anything

Categories : Opengl

GLUI controls do not appear but they have effect
Could it be, that you created a OpenGL-3 core profile context? GLUI uses functionality deprecated in OpenGL-3 and unless you have a compatibility context it will not work at all. Also remember, that GLUI doesn't know shaders, so if you use shaders, remember to disable them after you're done using them, otherwise GLUI ends up trying to work the fixed function pipeline… fruitlessly.

Categories : Opengl

GLSL Multitexturing Only Shows Texture 0
The glBindSampler() calls in the original code are not correct: glBindSampler(0, glGetUniformLocation(shader_id, "mytex[0]")); The second argument for this call must be the name of a sampler object, not a uniform location. Sampler objects are a feature introduced in OpenGL 3.3, and provide a mechanism to sample the same texture with multiple sets of sampling attributes. To use glBindSampler(),

Categories : Opengl

Textures messed up when building from the libgdx source code
Your binaries are probably not in sync with the code. Run ant -f fetch.xml and copy the required .so files to your android project, replacing the old ones. If that doesn't help then download the natives jars and .so files (in the armeabi folders) from here: http://libgdx.badlogicgames.com/nightlies/dist/ and manually replace the current ones with those. See also: https://github.com/libgdx/libgdx/w

Categories : Opengl

How fragment shader determines the number of fragments from vertex shader output?
You're talking about the step in rasterization known as scan-conversion. The GPU takes the positions generated by your vertex shader and interpolates their attributes to produce the fragments that are passed to your fragment shader. So yes, it is essential for you to set gl_Position in the vertex shader. After converting the coordinates of a triangle to window coordinates, scan conversion takes t

Categories : Opengl

Artifacts rendering high-poly procedural meshes with OpenGL
There is an inconsistency in the units used for the index buffer size. In the AddVertices() method, this calculates the size in bytes: _indicesSize = indices.size() * sizeof(GLuint); It is then used correctly later in the same method as an argument to glBufferData(), which does need the size in bytes: glBufferData(GL_ELEMENT_ARRAY_BUFFER, _indicesSize, &indices[0], GL_STATIC_DRAW); But i

Categories : Opengl

Render multiple objects in OpenGL
Firstly a VBO is just a collection of vertices that is stored in your video card memory. You can use a single VBO and model matrix to transform it, you can also apply different shaders and textures on top of it. This is best explained with a 2D game in mind where every graphic is basically a quad; 4 vertices. Would you really need to flood your video card memory with repeated allocations for a

Categories : Opengl

Branching on uniform vs texture lookup
The shader compiler is free to optimize the first to vec3 val = texture(tex, texcoord).rgb * sign(abs(uform)); which is also branch-less. However it is not guaranteed to do so. So on a sufficiently optimizing driver the difference will be minimal. Though some compiler can optimize the flow if it is all dependent on uniforms. What will happen is the the driver will recompile and reoptimize th

Categories : Opengl

Parralax mapping does not work correctly using OpenGL and GLSL
The single textOffset method is an early parallax technique which makes a very large approximation: that the depth at the offset will be the same. That's why the effect might just look a bit strange. I think in your case one of the tangent vectors is facing the wrong way. As a test, try negating textOffset.x or textOffset.y. I'm more used to seeing shaders use eye-space before the jump to tangent

Categories : Opengl

std140 and bool alignment
GLboolean is an altogether different type from bool in GLSL. The smallest scalar data type in GLSL is 32-bit, so everything is aligned to some multiple of 4-bytes. For anything smaller than 32-bit you generally want to pack and unpack an integer or floating-point value yourself, so I would consider using a uint instead. You can store 32 bool values in one uint if you do the packing yourself.

Categories : Opengl

How to rotate a cone around a line?
you only need 1 rotate call void rotate_around_line(GLdouble x0, GLdouble y0, GLdouble z0, GLdouble u1, GLdouble u2, GLdouble u3, GLdouble kut) { double vek[3] = { u1 - x0, u2 - y0, u3 - z0 }; glTranslatef(x0, y0, z0); glRotatef(-kut, vek[0], vek[1], vek[2]); glTranslatef(-x0, -y0, -z0); } the last 3 parameters of glRotatef form the axis around which you want to rotate.

Categories : Opengl

Cannot create more than one VAO
In code that you provided I see nothing that can cause such a behaviour. Maby you should provide your entire solution that is connected with your rendering for better understanding what is going on in your program? By the way: if you already defined glVertexAttribPointer() for your buffor you don't have to do it every time you update the data you stored in your vertexCoordBufferID if of course yo

Categories : Opengl

Drawing to different size FBO
You need to call glViewport() with the size of your render target. The only time you can get away without calling it is when you render to the window, and the window is never resized. That's because the default viewport matches the initial window size. From the spec: In the initial state, w and h are set to the width and height, respectively, of the window into which the GL is to do its render

Categories : Opengl

Is glmultmatrixf hardware accelerated?
what you are seeing is that draw elements calls in test2 and test3 will be the bottleneck over the matrix manipulations of test1. Doing a just matrix multiplication is actually pretty cheap (a few dozen multiplications and additions), the biggest cost with test1 will be the glRotate which requires getting the cosine and sine of the angle you want to rotate with.

Categories : Opengl

Shadow Mapping with Deferred Renderer (OpenGL 4.1, GLSL)
One issue I can see is a difference between linear and hyperbolic depth. It looks like your "Linear Depth (F32)" G-buffer depth is actually hyperbolic, which is fine because the code expects this. However the light's depth is in fact linear but is then compared against the clip space depth after perspective divide. It'd probably be easiest to just make the light buffer's depth hyperbolic (gl_Frag

Categories : Opengl

Getting maximum/minimum luminance of texture OpenGL
For downsampling, all you need to do in the fragment shader is multiple texture lookups, then combine them for the output fragment. For example, you could do 2x2 lookups, so each pass would reduce the resolution in x and y by a factor 2. Let's say you want to reduce a 1024x1024 image. Then you would render a quad into a 512x512 image. Set it up so your vertex shader simply generates values for x

Categories : Opengl

What's the purpose of glVertexPointer?
The first way is the modern, generic way of sending attributes. The second one is older, where vertices, normals, colors etc. had their own hard-coded attributes. It should not be used in modern code.

Categories : Opengl

Precision of glReadPixels when reading unsigned int
Ok i found the error: This is the correct command to clear the buffer: glClearBufferuiv(GL_COLOR, colorbufId, &UNDEF_IDX); glClear( /*GL_COLOR_BUFFER_BIT |*/ GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT );

Categories : Opengl


Recently Add
calculate light volume radius from intensity
mouse movement with glut
Mathematical view of z-fighting
GLSL compilation error #132
GLUI controls do not appear but they have effect
GLSL Multitexturing Only Shows Texture 0
Textures messed up when building from the libgdx source code
How fragment shader determines the number of fragments from vertex shader output?
Artifacts rendering high-poly procedural meshes with OpenGL
Render multiple objects in OpenGL
Branching on uniform vs texture lookup
Parralax mapping does not work correctly using OpenGL and GLSL
std140 and bool alignment
How to rotate a cone around a line?
Cannot create more than one VAO
Drawing to different size FBO
Is glmultmatrixf hardware accelerated?
Shadow Mapping with Deferred Renderer (OpenGL 4.1, GLSL)
Getting maximum/minimum luminance of texture OpenGL
What's the purpose of glVertexPointer?
Precision of glReadPixels when reading unsigned int
© Copyright 2017 spot7.org Publishing Limited. All rights reserved.