Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7646293
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T10:10:13+00:00 2026-05-31T10:10:13+00:00

I am trying to build a simple openGL and SDL program that just refuses

  • 0

I am trying to build a simple openGL and SDL program that just refuses to work.

I am using the latest nvidia driver (285.something if i remember) and i use mingw to compile. The machine i use runs Windows7.
My knowledge of mingw is somewhat limited so this might be a very simple linking error.

The version of SDL im using is 1.2 (should i upgrade to 1.3?)

At first, everything worked fine, but i was merely opening an opengl window through SDL.
here’s the code for the original makefile

all:
g++ -o sdlGL.exe esg.cpp tiletest.cpp -lmingw32 -lSDLmain -lSDL -lopengl32 -lglu32

and these are the 2 functions that were called

    void init_sdl(int width, int height) {
        //Start SDL
        if(SDL_Init(SDL_INIT_EVERYTHING) != 0) {
            fDebug << "Failed to init SDL" << std::endl;
            quit(1);
        }

        //Set SDL attrib.
        SDL_GL_SetAttribute( SDL_GL_RED_SIZE, 8 );
        SDL_GL_SetAttribute( SDL_GL_GREEN_SIZE, 8 );
        SDL_GL_SetAttribute( SDL_GL_BLUE_SIZE, 8 );
        SDL_GL_SetAttribute( SDL_GL_ALPHA_SIZE, 8 );
        SDL_GL_SetAttribute( SDL_GL_DEPTH_SIZE, 16 );
        SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 );

        //Set SDL video mode
        if( SDL_SetVideoMode(width, height, 0, SDL_OPENGL) == 0 ) {
            fDebug << "Failed to set SDL video mode" << std::endl;
            quit(1);
        }
    }

    //Initializes OpenGL
    void init_opengl(int width, int height, bool alpha) {
        // Set the OpenGL state after creating the context with SDL_SetVideoMode
        glClearColor( 0, 0, 0, 0 );
        glClear(GL_COLOR_BUFFER_BIT);
        glEnable( GL_TEXTURE_2D ); // Need this to display a texture

        if(alpha) {
            glEnable (GL_BLEND);
            glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
        }

        glViewport( 0, 0, width, height );
        glMatrixMode( GL_PROJECTION );
        glLoadIdentity();
        glOrtho( 0, width, height, 0, -1, 1 );
        glMatrixMode( GL_MODELVIEW );
        glLoadIdentity();
    }

Now for the inclusions:

#include "SDL/SDL.h"
#include "SDL/SDL_image.h"
#include "SDL/SDL_opengl.h"
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>

With that code, everything worked fine.
Then i added some functions to take care of shaders and shader programs

    void CreateShader(GLenum eShaderType, const std::string &strShaderFile, std::vector<GLuint> &shaderList) {
        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);


        shaderList.push_back(shader);
    }

    void ClearShader(std::vector<GLuint> &shaderList) {
        std::for_each(shaderList.begin(), shaderList.end(), glDeleteShader);
    }

    GLuint CreateProgram(const std::vector<GLuint> &shaderList) {
        GLuint program = glCreateProgram();

        for(size_t iLoop = 0; iLoop < shaderList.size(); iLoop++)
            glAttachShader(program, shaderList[iLoop]);

        glLinkProgram(program);

        GLint status;
        glGetProgramiv (program, GL_LINK_STATUS, &status);

        for(size_t iLoop = 0; iLoop < shaderList.size(); iLoop++)
            glDetachShader(program, shaderList[iLoop]);

        return program;
    }

Now, the compiler complains that glCreateShader, glShaderSource, glCompileShader, glGetShaderiv, glDeleteShader, glCreateProgram, glAttachShader, glLinkProgram, glGetProgramiv and glDetachShader were not declared in this scope.

i figured i needed to include glee or glew (right?) so i went with glew.
I then added -glew32 to my makefile and added glew.h to my inclusions

#include "GL/glew.h"

Now, the compiler lists a ton of errors for glew.h like —- does not name a type and —- was not declared in this scope.

I have no idea what to do to fix this.
I should add that i have not much experience with openGL.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T10:10:15+00:00Added an answer on May 31, 2026 at 10:10 am

    GLEW handles the platform-specific #includes for the GL header(s), so you no longer need SDL_opengl.h. It also #includes the appropriate GLU header so you don’t need that either.

    As Xavier pointed out #include <GL/glew.h> before anything else. If I recall correctly it tends to conflict with windows.h.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to build a simple TableView program struture. It seems to work fine,
I'm trying to build a simple Magento Module that needs to connect to the
I am trying to build a simple nested html menu using HAML and am
I'm trying to build a simple jquery plugin that can take selectors as parameters.
I'm trying to build a very simple OpenGL-app under Ubuntu 10.04 (I have a
Im trying to build a simple, lightweight product viewer using jquery. I have a
I am trying to build a simple search-engine using HtmlAgilityPack and Xpath with C#
Im trying to build a simple AJAX script that uses a form to send
I am trying to build a simple phonebook in cakephp 2.0 that stores &
I'm trying to build a simple Silverlight 3 MediaPlayer using the MediaElement tag: <Border

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.