glsl

Opengl error 1281 when trying to glUseProgram

痞子三分冷 提交于 2019-12-05 20:11:18
Any ideas how I could debug this opengl error further? 1281 I'm loading source from files, compiling, linking and then trying to check for errors after glUseProgram In my object's draw method .. log.info(gl2.glIsProgram(shaderProgram)); // true gl2.glUseProgram(shaderProgram); int error; while ((error = gl2.glGetError()) != GL2.GL_NO_ERROR) { throw new RuntimeException("glUseProgram" + ": glError " + error); } Output .. [13:38:08] INFO (IARectangle.java:99) - true java.lang.RuntimeException: glUseProgram: glError 1281 This is how I load my shader source, from .glsl files .. Vector<Integer>

GLSL: “Invalid call of undeclared identifier 'texture2D'”

蓝咒 提交于 2019-12-05 19:44:32
问题 I'm on a Mac, using Swift, and using OpenGL 3.2. I'm also using XCode 6.1 Beta so I suppose that's the most likely explanation, because it doesn't seem to me like this makes sense. I can't find any evidence that this shouldn't be supported, but this fragment shader is resulting in the error Invalid call of undeclared identifier 'texture2D' during compilation: #version 150 uniform sampler2D usTexture; in vec2 vTextureCoord; out vec4 FragColor; void main() { vec4 color = texture2D(usTexture,

Issue getting gradient square in glsl es 2.0, Gamemaker Studio 2.0

大兔子大兔子 提交于 2019-12-05 18:38:47
I made a triangle list with 4 triangles, having the middle point a different color. And then aim to combine the triangles to get a nice gradient. But the edges of the triangles create unwanted lines, I don't want these lines I want it to be smooth al the way. How can I get the desired result? Images: Shader Code: // Simple passthrough vertex shader // attribute vec3 in_Position; // (x,y,z) attribute vec4 in_Colour; // (r,g,b,a) attribute vec2 in_TextureCoord; // (u,v) varying vec2 v_texcoord; varying vec4 v_colour; void main() { vec4 object_space_pos = vec4( in_Position.x, in_Position.y, in

How to copy depth buffer to a texture on the GPU?

ε祈祈猫儿з 提交于 2019-12-05 18:21:22
问题 I want to get the current depth buffer to a texture, to access it in a shader. For various reasons I can't do a separate depth pass, but would need to copy the already-rendered depth. glReadPixels would involve the CPU and potentially kill performance, and as far as I know glBlitFramebuffer can't blit depth-to-color, only depth-to-depth. How to do this on the GPU? 回答1: The modern way of doing this would be to use a FBO. Attach a color and depth texture to it, render, then disable the FBO and

Where can I find documentation on the OpenGL shader function texture2DRect()?

你。 提交于 2019-12-05 17:38:24
I'm normally a self-sufficient Googler, but I can't find any documentation on the OpenGL shader function texture2DRect() . Has anyone come across this before? It's being used in some sample code for writing shaders in openframeworks, so I know it exists, and it works, just can't find any official docs on it. Where can I learn more about this function? That function is used to sample a 2D Texture Rectangle (A NPOT texture target), and it's specified in "Additions to version 1.10.59 of the OpenGL Shading Language specification" of the GL_ARB_texture_rectangle extension .: Add to section 8.7

Picking triangles in OpenGL core profile when using glDrawElements

ぃ、小莉子 提交于 2019-12-05 17:13:22
I am drawing a mesh of triangles using glDrawElements and would like to be able to pick/select a triangle using the mouse click. The mesh of triangles can be very big. In fixed-function OpenGL there is the possibility of using GL_SELECT: http://content.gpwiki.org/index.php/OpenGL:Tutorials:Picking .. However I am only interested in using OpenGL core profile. Another possibility would be to use 'color coding': http://www.lighthouse3d.com/opengl/picking/index.php?color1 http://www.opengl.org/resources/faq/technical/selection.htm .. but as far as I know its not possible to indicate per triangle

Ping-pong rendering between two FBOs fails after first frame.

送分小仙女□ 提交于 2019-12-05 14:36:00
I am trying to create two FBOs and implement a ping-pong render. But, I only get the first frame to work properly. I am trying to simulate a game-of-life and, after the first frame, I only get a black screen. Could you help me check it? I have spent hours on this issue. Edit Maybe I didn't describe clearly. Actually, I want to use the textureB as the texture and render it to textureA, then use the textureA to render to screen, then vice versa. Edit I can see the first frame, which is the textureB. After it go through the fragment shader, it become black. At first, I suspect the fragment shader

Vertex shader with array inputs

倾然丶 夕夏残阳落幕 提交于 2019-12-05 13:40:06
Given a vertex shader that looks something like #version 400 compatibility const int max_valence = 6; in int valence; in vec3 patch_data[1 + 2 * max_valence]; ... What is the the proper way to map the data to the correct vertex attribs? I'm trying to use a VBO, but I can't figure out how to pass that large of a value in. glVertexAttribPointer takes at most a vector of size 4. What's the correct way to get the vertex attributes into the shader? Arrays of vertex attributes are legal in OpenGL. However, each member of the array takes up a separate attribute index. They are allocated contiguously,

AlphaFunctions in WebGL?

只愿长相守 提交于 2019-12-05 13:21:42
Is it possible to achieve an transparency effect where fragments with alpha lower than 0.5 are discarded and fragments with alpha higher than 0.5 are rendered rendered opaque? From what I've read, glEnable(GL_ALPHA_TEST); glAlphaFunc(GL_GREATER, 0.5); would be what I'm looking for but unfortunately, AlphaFunction is not defined in WebGL. Is there a workaround? My problem is, that transparent fragments write into the depth buffer and thus prevent farther fragments from beeing rendered: alpha_error http://gebackene-ente.at/nudelsalat/sonstiges/pointcloud_alphaerror.jpg Sorting is not an option

for-loop in shader code working with hardcoded number but not with uniform variable

[亡魂溺海] 提交于 2019-12-05 13:17:38
I asked for help about an OpenGL ES 2.0 Problem in this question . What seems to be the answer is very odd to me. Therefore I decided to ask this question in hope of being able to understand what is going on. Here is the piece of faulty vertex-shader code: // a bunch of uniforms and stuff... uniform int u_lights_active; void main() { // some code... for ( int i = 0; i < u_lights_active; ++i ) { // do some stuff using u_lights_active } // some other code... } I know this looks odd but this is really all code that is needed to explain the problem / faulty behavior. My question is: Why is the