Git Product home page Git Product logo

Comments (9)

ikskuh avatar ikskuh commented on July 20, 2024 1

This is reasonable behaviour for machines that don't support all the functions from glcorearb.h. Imagine compiling your application with all functions from OpenGL 4.6, but targeting OpenGL 3.3.

When starting the application on a system that does not support newer functions than those of OpenGL 3.3, the application should still run and not emit any errors or warnings regarding missing functions.

from gl3w.

ikskuh avatar ikskuh commented on July 20, 2024 1

Well, the function will return NULL if that was the initial question

from gl3w.

 avatar commented on July 20, 2024

I'm afraid you misunderstand my question. I'm not asking what you are trying to answer.

from gl3w.

 avatar commented on July 20, 2024

@MasterQ32: Thank you for your willingness to answer. I think a more relevant answer can be tendered from some others.

from gl3w.

tombsar avatar tombsar commented on July 20, 2024

If an OpenGL function is not found in either of those locations, then it is not present on the local machine. Returning NULL in these situations seems correct to me; it will raise a segfault only if you try to use this function, and otherwise continue normally.

from gl3w.

 avatar commented on July 20, 2024

So the functions listed in union GL3WProcs or <GL/glcorearb.h> are just all OpenGL functions in the standard, not the actual available (in opengl32.dll or from wglGetProcAddress as extensions) OpenGL functions provided by the platform on which I ran the python script to generate the gl3w.c. Right? So all gl3w does is to mark a function item -- if it is available in the platform on which the application is running, the item is the function pointer, otherwise the item is NULL. So a serious application using gl3w should check whether the OpenGL function to be used is NULL or not before calling it, just as parse_version of gl3w.c checks glGetIntegerv:

static int parse_version(void)
{
	if (!glGetIntegerv)
		return GL3W_ERROR_INIT;

	glGetIntegerv(GL_MAJOR_VERSION, &version.major);
	glGetIntegerv(GL_MINOR_VERSION, &version.minor);
        ......
}

Am I right?

from gl3w.

tombsar avatar tombsar commented on July 20, 2024

Yes, that all sounds right to me. On Windows you can only find out what functionality is actually available at runtime, so not everything in the OpenGL headers will work. There is definitely an argument to be made that gl3w should check for failures, at least for core functionality, but I presume the author decided the extra safety wasn't worth the overhead or code complexity. If you want your code to be completely safe, you should check every OpenGL function pointer before use.

In practice, however, you should be safe using any core OpenGL functionality for a given OpenGL version after checking gl3wIsSupported. If a graphics driver claims it supports a given OpenGL version, but then does not give you the function pointers, that would be a serious bug in the driver. If you want to use anything defined as an OpenGL extension, or that comes from a spec version newer than what you requested, then you should definitely check for NULL before using it.

from gl3w.

 avatar commented on July 20, 2024

@tombsar: Thank you very much for the clear remarks.

from gl3w.

tombsar avatar tombsar commented on July 20, 2024

Closing this. Please reopen if you have further questions.

from gl3w.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.