Scroll to navigation

SDL_GL_BindTexture(3) SDL3 FUNCTIONS SDL_GL_BindTexture(3)

NAME

SDL_GL_BindTexture - Bind an OpenGL/ES/ES2 texture to the current context.

SYNOPSIS

#include "SDL3/SDL.h"
int SDL_GL_BindTexture(SDL_Texture *texture, float *texw, float *texh);

DESCRIPTION

This is for use with OpenGL instructions when rendering OpenGL primitives directly.

If not NULL, texw and texh will be filled with the width and height values suitable for the provided texture. In most cases, both will be 1.0, however, on systems that support the GL_ARB_texture_rectangle extension, these values will actually be the pixel width and height used to create the texture, so this factor needs to be taken into account when providing texture coordinates to OpenGL.

You need a renderer to create an SDL_Texture , therefore you can only use this function with an implicit OpenGL context from

SDL_CreateRenderer (), not with your own OpenGL context. If you need control over your OpenGL context, you need to write your own texture-loading methods.

Also note that SDL may upload RGB textures as BGR (or vice-versa), and re-order the color channels in the shaders phase, so the uploaded texture may have swapped color channels.

FUNCTION PARAMETERS

the texture to bind to the current OpenGL/ES/ES2 context
a pointer to a float value which will be filled with the texture width or NULL if you don't need that value
a pointer to a float value which will be filled with the texture height or NULL if you don't need that value

RETURN VALUE

Returns 0 on success or a negative error code on failure; call

SDL_GetError () for more information.

AVAILABILITY

This function is available since SDL 3.0.0.

SEE ALSO

SDL_GL_MakeCurrent(3), SDL_GL_UnbindTexture(3)

SDL 3.0.0 SDL