c++ - OpenGL fast rendering 2d image -
my current drawing pipeline of existing examples on internet when rendering several videos @ same time, rendering 2d texture pipeline can slow. there ways improve ? can provide examples? thanks.
// when initializing gluint texture; glgentextures(1, &texture); glbindtexture(gl_texture_2d, texture); gltexparameteri(gl_texture_2d, gl_texture_mag_filter, gl_nearest); gltexparameteri(gl_texture_2d, gl_texture_min_filter, gl_nearest); glteximage2d(gl_texture_2d, 0, gl_rgb, image.cols, image.rows, 0, gl_rgb, gl_unsigned_byte, null); glbindtexture(gl_texture_2d, 0); glfinish(); // thread load image cv::mat image = loadimage(); //initializegl() glviewport(0, 0, width, height); glmatrixmode(gl_projection); glloadidentity(); glortho(0, width, 0, height, 0, 1); glmatrixmode(gl_modelview); glloadidentity(); //paintgl() glclear(gl_color_buffer_bit|gl_depth_buffer_bit); glclearcolor(0.0, 0.0, 0.0, 1.0); glloadidentity(); glenable(gl_texture_2d); glbindtexture(gl_texture_2d, texture); gltexsubimage2d(gl_texture_2d, 0, 0, 0, image.cols, image.rows, gl_rgb, gl_unsigned_byte, image.data); glbegin(gl_quads); gltexcoord2f(0.0f, 1.0f); glvertex3f(0, 0, 0.0f); gltexcoord2f(1.0f, 1.0f); glvertex3f(width, 0.0f, 0.0f); gltexcoord2f(1.0f, 0.0f); glvertex3f(width, height, 0.0f); gltexcoord2f(0.0f, 0.0f); glvertex3f(0, height, 0.0f); glend();
Comments
Post a Comment