UltraGrid
UltraGrid Low-Latency High-Resolution Transmission System
Loading...
Searching...
No Matches
GlProgram Class Reference

#include <opengl_utils.hpp>

Collaboration diagram for GlProgram:
Collaboration graph

Public Member Functions

 GlProgram ()=default
 
 GlProgram (const char *vert_src, const char *frag_src)
 
 GlProgram (const GlProgram &)=delete
 
 GlProgram (GlProgram &&o)
 
 ~GlProgram ()
 
GLuint get ()
 
GlProgram & operator= (const GlProgram &)=delete
 
GlProgram & operator= (GlProgram &&o)
 

Private Member Functions

void swap (GlProgram &o)
 

Private Attributes

GLuint program = 0
 

Detailed Description

RAII wrapper for OpenGL program

Definition at line 70 of file opengl_utils.hpp.

Constructor & Destructor Documentation

◆ GlProgram() [1/4]

GlProgram::GlProgram ( )
default

Compiles provided shaders and constructs an OpenGL program

Parameters
vert_srcvertex shader source
frag_srcfragment shader source

◆ GlProgram() [2/4]

GlProgram::GlProgram ( const char * vert_src,
const char * frag_src )

Definition at line 104 of file opengl_utils.cpp.

104 {
105 GLuint vertexShader = glCreateShader(GL_VERTEX_SHADER);
106 GLuint fragShader = glCreateShader(GL_FRAGMENT_SHADER);
107
108 glShaderSource(vertexShader, 1, &vert_src, NULL);
109 compileShader(vertexShader);
110 glShaderSource(fragShader, 1, &frag_src, NULL);
111 compileShader(fragShader);
112
113 program = glCreateProgram();
114 glAttachShader(program, vertexShader);
115 glAttachShader(program, fragShader);
116 glLinkProgram(program);
117 //glUseProgram(program);
118
119 glDetachShader(program, vertexShader);
120 glDetachShader(program, fragShader);
121 glDeleteShader(vertexShader);
122 glDeleteShader(fragShader);
123}
GLuint program
static const char * vert_src
static void compileShader(GLuint shaderId, QOpenGLFunctions_3_3_Core *f)
static const char * frag_src

References compileShader(), frag_src, program, and vert_src.

Here is the call graph for this function:

◆ ~GlProgram()

GlProgram::~GlProgram ( )

Definition at line 125 of file opengl_utils.cpp.

125 {
126 if(program == 0)
127 return;
128
129 glUseProgram(0);
130 glDeleteProgram(program);
131}

References program.

◆ GlProgram() [3/4]

GlProgram::GlProgram ( const GlProgram & )
delete

◆ GlProgram() [4/4]

GlProgram::GlProgram ( GlProgram && o)
inline

Definition at line 88 of file opengl_utils.hpp.

88{ swap(o); }
void swap(GlProgram &o)

References swap().

Here is the call graph for this function:

Member Function Documentation

◆ get()

GLuint GlProgram::get ( )
inline

Returns the underlying OpenGL program id

Definition at line 85 of file opengl_utils.hpp.

85{ return program; }

References program.

Referenced by FlatVideoScene::enableDeinterlacing(), FlatVideoScene::render(), PanoramaScene::render(), and FlatVideoScene::resize().

◆ operator=() [1/2]

GlProgram & GlProgram::operator= ( const GlProgram & )
delete

◆ operator=() [2/2]

GlProgram & GlProgram::operator= ( GlProgram && o)
inline

Definition at line 90 of file opengl_utils.hpp.

90{ swap(o); return *this; }

References swap().

Here is the call graph for this function:

◆ swap()

void GlProgram::swap ( GlProgram & o)
inlineprivate

Definition at line 93 of file opengl_utils.hpp.

93 {
94 std::swap(program, o.program);
95 }

References program.

Referenced by GlProgram(), and operator=().

Member Data Documentation

◆ program

GLuint GlProgram::program = 0
private

Definition at line 96 of file opengl_utils.hpp.

Referenced by GlProgram(), ~GlProgram(), get(), and swap().


The documentation for this class was generated from the following files: