Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Ludmány Balázs
/
thin-client
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
249ab83a
authored
Jul 07, 2016
by
Ludmány Balázs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Borderline working version
parent
d4f375e9
Pipeline
#125
skipped in 0 seconds
Changes
15
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
218 additions
and
124 deletions
+218
-124
ThinClient.pro
+3
-1
ThinClient.pro.user
+1
-1
dispatcher.cpp
+33
-9
dispatcher.h
+4
-0
draw_shader.fsh
+1
-2
fill_shader.fsh
+5
-0
fill_shader.vsh
+10
-0
main.cpp
+1
-1
main.qml
+28
-5
qvnc.cpp
+6
-0
qvnc.h
+2
-0
uploader.cpp
+52
-28
uploader.h
+18
-12
vncrenderer.cpp
+44
-54
vncrenderer.h
+10
-11
No files found.
ThinClient.pro
View file @
249ab83a
...
...
@@ -33,4 +33,6 @@ HEADERS += \
DISTFILES
+=
\
draw_shader
.
fsh
\
draw_shader
.
vsh
draw_shader
.
vsh
\
fill_shader
.
vsh
\
fill_shader
.
fsh
ThinClient.pro.user
View file @
249ab83a
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 3.5.1, 2016-07-0
6T14:51:57
. -->
<!-- Written by QtCreator 3.5.1, 2016-07-0
7T10:36:53
. -->
<qtcreator>
<data>
<variable>
EnvironmentId
</variable>
...
...
dispatcher.cpp
View file @
249ab83a
...
...
@@ -39,7 +39,7 @@ void Dispatcher::GotBitmap(rfbClient *client, const uint8_t *buffer, int x, int
img
=
QImage
(
buffer
,
w
,
h
,
QImage
::
Format_RGB16
);
break
;
case
32
:
img
=
QImage
(
buffer
,
w
,
h
,
QImage
::
Format_RGB
32
);
img
=
QImage
(
buffer
,
w
,
h
,
QImage
::
Format_RGB
X8888
);
break
;
default
:
emit
dispatcher
->
error
();
...
...
@@ -74,6 +74,18 @@ void Dispatcher::FinishedFrameBufferUpdate(rfbClient *client)
}
}
void
Dispatcher
::
setMouse
(
int
x
,
int
y
,
bool
left
,
bool
middle
,
bool
right
)
{
if
(
m_client
==
NULL
)
return
;
int
buttonMask
=
0
;
if
(
left
)
buttonMask
|=
rfbButton1Mask
;
if
(
middle
)
buttonMask
|=
rfbButton2Mask
;
if
(
right
)
buttonMask
|=
rfbButton3Mask
;
SendPointerEvent
(
m_client
,
x
,
y
,
buttonMask
);
}
unsigned
int
Dispatcher
::
decoderCount
()
const
{
return
m_decoderCount
;
...
...
@@ -133,6 +145,14 @@ unsigned int Dispatcher::draw_count()
return
0
;
}
QVector3D
Dispatcher
::
colorMax
()
const
{
if
(
m_client
==
NULL
)
return
QVector3D
();
return
QVector3D
(
m_client
->
format
.
redMax
,
m_client
->
format
.
greenMax
,
m_client
->
format
.
blueMax
);
}
void
Dispatcher
::
create_context
(
QOpenGLContext
*
context
)
{
m_uploader
.
create_context
(
context
);
...
...
@@ -170,19 +190,23 @@ void Dispatcher::refresh()
setFinished
(
false
);
m_uploader
.
startedUpdate
();
int
message
=
0
;
int
message
=
WaitForMessage
(
m_client
,
10000
);
if
(
message
<
0
)
{
terminate
();
emit
error
();
return
;
}
if
(
message
)
{
if
(
!
HandleRFBServerMessage
(
m_client
))
{
// Wait until we get something
while
(
message
==
0
)
{
message
=
WaitForMessage
(
m_client
,
10000
);
if
(
message
<
0
)
{
terminate
();
emit
error
();
return
;
}
if
(
message
)
{
if
(
!
HandleRFBServerMessage
(
m_client
))
{
terminate
();
emit
error
();
return
;
}
}
}
}
...
...
dispatcher.h
View file @
249ab83a
...
...
@@ -9,6 +9,8 @@
#include <QPoint>
#include <QSize>
#include <QColor>
#include <QMouseEvent>
#include <QVector3D>
#include <rfb/rfbclient.h>
#include "uploader.h"
...
...
@@ -29,6 +31,7 @@ public:
static
rfbBool
GotJpeg
(
rfbClient
*
client
,
const
uint8_t
*
buffer
,
int
length
,
int
x
,
int
y
,
int
w
,
int
h
);
static
void
FinishedFrameBufferUpdate
(
rfbClient
*
client
);
void
setMouse
(
int
x
,
int
y
,
bool
left
,
bool
middle
,
bool
right
);
unsigned
int
decoderCount
()
const
;
unsigned
int
incrementDecoderCount
();
...
...
@@ -42,6 +45,7 @@ public:
unsigned
int
copy_count
();
unsigned
int
draw_count
();
QVector3D
colorMax
()
const
;
private
:
rfbClient
*
m_client
;
unsigned
int
m_decoderCount
;
...
...
draw_shader.fsh
View file @
249ab83a
...
...
@@ -3,6 +3,5 @@ varying highp vec2 vartexcoord;
void main(void)
{
gl_FragColor =
texture2D(texture, vartexcoord
);
gl_FragColor =
vec4(texture2D(texture, vartexcoord).rgb, 1.0
);
}
fill_shader.fsh
0 → 100644
View file @
249ab83a
varying highp vec3 varcolor;
void main(void)
{
gl_FragColor = vec4(varcolor, 1.0);
}
fill_shader.vsh
0 → 100644
View file @
249ab83a
uniform highp mat4 ortho;
uniform highp vec3 colormax;
attribute highp vec2 position;
attribute highp vec3 color;
varying highp vec3 varcolor;
void main(void)
{
gl_Position = ortho * vec4(position, 0.0, 1.0);
varcolor = color / colormax;
}
main.cpp
View file @
249ab83a
...
...
@@ -8,7 +8,7 @@ int main(int argc, char *argv[])
{
QGuiApplication
app
(
argc
,
argv
);
qmlRegisterType
<
QVnc
>
(
"thinclient"
,
1
,
1
,
"QVnc"
);
qmlRegisterType
<
QVnc
>
(
"thinclient"
,
1
,
3
,
"QVnc"
);
QQmlApplicationEngine
engine
;
engine
.
load
(
QUrl
(
QStringLiteral
(
"qrc:/main.qml"
)));
...
...
main.qml
View file @
249ab83a
import
QtQuick
2.6
import
QtQuick
.
Controls
2.0
import
thinclient
1.
1
import
thinclient
1.
3
ApplicationWindow
{
visible
:
true
width
:
1280
height
:
1024
width
:
vnc
.
width
;
height
:
tab
.
height
+
vnc
.
height
header
:
TabBar
{
id
:
tab
width
:
parent
.
width
TabButton
{
text
:
qsTr
(
"Open connection"
)
...
...
@@ -26,7 +27,29 @@ ApplicationWindow {
id
:
vnc
host
:
"vm.ik.bme.hu"
port
:
10495
width
:
1280
height
:
1024
width
:
1027
height
:
768
MouseArea
{
anchors.fill
:
parent
cursorShape
:
Qt
.
BlankCursor
hoverEnabled
:
true
acceptedButtons
:
Qt
.
LeftButton
|
Qt
.
MiddleButton
|
Qt
.
RightButton
onPositionChanged
:
vnc
.
setMouse
(
mouse
.
x
,
mouse
.
y
,
mouse
.
buttons
&
Qt
.
LeftButton
,
mouse
.
buttons
&
Qt
.
MiddleButton
,
mouse
.
buttons
&
Qt
.
RightButton
)
onPressed
:
vnc
.
setMouse
(
mouse
.
x
,
mouse
.
y
,
mouse
.
buttons
&
Qt
.
LeftButton
,
mouse
.
buttons
&
Qt
.
MiddleButton
,
mouse
.
buttons
&
Qt
.
RightButton
)
onReleased
:
vnc
.
setMouse
(
mouse
.
x
,
mouse
.
y
,
mouse
.
buttons
&
Qt
.
LeftButton
,
mouse
.
buttons
&
Qt
.
MiddleButton
,
mouse
.
buttons
&
Qt
.
RightButton
)
}
}
}
qvnc.cpp
View file @
249ab83a
...
...
@@ -56,6 +56,11 @@ void QVnc::setPort(int port)
emit
portChanged
(
port
);
}
void
QVnc
::
setMouse
(
int
x
,
int
y
,
bool
left
,
bool
middle
,
bool
right
)
{
m_dispatcher
->
setMouse
(
x
,
y
,
left
,
middle
,
right
);
}
void
QVnc
::
dispatch_error
()
{
qDebug
()
<<
"error"
;
...
...
@@ -81,6 +86,7 @@ QQuickFramebufferObject::Renderer *QVnc::createRenderer() const
m_dispatcher
->
uploader
().
draw_buffer
(),
m_dispatcher
->
uploader
().
draw_textures
());
connect
(
renderer
,
&
VncRenderer
::
finishedRendering
,
m_dispatcher
,
&
Dispatcher
::
refresh
);
connect
(
renderer
,
&
VncRenderer
::
framebufferObjectChanged
,
&
(
m_dispatcher
->
uploader
()),
&
Uploader
::
changeFramebufferObject
);
return
renderer
;
}
...
...
qvnc.h
View file @
249ab83a
...
...
@@ -6,6 +6,7 @@
#include <QQuickFramebufferObject>
#include <QThread>
#include <QOffscreenSurface>
#include <QMouseEvent>
#include "dispatcher.h"
#include "vncrenderer.h"
...
...
@@ -41,6 +42,7 @@ public slots:
void
setHost
(
QString
host
);
void
setPort
(
int
port
);
void
setMouse
(
int
x
,
int
y
,
bool
left
,
bool
middle
,
bool
right
);
void
dispatch_error
();
private
:
...
...
uploader.cpp
View file @
249ab83a
...
...
@@ -14,9 +14,6 @@ Uploader::Uploader()
m_copy_data
.
reserve
(
5
);
m_copy_source
->
reserve
(
5
);
m_draw_textures
->
reserve
(
5
);
m_draw_buffer
=
QSharedPointer
<
QOpenGLBuffer
>
(
new
QOpenGLBuffer
);
m_draw_buffer
->
setUsagePattern
(
QOpenGLBuffer
::
DynamicDraw
);
}
void
Uploader
::
create_context
(
QOpenGLContext
*
context
)
...
...
@@ -25,33 +22,57 @@ void Uploader::create_context(QOpenGLContext *context)
m_uploader_context
->
setShareContext
(
context
);
m_uploader_context
->
create
();
m_uploader_context
->
makeCurrent
(
&
m_surface
);
m_uploader_context
->
functions
()
->
initializeOpenGLFunctions
();
m_fill_buffer
.
create
();
m_copy_buffer
.
create
();
m_draw_buffer
.
create
();
}
void
Uploader
::
startedUpdate
()
{
// Clean up the data from the previous round
m_fill_data
.
clear
();
m_fill_count
=
0
;
for
(
unsigned
int
i
=
0
;
i
<
m_copy_count
;
i
++
)
{
m_copy_source
->
at
(
i
).
texture
->
destroy
();
delete
m_copy_source
->
at
(
i
).
texture
;
}
m_copy_source
->
clear
();
m_copy_data
.
clear
();
m_copy_count
=
0
;
m_fill_data
.
clear
();
m_fill_count
=
0
;
for
(
unsigned
int
i
=
0
;
i
<
m_draw_count
;
i
++
)
{
m_draw_textures
->
at
(
i
)
->
destroy
();
delete
m_draw_textures
->
at
(
i
);
}
m_draw_textures
->
clear
();
m_draw_data
.
clear
();
m_draw_count
=
0
;
}
void
Uploader
::
gotCopyRect
(
const
int
src_x
,
const
int
src_y
,
const
int
width
,
const
int
height
,
const
int
dest_x
,
const
int
dest_y
)
{
if
(
m_framebufferObject
!=
NULL
&&
!
m_framebufferObject
->
isBound
())
m_framebufferObject
->
bind
();
QOpenGLTexture
*
texture
=
new
QOpenGLTexture
(
QOpenGLTexture
::
Target2D
);
texture
->
allocateStorage
(
QOpenGLTexture
::
RGBA
,
QOpenGLTexture
::
Float32
);
texture
->
setAutoMipMapGenerationEnabled
(
false
);
texture
->
setSize
(
width
,
height
);
texture
->
setFormat
(
QOpenGLTexture
::
RGBAFormat
);
texture
->
allocateStorage
();
texture
->
bind
();
m_uploader_context
->
functions
()
->
glCopyTexImage2D
(
GL_TEXTURE_2D
,
0
,
GL_RGBA
,
src_x
,
m_framebufferHeight
-
src_y
,
width
,
height
,
0
);
texture
->
release
();
// "Specify the window coordinates of the lower left corner
// of the rectangular region of pixels to be copied."
...
...
@@ -124,7 +145,7 @@ void Uploader::gotFillRect(const int x, const int y, const int width, const int
void
Uploader
::
gotBitmap
(
const
QImage
&
image
,
const
int
x
,
const
int
y
,
const
int
width
,
const
int
height
)
{
m_draw_textures
->
append
(
new
QOpenGLTexture
(
image
,
QOpenGLTexture
::
DontGenerateMipMaps
));
m_draw_textures
->
append
(
new
QOpenGLTexture
(
image
.
mirrored
()
,
QOpenGLTexture
::
DontGenerateMipMaps
));
// bottom left
m_draw_data
.
append
((
float
)
x
);
...
...
@@ -152,23 +173,26 @@ void Uploader::gotBitmap(const QImage &image, const int x, const int y, const in
void
Uploader
::
finishedUpdate
()
{
if
(
m_
copy
_count
>
0
)
{
m_
copy_buffer
->
bind
();
m_
copy_buffer
->
allocate
(
m_copy_data
.
constData
(),
m_copy
_data
.
size
()
*
sizeof
(
float
));
m_
copy_buffer
->
release
();
if
(
m_
fill
_count
>
0
)
{
m_
fill_buffer
.
bind
();
m_
fill_buffer
.
allocate
(
m_fill_data
.
constData
(),
m_fill
_data
.
size
()
*
sizeof
(
float
));
m_
fill_buffer
.
release
();
}
if
(
m_
fill
_count
>
0
)
{
m_
fill_buffer
->
bind
();
m_
fill_buffer
->
allocate
(
m_fill_data
.
constData
(),
m_fill
_data
.
size
()
*
sizeof
(
float
));
m_
fill_buffer
->
release
();
if
(
m_
copy
_count
>
0
)
{
m_
copy_buffer
.
bind
();
m_
copy_buffer
.
allocate
(
m_copy_data
.
constData
(),
m_copy
_data
.
size
()
*
sizeof
(
float
));
m_
copy_buffer
.
release
();
}
if
(
m_draw_count
>
0
)
{
m_draw_buffer
->
bind
();
m_draw_buffer
->
allocate
(
m_draw_data
.
data
(),
m_draw_data
.
size
()
*
sizeof
(
float
));
m_draw_buffer
->
release
();
m_draw_buffer
.
bind
();
m_draw_buffer
.
allocate
(
m_draw_data
.
data
(),
m_draw_data
.
size
()
*
sizeof
(
float
));
m_draw_buffer
.
release
();
}
QOpenGLContext
::
currentContext
()
->
functions
()
->
glFlush
();
if
(
m_framebufferObject
!=
NULL
&&
m_framebufferObject
->
isBound
())
m_framebufferObject
->
release
();
}
void
Uploader
::
setFramebufferHeight
(
int
framebufferHeight
)
...
...
@@ -191,22 +215,22 @@ unsigned int Uploader::draw_count() const
return
m_draw_count
;
}
Q
SharedPointer
<
QVector
<
copy
>>
Uploader
::
copy_source
()
Q
OpenGLBuffer
Uploader
::
fill_buffer
()
{
return
m_
copy_source
;
return
m_
fill_buffer
;
}
QSharedPointer
<
Q
OpenGLBuffer
>
Uploader
::
copy_buffer
()
QSharedPointer
<
Q
Vector
<
copy
>>
Uploader
::
copy_source
()
{
return
m_copy_
buffer
;
return
m_copy_
source
;
}
Q
SharedPointer
<
QOpenGLBuffer
>
Uploader
::
fill
_buffer
()
Q
OpenGLBuffer
Uploader
::
copy
_buffer
()
{
return
m_
fill
_buffer
;
return
m_
copy
_buffer
;
}
Q
SharedPointer
<
QOpenGLBuffer
>
Uploader
::
draw_buffer
()
Q
OpenGLBuffer
Uploader
::
draw_buffer
()
{
return
m_draw_buffer
;
}
...
...
@@ -216,7 +240,7 @@ QSharedPointer<QVector<QOpenGLTexture *>> Uploader::draw_textures()
return
m_draw_textures
;
}
QOpenGLContext
*
Uploader
::
uploader_context
()
const
void
Uploader
::
changeFramebufferObject
(
QOpenGLFramebufferObject
*
framebufferObject
)
{
return
m_uploader_contex
t
;
m_framebufferObject
=
framebufferObjec
t
;
}
uploader.h
View file @
249ab83a
#ifndef UPLOADER_H
#define UPLOADER_H
#include <QObject>
#include <QQuickWindow>
#include <QDebug>
#include <QVector>
...
...
@@ -9,6 +10,7 @@
#include <QOpenGLFunctions>
#include <QOpenGLBuffer>
#include <QOpenGLTexture>
#include <QOpenGLFramebufferObject>
#include <QThreadPool>
#include <QtAlgorithms>
#include <QSharedPointer>
...
...
@@ -21,8 +23,9 @@ typedef struct {
QOpenGLTexture
*
texture
;
}
copy
;
class
Uploader
class
Uploader
:
public
QObject
{
Q_OBJECT
public
:
Uploader
();
void
create_context
(
QOpenGLContext
*
context
);
...
...
@@ -38,34 +41,37 @@ public:
unsigned
int
copy_count
()
const
;
unsigned
int
draw_count
()
const
;
QOpenGLBuffer
fill_buffer
();
QSharedPointer
<
QVector
<
copy
>>
copy_source
();
QSharedPointer
<
QOpenGLBuffer
>
copy_buffer
();
QSharedPointer
<
QOpenGLBuffer
>
fill_buffer
();
QSharedPointer
<
QOpenGLBuffer
>
draw_buffer
();
QOpenGLBuffer
copy_buffer
();
QOpenGLBuffer
draw_buffer
();
QSharedPointer
<
QVector
<
QOpenGLTexture
*>>
draw_textures
();
QOpenGLContext
*
uploader_context
()
const
;
private
:
int
m_framebufferHeight
;
QOffscreenSurface
m_surface
;
QOpenGLContext
*
m_uploader_context
;
unsigned
int
m_copy_count
;
QVector
<
float
>
m_copy_data
;
QSharedPointer
<
QVector
<
copy
>>
m_copy_source
;
QSharedPointer
<
QOpenGLBuffer
>
m_copy_buffer
;
QOpenGLFramebufferObject
*
m_framebufferObject
;
unsigned
int
m_fill_count
;
QVector
<
float
>
m_fill_data
;
QSharedPointer
<
QOpenGLBuffer
>
m_fill_buffer
;
QOpenGLBuffer
m_fill_buffer
;
unsigned
int
m_copy_count
;
QVector
<
float
>
m_copy_data
;
QSharedPointer
<
QVector
<
copy
>>
m_copy_source
;
QOpenGLBuffer
m_copy_buffer
;
unsigned
int
m_draw_count
;
QVector
<
float
>
m_draw_data
;
Q
SharedPointer
<
QOpenGLBuffer
>
m_draw_buffer
;
Q
OpenGLBuffer
m_draw_buffer
;
QSharedPointer
<
QVector
<
QOpenGLTexture
*>>
m_draw_textures
;
uchar
m_decoders_running
;
public
slots
:
void
changeFramebufferObject
(
QOpenGLFramebufferObject
*
framebufferObject
);
};
#endif // UPLOADER_H
vncrenderer.cpp
View file @
249ab83a
#include "vncrenderer.h"
VncRenderer
::
VncRenderer
(
QQuickWindow
*
window
,
Q
SharedPointer
<
QOpenGLBuffer
>
fill_buffer
,
Q
OpenGLBuffer
fill_buffer
,
QSharedPointer
<
QVector
<
copy
>>
copy_source
,
Q
SharedPointer
<
QOpenGLBuffer
>
copy_buffer
,
Q
SharedPointer
<
QOpenGLBuffer
>
draw_buffer
,
Q
OpenGLBuffer
copy_buffer
,
Q
OpenGLBuffer
draw_buffer
,
QSharedPointer
<
QVector
<
QOpenGLTexture
*>>
draw_textures
,
QObject
*
parent
)
:
QObject
(
parent
),
m_window
(
window
),
m_fill_buffer
(
fill_buffer
),
m_copy_source
(
copy_source
),
m_copy_buffer
(
copy_buffer
),
m_draw_buffer
(
draw_buffer
),
m_draw_textures
(
draw_textures
)
,
m_clear
(
true
)
QObject
(
parent
),
m_window
(
window
),
m_
clear
(
true
),
m_
fill_buffer
(
fill_buffer
),
m_copy_source
(
copy_source
),
m_copy_buffer
(
copy_buffer
),
m_draw_buffer
(
draw_buffer
),
m_draw_textures
(
draw_textures
)
{
m_draw_buffer
->
create
();
/*QOpenGLShader fill_vshader(QOpenGLShader::Vertex, &m_fill_program);
fill_vshader.compileSourceCode("uniform highp mat4 ortho;\n"
"attribute highp vec2 position;\n"
"attribute lowp vec3 color;\n"
"varying lowp vec4 varcolor;\n"
"void main(void)\n"
"{\n"
" varcolor = vec4(color, 1.0);\n"
" gl_Position = ortho * vec4(position, 0.0, 1.0);\n"
"}\n");
QOpenGLShader fill_fshader(QOpenGLShader::Fragment, &m_fill_program);
fill_fshader.compileSourceCode("varying lowp vec4 varcolor;\n"
"void main(void)\n"
"{\n"
" gl_FragColor = varcolor;\n"
"}\n");
m_fill_program.addShader(&fill_vshader);
m_fill_program.addShader(&fill_fshader);
m_fill_program.link();
m_fill_program
.
addShaderFromSourceFile
(
QOpenGLShader
::
Vertex
,
"fill_shader.vsh"
);
m_fill_program
.
addShaderFromSourceFile
(
QOpenGLShader
::
Fragment
,
"fill_shader.fsh"
);
m_fill_program
.
bind
();
m_fill_program
.
enableAttributeArray
(
"position"
);
m_fill_program.enableAttributeArray("color");*/
m_fill_program
.
enableAttributeArray
(
"color"
);
m_fill_program
.
release
();
m_draw_program
.
addShaderFromSourceFile
(
QOpenGLShader
::
Vertex
,
"draw_shader.vsh"
);
m_draw_program
.
addShaderFromSourceFile
(
QOpenGLShader
::
Fragment
,
"draw_shader.fsh"
);
...
...
@@ -42,34 +24,36 @@ VncRenderer::VncRenderer(QQuickWindow *window,
m_draw_program
.
enableAttributeArray
(
"position"
);
m_draw_program
.
enableAttributeArray
(
"texcoord"
);
m_draw_program
.
release
();
m_functions
=
QOpenGLContext
::
currentContext
()
->
functions
();
}
void
VncRenderer
::
render
()
{
QOpenGLFunctions
*
fun
=
m_window
->
openglContext
()
->
functions
();
if
(
m_clear
)
{
fun
->
glClearColor
(
1
.0
f
,
0.0
f
,
0.0
f
,
1.0
f
);
fun
->
glClear
(
GL_COLOR_BUFFER_BIT
);
m_functions
->
glClearColor
(
0
.0
f
,
0.0
f
,
0.0
f
,
1.0
f
);
m_functions
->
glClear
(
GL_COLOR_BUFFER_BIT
);
m_clear
=
false
;
}
/*
if(m_fill_count > 0) {
if
(
m_fill_count
>
0
)
{
m_fill_program
.
bind
();
m_fill_program
.
enableAttributeArray
(
"position"
);
m_fill_program
.
enableAttributeArray
(
"color"
);
m_fill_buffer
.
bind
();
m_fill_program.setAttributeBuffer("position", GL_FLOAT, 0
, 2, 3
* sizeof(float));
m_fill_program.setAttributeBuffer("color", GL_FLOAT, 2
, 3, 2
* sizeof(float));
m_fill_program
.
setAttributeBuffer
(
"position"
,
GL_FLOAT
,
0
*
sizeof
(
float
),
2
,
5
*
sizeof
(
float
));
m_fill_program
.
setAttributeBuffer
(
"color"
,
GL_FLOAT
,
2
*
sizeof
(
float
),
3
,
5
*
sizeof
(
float
));
for
(
unsigned
int
i
=
0
;
i
<
m_fill_count
;
i
++
)
fun->glDrawArrays(GL_TRIANGLES
, i * 4, 4);
m_functions
->
glDrawArrays
(
GL_TRIANGLE_STRIP
,
i
*
4
,
4
);
m_fill_buffer
.
release
();
m_fill_program
.
release
();
}
*/
if
(
m_copy_count
>
0
||
m_draw_count
>
0
)
m_draw_program
.
bind
();
m_draw_program
.
enableAttributeArray
(
"position"
);
m_draw_program
.
enableAttributeArray
(
"texcoord"
);
/*
if
(
m_copy_count
>
0
){
m_copy_buffer
.
bind
();
m_draw_program
.
setAttributeBuffer
(
"position"
,
GL_FLOAT
,
0
*
sizeof
(
float
),
2
,
4
*
sizeof
(
float
));
...
...
@@ -77,32 +61,32 @@ void VncRenderer::render()
for
(
unsigned
int
i
=
0
;
i
<
m_copy_count
;
i
++
)
{
m_copy_source
->
at
(
i
).
texture
->
bind
();
fun
->glCopyTexImage2D(GL_TEXTURE_2D,
0,
GL_RGBA,
m_copy_source->at(i).src_x,
m_copy_source->at(i).src_y,
m_copy_source->at(i).width,
m_copy_source->at(i).height,
0);
fun
->glDrawArrays(GL_TRIANGLE_STRIP, i * 4, 4);
/*m_functions
->glCopyTexImage2D(GL_TEXTURE_2D,
0,
GL_RGBA,
m_copy_source->at(i).src_x,
m_copy_source->at(i).src_y,
m_copy_source->at(i).width,
m_copy_source->at(i).height,
0);*/
m_functions
->
glDrawArrays
(
GL_TRIANGLE_STRIP
,
i
*
4
,
4
);
m_copy_source
->
at
(
i
).
texture
->
release
();
}
m_copy_buffer
.
release
();
}
*/
}
if
(
m_draw_count
>
0
)
{
m_draw_buffer
->
bind
();
m_draw_buffer
.
bind
();
m_draw_program
.
setAttributeBuffer
(
"position"
,
GL_FLOAT
,
0
*
sizeof
(
float
),
2
,
4
*
sizeof
(
float
));
m_draw_program
.
setAttributeBuffer
(
"texcoord"
,
GL_FLOAT
,
2
*
sizeof
(
float
),
2
,
4
*
sizeof
(
float
));
for
(
unsigned
int
i
=
0
;
i
<
m_draw_count
;
i
++
)
{
m_draw_textures
->
at
(
i
)
->
bind
();
fun
->
glDrawArrays
(
GL_TRIANGLE_STRIP
,
i
*
4
,
4
);
m_functions
->
glDrawArrays
(
GL_TRIANGLE_STRIP
,
i
*
4
,
4
);
m_draw_textures
->
at
(
i
)
->
release
();
}
m_draw_buffer
->
release
();
m_draw_buffer
.
release
();
}
if
(
m_copy_count
>
0
||
m_draw_count
>
0
)
...
...
@@ -117,13 +101,15 @@ QOpenGLFramebufferObject *VncRenderer::createFramebufferObject(const QSize &size
{
QMatrix4x4
ortho
;
ortho
.
ortho
(
QRect
(
QPoint
(
0
,
size
.
height
()),
QSize
(
size
.
width
(),
-
1
*
size
.
height
())));
//
m_fill_program.bind();
//
m_fill_program.setUniformValue("ortho", ortho);
m_fill_program
.
bind
();
m_fill_program
.
setUniformValue
(
"ortho"
,
ortho
);
m_draw_program
.
bind
();
m_draw_program
.
setUniformValue
(
"ortho"
,
ortho
);
m_draw_program
.
release
();
return
new
QOpenGLFramebufferObject
(
size
);
QOpenGLFramebufferObject
*
framebufferObject
=
new
QOpenGLFramebufferObject
(
size
);
emit
framebufferObjectChanged
(
framebufferObject
);
return
framebufferObject
;
}
void
VncRenderer
::
synchronize
(
QQuickFramebufferObject
*
object
)
...
...
@@ -133,4 +119,8 @@ void VncRenderer::synchronize(QQuickFramebufferObject *object)
m_fill_count
=
dispatcher
->
fill_count
();
m_copy_count
=
dispatcher
->
copy_count
();
m_draw_count
=
dispatcher
->
draw_count
();
m_fill_program
.
bind
();
m_fill_program
.
setUniformValue
(
"colormax"
,
dispatcher
->
colorMax
());
m_fill_program
.
release
();
}
vncrenderer.h
View file @
249ab83a
...
...
@@ -18,11 +18,11 @@ class VncRenderer : public QObject, public QQuickFramebufferObject::Renderer
{
Q_OBJECT
public
:
VncRenderer
(
QQuickWindow
*
window
,
Q
SharedPointer
<
QOpenGLBuffer
>
fill_buffer
,
VncRenderer
(
QQuickWindow
*
window
,
Q
OpenGLBuffer
fill_buffer
,
QSharedPointer
<
QVector
<
copy
>>
copy_source
,
Q
SharedPointer
<
QOpenGLBuffer
>
copy_buffer
,
Q
SharedPointer
<
QOpenGLBuffer
>
draw_buffer
,
Q
OpenGLBuffer
copy_buffer
,
Q
OpenGLBuffer
draw_buffer
,
QSharedPointer
<
QVector
<
QOpenGLTexture
*>>
draw_textures
,
QObject
*
parent
=
0
);
protected
:
...
...
@@ -31,24 +31,23 @@ protected:
void
synchronize
(
QQuickFramebufferObject
*
)
override
;
private
:
QQuickWindow
*
m_window
;
QOpenGLFunctions
*
m_functions
;
bool
m_clear
;
unsigned
int
m_fill_count
;
QOpenGLShaderProgram
m_fill_program
;
Q
SharedPointer
<
QOpenGLBuffer
>
m_fill_buffer
;
Q
OpenGLBuffer
m_fill_buffer
;
unsigned
int
m_copy_count
;
QSharedPointer
<
QVector
<
copy
>>
m_copy_source
;
Q
SharedPointer
<
QOpenGLBuffer
>
m_copy_buffer
;
Q
OpenGLBuffer
m_copy_buffer
;
unsigned
int
m_draw_count
;
QOpenGLShaderProgram
m_draw_program
;
Q
SharedPointer
<
QOpenGLBuffer
>
m_draw_buffer
;
Q
OpenGLBuffer
m_draw_buffer
;
QSharedPointer
<
QVector
<
QOpenGLTexture
*>>
m_draw_textures
;
QMatrix4x4
m_ortho
;
bool
m_clear
;
signals
:
void
framebufferObjectChanged
(
QOpenGLFramebufferObject
*
framebufferObject
);
void
finishedRendering
();
};
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment