Ion
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ion::portgfx Namespace Reference

Classes

class  Visual
 Opaque class that sets up an offscreen OpenGL context/surface/visual in a platform-specific way to allow OpenGL calls to succeed on the current thread. More...
 

Functions

void * GetGlProcAddress (const char *name, bool is_core)
 Returns a generic pointer to an OpenGL function or OpenGL extension function with the given name. More...
 
ION_API bool IsExtensionSupported (const std::string &unprefixed_extension, const std::string &extensions_string)
 Returns whether the currently bound OpenGL implementation supports the named extension. More...
 
ION_API bool IsExtensionSupported (const char *unprefixed_extension)
 A convenience wrapper around the above which takes the unprefixed extension directly as a C string. More...
 
ION_API bool IsExtensionIncomplete (const char *unprefixed_extension)
 Returns whether the passed extension is known to be incomplete for the current platform. More...
 
bool SetSwapInterval (int interval)
 Setting the swap interval is very platform-dependent, so we define a wrapper function for it here. More...
 

Function Documentation

ION_API void * ion::portgfx::GetGlProcAddress ( const char *  name,
bool  is_core 
)

Returns a generic pointer to an OpenGL function or OpenGL extension function with the given name.

Returns NULL if the function is not found. The caller must know whether the function is a "core" function or not, as they must be looked up differently from extensions.

Definition at line 384 of file getglprocaddress.cc.

Referenced by SetSwapInterval().

ION_API bool ion::portgfx::IsExtensionIncomplete ( const char *  unprefixed_extension)

Returns whether the passed extension is known to be incomplete for the current platform.

For example, vertex array objects are known to be broken for many Android devices, and support for them is not always good.

Note
a true return value does not mean the extension is fully supported, only that it is not known to be broken.

This function does not require an OpenGL context to be bound.

Definition at line 88 of file isextensionsupported.cc.

Referenced by ion::gfx::GraphicsManager::EnableFunctionGroupIfAvailable(), and IsExtensionSupported().

ION_API bool ion::portgfx::IsExtensionSupported ( const std::string &  unprefixed_extension,
const std::string &  extensions_string 
)

Returns whether the currently bound OpenGL implementation supports the named extension.

Names are generally of the form GL_<BODY>_name, where <BODY> is usually one of APPLE, AMD, ARB, ATI, EXT, INTEL, KHR, NV, OES, SGI[SX], WEBGL. For maximum compatibility with various implementations, it is often best to only pass the name without the GL or <BODY>.

Definition at line 30 of file isextensionsupported.cc.

References IsExtensionIncomplete().

Referenced by IsExtensionSupported(), and ion::gfx::GraphicsManager::IsExtensionSupported().

ION_API bool ion::portgfx::IsExtensionSupported ( const char *  unprefixed_extension)

A convenience wrapper around the above which takes the unprefixed extension directly as a C string.

Note
to call this function a valid OpenGL context must be bound.

Definition at line 72 of file isextensionsupported.cc.

References ion::portgfx::Visual::GetCurrent(), IsExtensionSupported(), LOG, and ion::port::WARNING.

ION_API bool ion::portgfx::SetSwapInterval ( int  interval)

Setting the swap interval is very platform-dependent, so we define a wrapper function for it here.

Sets the swap interval of the current GL context on the default display device.

It does nothing on iOS and Android. An interval of 0 is equivalent to disabling vsync, while an interval of 1 is equivalent to enabling vsync. Higher values are also possible.

iOS only supports setting vsync through a CADisplayLink that is only available where explicitly created in obj-c code, usually where the GL context is created . We could force applications to pass their CADisplayLink here, but that leads to a platform-specific interface, and the CADisplayLink itself already has a single function to change the swap interval.

There are also numerous reports that eglSwapInterval does nothing on many Android devices.

Note that this function does nothing on iOS, Android, and Asmjs. The function returns whether the swap interval was successfully set, and always returns true on platforms where it does nothing.

Definition at line 43 of file setswapinterval.cc.

References GetGlProcAddress().