Qt/onroad: use CameraViewWidget (#21821)
* use CameraViewWidget
* no timer, updateFrame after frameSwapped
* use QOpenGLShaderProgram
* merge master
* remove that
* new function setStreamType
* continue
* remove showEvent
* cleanup
* cleanup
* little more
* fix black screen on startup
Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com>
old-commit-hash: a034926264
commatwo_master
parent
4844f8196d
commit
f4d8621be1
11 changed files with 64 additions and 376 deletions
@ -1,63 +0,0 @@ |
|||||||
#include "selfdrive/common/glutil.h" |
|
||||||
|
|
||||||
#include <cassert> |
|
||||||
#include <cstdio> |
|
||||||
#include <cstdlib> |
|
||||||
#include <string> |
|
||||||
|
|
||||||
static GLuint load_shader(GLenum shaderType, const char *src) { |
|
||||||
GLint status = 0, len = 0; |
|
||||||
GLuint shader = glCreateShader(shaderType); |
|
||||||
assert(shader != 0); |
|
||||||
|
|
||||||
glShaderSource(shader, 1, &src, NULL); |
|
||||||
glCompileShader(shader); |
|
||||||
glGetShaderiv(shader, GL_COMPILE_STATUS, &status); |
|
||||||
if (!status) { |
|
||||||
glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &len); |
|
||||||
if (len) { |
|
||||||
std::string msg(len, '\0'); |
|
||||||
glGetShaderInfoLog(shader, len, NULL, msg.data()); |
|
||||||
fprintf(stderr, "error compiling shader:\n%s\n", msg.c_str()); |
|
||||||
} |
|
||||||
assert(0); |
|
||||||
} |
|
||||||
return shader; |
|
||||||
} |
|
||||||
|
|
||||||
GLShader::GLShader(const char *vert_src, const char *frag_src) { |
|
||||||
GLint status = 0, len = 0; |
|
||||||
prog = glCreateProgram(); |
|
||||||
assert(prog != 0); |
|
||||||
|
|
||||||
vert = load_shader(GL_VERTEX_SHADER, vert_src); |
|
||||||
frag = load_shader(GL_FRAGMENT_SHADER, frag_src); |
|
||||||
glAttachShader(prog, vert); |
|
||||||
glAttachShader(prog, frag); |
|
||||||
glLinkProgram(prog); |
|
||||||
|
|
||||||
glGetProgramiv(prog, GL_LINK_STATUS, &status); |
|
||||||
if (!status) { |
|
||||||
glGetProgramiv(prog, GL_INFO_LOG_LENGTH, &len); |
|
||||||
if (len) { |
|
||||||
std::string msg(len, '\0'); |
|
||||||
glGetProgramInfoLog(prog, len, NULL, msg.data()); |
|
||||||
fprintf(stderr, "error linking program:\n%s\n", msg.c_str()); |
|
||||||
} |
|
||||||
assert(0); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
GLShader::~GLShader() { |
|
||||||
glDeleteProgram(prog); |
|
||||||
glDeleteShader(frag); |
|
||||||
glDeleteShader(vert); |
|
||||||
} |
|
||||||
|
|
||||||
GLuint GLShader::getUniformLocation(const char *name) { |
|
||||||
auto it = uniform_loc_map.find(name); |
|
||||||
if (it == uniform_loc_map.end()) { |
|
||||||
it = uniform_loc_map.insert(it, {name, glGetUniformLocation(prog, name)}); |
|
||||||
} |
|
||||||
return it->second; |
|
||||||
} |
|
@ -1,21 +0,0 @@ |
|||||||
#pragma once |
|
||||||
|
|
||||||
#include <map> |
|
||||||
|
|
||||||
#ifdef __APPLE__ |
|
||||||
#include <OpenGL/gl3.h> |
|
||||||
#else |
|
||||||
#include <GLES3/gl3.h> |
|
||||||
#endif |
|
||||||
|
|
||||||
class GLShader { |
|
||||||
public: |
|
||||||
GLShader(const char *vert_src, const char *frag_src); |
|
||||||
~GLShader(); |
|
||||||
GLuint getUniformLocation(const char * name); |
|
||||||
GLuint prog = 0; |
|
||||||
|
|
||||||
private: |
|
||||||
GLuint vert = 0, frag = 0; |
|
||||||
std::map<const char*, GLint> uniform_loc_map; |
|
||||||
}; |
|
Loading…
Reference in new issue