Why glClearBufferfv is not defined in this scope

I’m new to opengl and trying to solve this issue from last 5 hours but no luck. I checked gl.h header file and it does not declare glClearBufferfv(). I don’t know why.

#include <GLFW/glfw3.h>
#include <GL/gl.h>
#include <iostream>

int main(void)
    GLFWwindow* window;

    /* Initialize the library */
    if (!glfwInit()){
	std::cerr<<"Error initializing glfw";	
        return -1;

    glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
    glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
    /* Create a windowed mode window and its OpenGL context */
    window = glfwCreateWindow(640, 480, "Hello World", NULL, NULL);
    if (!window)
        return -1;
    /* Make the window's context current */

    //color for clearing
    const GLint color[] = {1,0,0,1}; 
    /* Loop until the user closes the window */
    while (!glfwWindowShouldClose(window))
	/* Render here */
        /* Swap front and back buffers */

        /* Poll for and process events */

    return 0;

here is my makefile:

window: window.cpp
	g++ window1.cpp  -lGL  -lglfw -o window1.out

I wrote a program using glClearColor(1,0,0,1) and glClear(GL_COLOR_BUFFER_BIT); that works but don’t know why when using glClearBufferfv I get error.

Thanks. If any other details are required let me know.

FYI, I’m using Ubuntu. As I said gl.h doesnt have declaration of glClearBufferfv I want to know how can I upgrade/update those headers to have the declaration.

It’s in <GL/glext.h>. But you have to define GL_GLEXT_PROTOTYPES to get prototypes, otherwise you just get typedefs for the function pointers which must be obtained from glXGetProcAddress (Unix) or wglGetProcAddress (Windows). E.g.

 = (PFNGLCLEARBUFFERFVPROC) glXGetProcAddress((const GLubyte *) "glClearBufferfv");
1 Like

:slightly_smiling_face: Thank you @GClements

Can you tell what does PFN stands for in that typedef

Pointer to Function.

If you expand the typedef, you get:


typedef void (* PFNGLCLEARBUFFERFVPROC) (GLenum buffer, GLint drawbuffer, const GLfloat *value);


typedef void (__stdcall * PFNGLCLEARBUFFERFVPROC) (GLenum buffer, GLint drawbuffer, const GLfloat *value);
1 Like

Thanks :slightly_smiling_face: could’n found that enywhere else on internet.

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.