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

  • Home
  • SEARCH
  • 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 6143607
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T18:32:42+00:00 2026-05-23T18:32:42+00:00

I’ve started learning OpenGL and managed to create a spinning cube using vertex buffer

  • 0

I’ve started learning OpenGL and managed to create a spinning cube using vertex buffer objects. However, when I compile my code, gcc issues the following warnings:

|| sdlogl.c: In function ‘initGL’:
sdlogl.c|48| warning: implicit declaration of function ‘glGenBuffers’
sdlogl.c|50| warning: implicit declaration of function ‘glBindBuffer’
sdlogl.c|51| warning: implicit declaration of function ‘glBufferData’

What should I do to fix these warnings?

This is my code:

#include <SDL/SDL.h>
#include <SDL/SDL_opengl.h>
#include <GL/gl.h>
#include <GL/glu.h>
#include <GL/glext.h>

SDL_Surface *surface;
float rquad=0.0f;
GLuint vertexBuffer,colorBuffer;

float vert[]={
     1, 1, 1,   1, 1,-1,  -1, 1,-1,  -1, 1, 1,
     1,-1, 1,   1,-1,-1,  -1,-1,-1,  -1,-1, 1,
     1, 1, 1,   1,-1, 1,   1,-1,-1,   1, 1,-1,
    -1, 1, 1,  -1,-1, 1,  -1,-1,-1,  -1, 1,-1,
     1, 1, 1,  -1, 1, 1,  -1,-1, 1,   1,-1, 1,
     1, 1,-1,  -1, 1,-1,  -1,-1,-1,   1,-1,-1
};
float colors[]={
    1,0,0,  1,0,0,  1,0,0,  1,0,0,
    0,1,0,  0,1,0,  0,1,0,  0,1,0,
    0,0,1,  0,0,1,  0,0,1,  0,0,1,
    1,1,0,  1,1,0,  1,1,0,  1,1,0, 
    1,0,1,  1,0,1,  1,0,1,  1,0,1, 
    0,1,1,  0,1,1,  0,1,1,  0,1,1
};

Uint32 timerfunc(Uint32 interval,void* param){
    rquad+=0.8f;
    return interval;
}

void initGL(){

    glViewport(0,0,640,480);
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    gluPerspective(45,640.0/480.0,0.1,100);
    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();

    glShadeModel(GL_SMOOTH);
    glClearColor(0,0,0,0);
    glClearDepth(1);
    glEnable(GL_DEPTH_TEST);
    glDepthFunc(GL_LEQUAL);

    glGenBuffers(1,&vertexBuffer);
    glGenBuffers(1,&colorBuffer);
    glBindBuffer(GL_ARRAY_BUFFER,vertexBuffer);
    glBufferData(GL_ARRAY_BUFFER,72*sizeof(float),vert,
            GL_STATIC_DRAW);
    glBindBuffer(GL_ARRAY_BUFFER,colorBuffer);
    glBufferData(GL_ARRAY_BUFFER,72*sizeof(float),colors,
            GL_STATIC_DRAW);
}

void drawGLScene(){
    glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
    glLoadIdentity();
    glTranslatef(0,0,-6);
    glRotatef(rquad,1,1,0.5);

    glBindBuffer(GL_ARRAY_BUFFER,vertexBuffer);
    glVertexPointer(3,GL_FLOAT,0,0);
    glBindBuffer(GL_ARRAY_BUFFER,colorBuffer);
    glColorPointer(3,GL_FLOAT,0,0);

    glEnableClientState(GL_VERTEX_ARRAY);
    glEnableClientState(GL_COLOR_ARRAY);

    glDrawArrays(GL_QUADS,0,24);

    glDisableClientState(GL_VERTEX_ARRAY);
    glDisableClientState(GL_COLOR_ARRAY);

    glBindBuffer(GL_ARRAY_BUFFER,0);
    glBindBuffer(GL_ELEMENT_ARRAY_BUFFER,0);

    SDL_GL_SwapBuffers();
}

int main(int argc, char** argv){
    int videoFlags=0;
    videoFlags|=SDL_OPENGL;
    videoFlags|=SDL_GL_DOUBLEBUFFER;
    videoFlags|=SDL_HWPALETTE;
    videoFlags|=SDL_HWSURFACE;
    videoFlags|=SDL_HWACCEL;

    int done=0;
    SDL_Event event;
    const SDL_VideoInfo* videoInfo;

    SDL_Init(SDL_INIT_VIDEO|SDL_INIT_TIMER);
    videoInfo=SDL_GetVideoInfo();
    SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER,1);

    SDL_WM_SetCaption("Hello OpenGL!",NULL);
    surface=SDL_SetVideoMode(640,480,32,videoFlags);

    initGL();
    SDL_AddTimer(10,timerfunc,NULL);
    while(!done){
        while(SDL_PollEvent(&event)){
            if(event.type==SDL_QUIT){
                done=1;
            }
        }
        drawGLScene();
    }
    SDL_Quit();
    return 0;
}

In addition, I compile my code using the following command: gcc sdlogl.c -g -Wall -lSDL -lGL -lGLU

  • 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-23T18:32:42+00:00Added an answer on May 23, 2026 at 6:32 pm

    Those warnings you get tell you, that the mentioned functions’ prototypes have not been properly declared and the compiler is presuming the default C function signature int ().

    Including glext.h will not give you the declarations though (for various reasons), but gives you proper typedefs to introduce those identifiers yourself. It gets tedious over time though. That’s why wrapper libraries have been implemented. I recomment GLEW or GLEE. Using GLEE the whole thing boils down to including GL/glee.h instead of GL/gl.h.

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
Basically, what I'm trying to create is a page of div tags, each has
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
We are using XSLT to translate a RIXML file to XML. Our RIXML contains
I have thousands of HTML files to process using Groovy/Java and I need to
I'm trying to create an if statement in PHP that prevents a single post

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.