SVG5/qvideoshader.cpp
2025-10-12 13:55:56 +09:00

50 lines
1.4 KiB
C++

#include "qvideoshader.h"
using namespace SOPENGL;
#include "common.h"
QVideoShader::QVideoShader()
{
}
QVideoShader::~QVideoShader()
{
SAFE_DELETE(m_pVideoTexture);
}
void QVideoShader::CreateShader(const char *pSrcVShader, const char *pSrcFShader)
{
QGLSLShader::CreateShader(pSrcVShader, pSrcFShader);
m_ImageWidth = m_pProgram->uniformLocation("nImageWidth");
m_ImageHeight = m_pProgram->uniformLocation("nImageHeight");
m_nDisplayType = m_pProgram->uniformLocation("nDisplayType");
}
void QVideoShader::CreateTexture(int nWidth, int nHeight, QOpenGLTexture::Target target, QOpenGLTexture::TextureFormat format)
{
m_nTextureWidth = nWidth;
m_nTextureHeight = nHeight;
m_pVideoTexture = new QOpenGLTexture(target);
//m_pVideoTexture->setMinificationFilter(QOpenGLTexture::LinearMipMapLinear);
//m_pVideoTexture->setMagnificationFilter(QOpenGLTexture::Linear);
m_pVideoTexture->create();
m_pVideoTexture->setFormat(format);
m_pVideoTexture->setSize(nWidth, nHeight);
m_pVideoTexture->allocateStorage();
}
void QVideoShader::SetUniformValue()
{
QGLSLShader::SetUniformValue();
m_pProgram->setUniformValue(m_ImageWidth, m_nTextureWidth);
m_pProgram->setUniformValue(m_ImageHeight, m_nTextureHeight);
m_pProgram->setUniformValue(m_nDisplayType, 0);
m_pVideoTexture->setMinMagFilters(QOpenGLTexture::LinearMipMapLinear, QOpenGLTexture::LinearMipMapLinear);
}