2

Here is my include and the code that is causing me distress:

#include <iostream>
#include <vector>
#include <OpenGL/gl.h>
#include <OpenGL/glu.h>
#include <GLUT/glut.h>

using namespace std;

GLuint CreateShader(GLenum eShaderType, const std::string &strShaderFile)
{
    GLuint shader = glCreateShader(eShaderType);
    const char *strFileData = strShaderFile.c_str();
    glShaderSource(shader, 1, &strFileData, NULL);

    glCompileShader(shader);

    GLint status;
    glGetShaderiv(shader, GL_COMPILE_STATUS, &status);
    if (status == GL_FALSE)
    {
        GLint infoLogLength;
        glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &infoLogLength);

        GLchar *strInfoLog = new GLchar[infoLogLength + 1];
        glGetShaderInfoLog(shader, infoLogLength, NULL, strInfoLog);

        const char *strShaderType = NULL;
        switch(eShaderType)
        {
            case GL_VERTEX_SHADER: strShaderType = "vertex"; break;
            case GL_GEOMETRY_SHADER: strShaderType = "geometry"; break;
            case GL_FRAGMENT_SHADER: strShaderType = "fragment"; break;
        }

        fprintf(stderr, "Compile failure in %s shader:\n%s\n", strShaderType, strInfoLog);
        delete[] strInfoLog;
    }

    return shader;
}

That was the only way I could think of pointing out that crucial bit of code. (I am new to SO)

I am learning from a tutorial so besides the altered includes and the namespace, this is not my code.

Anyway, I am using Xcode to learn about using OpenGL in C++ and it is telling me that I am using an undeclared identifier GL_GEOMETRY_SHADER ... I have coded using OpenGL in java before so to me this seems really strange as GL_GEOMETRY_SHADER should be identified along with its vertex and fragment counterpart, which do not cause any problems. Any help would be appreciated.

(As an aside that I don't think warrants an entire question of its own since I simply opted to not use the function, glutExitMainLoop(); is not defined either)

Thank you

bames53
  • 86,085
  • 15
  • 179
  • 244
Jokull Reynisson
  • 35
  • 1
  • 1
  • 5
  • 2
    Geometry shaders are a OpenGL 3.x level feature. You need to include `` instead of `` to get GL3 features. See for example my answer here for details: http://stackoverflow.com/questions/24095931/glut-deprecation-in-mac-osx-10-9-ide-qt-creator. – Reto Koradi Aug 18 '14 at 22:42
  • That fixes it, thank you! But now I'm getting a problem where a large number of undefined symbols are showing up, such as _glAttachShader, _glBindVertexArray, etc.. That say they're not defined for architecture x86_64. I apologize for asking another question in the comments, but you appear able to answer – Jokull Reynisson Aug 18 '14 at 22:51
  • You got `-framework OpenGL` as part of your link line? Well, since you say you're using Xcode... I dislike Xcode so much that I only use it when I absolutely have to, so I'm not the right person to help with that. – Reto Koradi Aug 18 '14 at 22:56

0 Answers0