source: opengl-game/graphics-pipeline_opengl.hpp@ 5081b9a

feature/imgui-sdl
Last change on this file since 5081b9a was 0b1b52d, checked in by Dmitry Portnoy <dmitry.portnoy@…>, 5 years ago

In openglgame, port over the functionality to specify and initialize varying attributes

  • Property mode set to 100644
File size: 1.2 KB
Line 
1#ifndef _GRAPHICS_PIPELINE_OPENGL_H
2#define _GRAPHICS_PIPELINE_OPENGL_H
3
4#include "graphics-pipeline.hpp"
5
6#include <vector>
7
8#include <GL/glew.h>
9
10enum VaryingAttribType {
11 ATTRIB_OBJECT_VARYING,
12 ATTRIB_POINT_VARYING,
13};
14
15// TODO: Might be better to create a different struct for uniform attributes
16struct VaryingAttribInfo {
17 VaryingAttribType attribType;
18 GLuint index;
19 GLint size;
20 GLenum type;
21 // UniformType uniType;
22 GLuint buffer; // For uniforms, this is the uniform location
23 size_t fieldOffset;
24 // GLfloat* data; // pointer to data source for uniform attributes
25};
26
27class GraphicsPipeline_OpenGL : public GraphicsPipeline {
28 public:
29 GraphicsPipeline_OpenGL(Viewport viewport);
30 ~GraphicsPipeline_OpenGL();
31
32 void addVaryingAttribute(VaryingAttribType attribType, GLint size, GLenum type, size_t fieldOffset);
33 void createPipeline(string vertShaderFile, string fragShaderFile);
34
35 private:
36 GLuint shaderProgram;
37 GLuint vao;
38 unsigned int numPoints;
39
40 vector<VaryingAttribInfo> varyingAttribs;
41
42 GLuint loadShaderProgram(string vertShaderFile, string fragShaderFile);
43 GLuint loadShader(GLenum type, string file);
44};
45
46#endif // _GRAPHICS_PIPELINE_OPENGL_H
Note: See TracBrowser for help on using the repository browser.