-
Notifications
You must be signed in to change notification settings - Fork 5
/
NuanceGLWidget.cpp
69 lines (57 loc) · 1.8 KB
/
NuanceGLWidget.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#include "glew.h"
#include "NuonEnvironment.h"
#include "NuanceGLWidget.h"
#include "video.h"
extern NuonEnvironment *nuonEnv;
extern bool bProcessorThreadRunning;
extern uint8 *mainChannelBuffer;
extern uint8 *overlayChannelBuffer;
uint8 *AllocateTextureMemory(uint32 size, bool bOverlay);
void FreeTextureMemory(uint8 *ptr, bool bOverlay);
NuanceGLWidget::NuanceGLWidget( QWidget* parent, const char* name, const QGLWidget* shareWidget) : QGLWidget(parent, name, shareWidget)
{
}
NuanceGLWidget::NuanceGLWidget( const QGLFormat& format, QWidget* parent, const char* name, const QGLWidget* shareWidget) : QGLWidget(format, parent, name, shareWidget)
{
}
NuanceGLWidget::~NuanceGLWidget()
{
FreeTextureMemory(mainChannelBuffer,false);
FreeTextureMemory(overlayChannelBuffer,true);
}
void NuanceGLWidget::initializeGL()
{
mainChannelBuffer = AllocateTextureMemory(ALLOCATED_TEXTURE_WIDTH*ALLOCATED_TEXTURE_HEIGHT*4,false);
overlayChannelBuffer = AllocateTextureMemory(ALLOCATED_TEXTURE_WIDTH*ALLOCATED_TEXTURE_HEIGHT*4,true);
InitializeYCrCbColorSpace();
}
void NuanceGLWidget::resizeGL(int w, int h)
{
glViewport(0,0,w,h);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0.0,1.0,0.0,1.0,-1.0,1.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glDisable(GL_BLEND);
glDisable(GL_DEPTH_TEST);
glDisable(GL_ALPHA_TEST);
glDisable(GL_LIGHTING);
glDisable(GL_FOG);
glClear(GL_COLOR_BUFFER_BIT);
nuonEnv->bMainBufferModified = true;
nuonEnv->bOverlayBufferModified = true;
}
void NuanceGLWidget::paintGL()
{
if(bProcessorThreadRunning)
{
//nuonEnv->bMainBufferModified = true;
//nuonEnv->bOverlayBufferModified = true;
RenderVideo(width(),height());
}
else
{
glClear(GL_COLOR_BUFFER_BIT);
}
}