Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I'm having trouble running example from: https://raw.github.com/progschj/OpenGL-Examples/master/07geometry_shader_blending.cpp My graphics card supports only #130 shaders version so I have to rewrite shaders.

I figured out how to fix vertex and fragment shaders. I removed:

layout(location = 0)

from

layout(location = 0) in vec4 vposition;

and added this into my source code:

glBindAttribLocation(shader_program, 0, "vposition");

However I have no idea how to rewrite geometry shader...

#version 130
uniform mat4 View;
uniform mat4 Projection;
layout (points) in;
layout (triangle_strip, max_vertices = 4) out;
out vec2 txcoord;
void main() {
   vec4 pos = View*gl_PositionIn[0].gl_Position;
   txcoord = vec2(-1,-1);
   gl_Position = Projection*(pos+vec4(txcoord,0,0));
   EmitVertex();
   txcoord = vec2( 1,-1);
   gl_Position = Projection*(pos+vec4(txcoord,0,0));
   EmitVertex();
   txcoord = vec2(-1, 1);
   gl_Position = Projection*(pos+vec4(txcoord,0,0));
   EmitVertex();
   txcoord = vec2( 1, 1);
   gl_Position = Projection*(pos+vec4(txcoord,0,0));
   EmitVertex();
}

The main problem is how to get rid of location here:

layout (points) in;
layout (triangle_strip, max_vertices = 4) out;

Can someone help me?

EDIT: @melak47 - I edited shader, now I'm not getting any error, but window is black.

#version 130
#extension GL_EXT_geometry_shader4 : enable
precision mediump float;
uniform mat4 View;
uniform mat4 Projection;
out vec2 txcoord;
void main() {
    vec4 pos = View*gl_PositionIn[0];
    txcoord = vec2(-1,-1);
    gl_Position = Projection*(pos+vec4(txcoord,0,0));
    EmitVertex();
    txcoord = vec2( 1,-1);
    gl_Position = Projection*(pos+vec4(txcoord,0,0));
    EmitVertex();
    txcoord = vec2(-1, 1);
    gl_Position = Projection*(pos+vec4(txcoord,0,0));
    EmitVertex();
    txcoord = vec2( 1, 1);
    gl_Position = Projection*(pos+vec4(txcoord,0,0));
    EmitVertex();
};
share|improve this question
    
try simply removing those two lines, adding #extension GL_EXT_geometry_shader4 : enable, and replacing gl_PositionIn[0].gl_Position with gl_PositionIn[0]. Maybe you will also have to add gl_FrontColor = gl_FrontColorIn[0]; –  melak47 Jul 28 '12 at 20:13

1 Answer 1

Your graphics card most likely does not support geometry shaders, which require GLSL 1.50 or higher. Geometry shaders were added in OpenGL 3.2, which is the version that supports GLSL 1.50. GLSL 1.30 is part of OpenGL 3.0 which did not support geometry shaders.

I assume you are using a pre-Sandy-Bridge Intel GPU or are on Linux. Intel's drivers are complete crap before the Sandy Bridge and they don't update their older drivers at all. Linux's standard GPU drivers do not yet support geometry shaders, so you'd need to install the proprietary NVIDIA/AMD drivers if you want geometry shaders.

Update: the Asker's problem was out of date drivers. Especially with OpenGL, always keep Windows drivers up to date. OpenGL support tends to lag heavily, and also tends to be buggy. I've shipped more than a few OpenGL games that had support nightmares on Windows thanks to the drivers. If you're only targetting Windows, consider D3D. If you're multi platform, consider supporting both D3D and OpenGL if you have the time/money/manpower.

share|improve this answer
    
You are right. My Radeon HD4570 doesn't support GLSL 1.40/1.50. –  Ziem Jul 28 '12 at 21:50
2  
... It should. If you're on Wibdows, upgrade your drivers. –  Sean Middleditch Jul 28 '12 at 22:26
    
@Ziem: My Radeon HD3300, an integrated motherboard GPU, supports GL 3.3 just fine. Even on Linux. –  Nicol Bolas Jul 28 '12 at 22:34
1  
The proprietary Linux drivers support everything the Windows drivers do, with a few corner case exceptions. The FOSS drivers are only at GL 3.0, and then only if you compile in some patented features that are disabled by default. OSX might also be an issue - it supports GL 3.2, but only if you use Core Profile / forward compatibility when crating the GL context. If you don't, you might be limited to older versions of GL (not sure which off the top of my head). –  Sean Middleditch Jul 29 '12 at 0:24
1  
I thought that I had the newest drivers, but I was wrong... I installed AMD Catalyst and updated drivers and voila - everything is working. According to OpenGL Extensions Viewer, my graphics card supports 3.3 and #330 GLSL. Thanks you all for help! –  Ziem Jul 29 '12 at 9:38

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.