Hi!
when I use opengl to show 4k rgb data, the video will have the fault, like this.
which is very strange,
#########################################################
this is my code
#include <stdio.h>
#include "glew.h"
#include "glut.h"
#include <stdlib.h>
#include <malloc.h>
#include <string.h>
int screen_w=3840,screen_h=2160;
const int pixel_w = 3840, pixel_h = 2160;
FILE *fp = NULL;
unsigned char buffer[pixel_w * pixel_h * 3];
void display(void){
fread(buffer, 1, pixel_w * pixel_h * 3, fp);
glRasterPos3f(-1.0f,1.0f,0);
glPixelZoom((float)screen_w/(float)pixel_w, -(float)screen_h/pixel_h);
glDrawPixels(3840, 2160, GL_RGB, GL_UNSIGNED_BYTE, buffer);
glutSwapBuffers();
}
void timeFunc(int value){
display();
glutTimerFunc(15, timeFunc, 0);
}
int main(int argc, char* argv[])
{
fp=fopen("../v4l2_3840_2160.rgb","rb+");
if(fp==NULL){
printf("Cannot open this file.\n");
return -1;
}
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB );
glutInitWindowPosition(0,0);
glutInitWindowSize(3840, 2160);
glutCreateWindow("4K");
glutDisplayFunc(&display);
glutTimerFunc(15, timeFunc, 0);
glutMainLoop();
return 0;
}
##############################################
The function of glDrawPixels take too much time around 50ms, but my timer is 15ms, Maybe which is the reason of fault.
Is there any other function?
Please give some advices,thank you very much!