#include "widget.h"
#include "ui_widget.h"
ui(new Ui::Widget)
{
ui->setupUi(this);
}
Widget::~Widget()
{
wglMakeCurrent(GetDC((HWND)this->winId()), this->contextGL);
cu.ClearProcess(nvGl.m_videoBuffer);
nvGl.cleanupVideo(GetDC((HWND)this->winId()));
delete ui;
}
void Widget::initializeGL(){
glewInit();
rec = Recorder();
this->contextGL =wglGetCurrentContext();
nvC = NVConfig();
nvC.GlobalInit();
nvGl = NVGL(nvC.l_vioConfig,GetDC((HWND)this->winId()));
cu= CUGL();
cu.InitProcess(nvGl.m_videoBuffer);
QTimer::singleShot(16,
this,
SLOT(Tick
()));
}
void Widget::resizeGL(int w, int h){
this->resize(w,h);
if(h==0)
h =1;
glViewport(0,0,w,h);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
perspectiveGL(45.0f,w/h,0.1f,100.0f);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}
void Widget::Tick(){
nvC.DetectIStatus();
nvC.setCaptureDevice();
nvGl.StartCapture();
cu.ProcessVideo(nvGl.m_videoBuffer);
rec.RecordShot(nvGl.m_videoTexture);
paintGL();
QTimer::singleShot(16,
this,
SLOT(Tick
()));
}
void Widget::paintGL(){
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
glTranslatef(-0.5f,-.5f,-1.1f);
glBegin(GL_QUADS);
glTexCoord2f(0,0);
glVertex3f(0,0,0);
glTexCoord2f(0,1.0f);
glVertex3f(0,1.0f,0);
glTexCoord2f(1.0f,1.0f);
glVertex3f(1.0f,1.0f,0);
glTexCoord2f(1.0f,0);
glVertex3f(1.0f,0,0);
glEnd();
}
void Widget::Record(){
rec.Start_StopRecord(nvGl.m_videoTexture);
}
void Widget::perspectiveGL(GLdouble fovY, GLdouble aspect, GLdouble zNear, GLdouble zFar){
const GLdouble pi = 3.1415926535897932384626433832795;
GLdouble fW, fH;
fH = tan( fovY / 360 * pi) * zNear;
fW = fH * aspect;
glFrustum( -fW,fW,-fH,fH,zNear,zFar);
}
#include "widget.h"
#include "ui_widget.h"
Widget::Widget(QWidget *parent) :
QGLWidget(parent),
ui(new Ui::Widget)
{
ui->setupUi(this);
}
Widget::~Widget()
{
wglMakeCurrent(GetDC((HWND)this->winId()), this->contextGL);
cu.ClearProcess(nvGl.m_videoBuffer);
nvGl.cleanupVideo(GetDC((HWND)this->winId()));
delete ui;
}
void Widget::initializeGL(){
glewInit();
rec = Recorder();
this->contextGL =wglGetCurrentContext();
nvC = NVConfig();
nvC.GlobalInit();
nvGl = NVGL(nvC.l_vioConfig,GetDC((HWND)this->winId()));
cu= CUGL();
cu.InitProcess(nvGl.m_videoBuffer);
QTimer::singleShot(16,this,SLOT(Tick()));
}
void Widget::resizeGL(int w, int h){
this->resize(w,h);
if(h==0)
h =1;
glViewport(0,0,w,h);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
perspectiveGL(45.0f,w/h,0.1f,100.0f);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}
void Widget::Tick(){
nvC.DetectIStatus();
nvC.setCaptureDevice();
nvGl.StartCapture();
cu.ProcessVideo(nvGl.m_videoBuffer);
rec.RecordShot(nvGl.m_videoTexture);
paintGL();
QTimer::singleShot(16,this,SLOT(Tick()));
}
void Widget::paintGL(){
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
glTranslatef(-0.5f,-.5f,-1.1f);
glBegin(GL_QUADS);
glTexCoord2f(0,0);
glVertex3f(0,0,0);
glTexCoord2f(0,1.0f);
glVertex3f(0,1.0f,0);
glTexCoord2f(1.0f,1.0f);
glVertex3f(1.0f,1.0f,0);
glTexCoord2f(1.0f,0);
glVertex3f(1.0f,0,0);
glEnd();
}
void Widget::Record(){
rec.Start_StopRecord(nvGl.m_videoTexture);
}
void Widget::perspectiveGL(GLdouble fovY, GLdouble aspect, GLdouble zNear, GLdouble zFar){
const GLdouble pi = 3.1415926535897932384626433832795;
GLdouble fW, fH;
fH = tan( fovY / 360 * pi) * zNear;
fW = fH * aspect;
glFrustum( -fW,fW,-fH,fH,zNear,zFar);
}
To copy to clipboard, switch view to plain text mode
Bookmarks