mirror of
https://github.com/lostjared/Acid.Cam.v2.Qt.git
synced 2025-12-05 14:30:03 +01:00
working on linux, but no longer macos, there is a targeted macos app anyway
This commit is contained in:
@@ -9,7 +9,7 @@ greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
|
||||
CONFIG += c++11
|
||||
DEPENDPATH += .
|
||||
INCLUDEPATH += . /usr/include/ /usr/local/include
|
||||
LIBS += `pkg-config acidcam opencv --libs` -lGL -lGLU
|
||||
LIBS += `pkg-config acidcam opencv --libs` -lGL
|
||||
#LIBS += -lopencv_contrib -lopencv_core -lopencv_highgui -lopencv_imgproc -lopencv_legacy -lopencv_video
|
||||
#LIBS += -L/usr/local/lib -lopencv_world
|
||||
QMAKE_CXXFLAGS += `pkg-config acidcam opencv --cflags`
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
######################################################################
|
||||
y######################################################################
|
||||
# Automatically generated by qmake (2.01a) Wed Feb 1 02:31:01 2017
|
||||
######################################################################
|
||||
|
||||
@@ -9,7 +9,7 @@ greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
|
||||
CONFIG += c++11
|
||||
DEPENDPATH += .
|
||||
INCLUDEPATH += . /usr/include/ /usr/local/include
|
||||
LIBS += `pkg-config acidcam opencv4 --libs` -lGLU -lGLU
|
||||
LIBS += `pkg-config acidcam opencv4 --libs` -lGLU
|
||||
#LIBS += -lopencv_contrib -lopencv_core -lopencv_highgui -lopencv_imgproc -lopencv_legacy -lopencv_video
|
||||
#LIBS += -L/usr/local/lib -lopencv_world
|
||||
QMAKE_CXXFLAGS += `pkg-config acidcam opencv4 --cflags`
|
||||
|
||||
@@ -7,8 +7,6 @@
|
||||
#include <QtGui/QPainter>
|
||||
#include <iostream>
|
||||
|
||||
|
||||
|
||||
glDisplayWindow::glDisplayWindow(QWindow *parent)
|
||||
: QWindow(parent)
|
||||
, m_animating(false)
|
||||
@@ -27,71 +25,36 @@ void glDisplayWindow::render(QPainter *painter) {
|
||||
}
|
||||
|
||||
void glDisplayWindow::initialize() {
|
||||
resize(1280, 720);
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
glClearDepth(1.0f);
|
||||
glClearColor(0, 0, 0, 0);
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
glOrtho(0, width(), height(), 0, -1.0, 1.0);
|
||||
glEnable (GL_DEPTH_TEST);
|
||||
}
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
resize(1280, 720);
|
||||
srand((unsigned int)time(0));
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
|
||||
glClearColor(0.0, 0.0, 0.0, 0.0);}
|
||||
|
||||
void glDisplayWindow::setNewFrame(QImage image) {
|
||||
frame = image;
|
||||
frame = image.mirrored();
|
||||
updated = true;
|
||||
}
|
||||
|
||||
void glDisplayWindow::updateTexture(QImage image) {
|
||||
static int lazy = 0;
|
||||
QImage new_one = image.mirrored();
|
||||
if(lazy == 0) {
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
glGenTextures(1, &tex);
|
||||
glBindTexture(GL_TEXTURE_2D, tex);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
|
||||
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_RGBA, new_one.width(), new_one.height(), 0, GL_BGR, GL_UNSIGNED_BYTE, new_one.bits());
|
||||
lazy = 1;
|
||||
} else {
|
||||
glBindTexture(GL_TEXTURE_2D, tex);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, new_one.width(), new_one.height(), GL_BGR, GL_UNSIGNED_BYTE, new_one.bits());
|
||||
}
|
||||
void glDisplayWindow::updateTexture(QImage) {
|
||||
}
|
||||
|
||||
void glDisplayWindow::render() {
|
||||
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
if (!m_device)
|
||||
m_device = new QOpenGLPaintDevice;
|
||||
|
||||
if(updated == true && frame.width()>100 && frame.height()>100) {
|
||||
updateTexture(frame);
|
||||
updated = false;
|
||||
}
|
||||
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
glOrtho(0, 1280, 0, 720, -1, 1);
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
glOrtho(0, 1, 1, 0, -1, 1);
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glLoadIdentity();
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
glBindTexture(GL_TEXTURE_2D, tex);
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
glBegin(GL_QUADS);
|
||||
glTexCoord2i(0, 0); glVertex2i(0, 0);
|
||||
glTexCoord2i(0, 1); glVertex2i(0, 720);
|
||||
glTexCoord2i(1, 1); glVertex2i(1280, 720);
|
||||
glTexCoord2i(1, 0); glVertex2i(1280, 0);
|
||||
glEnd();
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
glBindTexture(GL_TEXTURE_2D, 0);
|
||||
//m_device->setSize(size() * devicePixelRatio());
|
||||
//m_device->setDevicePixelRatio(devicePixelRatio());
|
||||
glDrawPixels(frame.width(), frame.height(), GL_RGB, GL_UNSIGNED_BYTE, frame.bits());
|
||||
m_device->setSize(size() * devicePixelRatio());
|
||||
m_device->setDevicePixelRatio(devicePixelRatio());
|
||||
QPainter painter(m_device);
|
||||
render(&painter);
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#ifndef __GL_DISPLAY___H
|
||||
#define __GL_DISPLAY___H
|
||||
|
||||
|
||||
#include <QtGui/QWindow>
|
||||
#include <QtGui/QOpenGLFunctions>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user