Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
U
Unterteilungsalgorithmen
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
3
Issues
3
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kai Westerkamp
Unterteilungsalgorithmen
Commits
84b5aebf
Commit
84b5aebf
authored
Jun 30, 2016
by
Philipp Adolf
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Return result from runShader
parent
af72c003
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
4 deletions
+17
-4
subdivision.cpp
QTProject/subdivision.cpp
+10
-3
subdivision.h
QTProject/subdivision.h
+7
-1
No files found.
QTProject/subdivision.cpp
View file @
84b5aebf
...
@@ -56,7 +56,8 @@ Mesh *Subdivision::subdivide(Mesh *mesh) {
...
@@ -56,7 +56,8 @@ Mesh *Subdivision::subdivide(Mesh *mesh) {
input
.
index_buffer
=
current_mesh
->
getIndexBuffer
();
input
.
index_buffer
=
current_mesh
->
getIndexBuffer
();
Tables
tables
=
precomputeTables
(
input
);
Tables
tables
=
precomputeTables
(
input
);
runShader
(
input
,
tables
);
Result
result
=
runShader
(
input
,
tables
);
return
NULL
;
return
NULL
;
}
}
...
@@ -317,9 +318,11 @@ Subdivision::Tables Subdivision::precomputeTables(Input input) {
...
@@ -317,9 +318,11 @@ Subdivision::Tables Subdivision::precomputeTables(Input input) {
return
tables
;
return
tables
;
}
}
void
Subdivision
::
runShader
(
Input
input
,
Tables
&
tables
)
{
Subdivision
::
Result
Subdivision
::
runShader
(
Input
input
,
Tables
&
tables
)
{
qDebug
()
<<
"Running compute shader"
;
qDebug
()
<<
"Running compute shader"
;
Result
result
;
// Create an input buffer for the vertex indices
// Create an input buffer for the vertex indices
GLuint
vertex_indices_handle
;
GLuint
vertex_indices_handle
;
f
->
glGenBuffers
(
1
,
&
vertex_indices_handle
);
f
->
glGenBuffers
(
1
,
&
vertex_indices_handle
);
...
@@ -343,6 +346,7 @@ void Subdivision::runShader(Input input, Tables &tables) {
...
@@ -343,6 +346,7 @@ void Subdivision::runShader(Input input, Tables &tables) {
f
->
glGenBuffers
(
1
,
&
output_handle
);
f
->
glGenBuffers
(
1
,
&
output_handle
);
f
->
glBindBuffer
(
GL_SHADER_STORAGE_BUFFER
,
output_handle
);
f
->
glBindBuffer
(
GL_SHADER_STORAGE_BUFFER
,
output_handle
);
f
->
glBufferData
(
GL_SHADER_STORAGE_BUFFER
,
(
input
.
vertex_buffer
.
size
()
+
tables
.
edge_indices
.
size
()
/
4
)
*
sizeof
(
Vertex
),
NULL
,
GL_DYNAMIC_DRAW
);
f
->
glBufferData
(
GL_SHADER_STORAGE_BUFFER
,
(
input
.
vertex_buffer
.
size
()
+
tables
.
edge_indices
.
size
()
/
4
)
*
sizeof
(
Vertex
),
NULL
,
GL_DYNAMIC_DRAW
);
result
.
vb_handle
=
output_handle
;
f
->
glBindBuffer
(
GL_SHADER_STORAGE_BUFFER
,
0
);
f
->
glBindBuffer
(
GL_SHADER_STORAGE_BUFFER
,
0
);
...
@@ -357,10 +361,12 @@ void Subdivision::runShader(Input input, Tables &tables) {
...
@@ -357,10 +361,12 @@ void Subdivision::runShader(Input input, Tables &tables) {
qDebug
()
<<
"New vertices:"
;
qDebug
()
<<
"New vertices:"
;
for
(
int
i
=
0
;
i
<
input
.
vertex_buffer
.
size
();
i
++
)
{
for
(
int
i
=
0
;
i
<
input
.
vertex_buffer
.
size
();
i
++
)
{
qDebug
()
<<
ptr
[
i
].
pos
;
qDebug
()
<<
ptr
[
i
].
pos
;
result
.
vertex_buffer
.
push_back
(
ptr
[
i
]);
}
}
qDebug
()
<<
"New edge points:"
;
qDebug
()
<<
"New edge points:"
;
for
(
int
i
=
0
;
i
<
tables
.
edge_indices
.
size
()
/
4
;
i
++
)
{
for
(
int
i
=
0
;
i
<
tables
.
edge_indices
.
size
()
/
4
;
i
++
)
{
qDebug
()
<<
ptr
[
edgeOffset
+
i
].
pos
;
qDebug
()
<<
ptr
[
edgeOffset
+
i
].
pos
;
result
.
vertex_buffer
.
push_back
(
ptr
[
edgeOffset
+
i
]);
}
}
f
->
glUnmapBuffer
(
GL_SHADER_STORAGE_BUFFER
);
f
->
glUnmapBuffer
(
GL_SHADER_STORAGE_BUFFER
);
...
@@ -368,7 +374,8 @@ void Subdivision::runShader(Input input, Tables &tables) {
...
@@ -368,7 +374,8 @@ void Subdivision::runShader(Input input, Tables &tables) {
f
->
glDeleteBuffers
(
1
,
&
vertex_indices_handle
);
f
->
glDeleteBuffers
(
1
,
&
vertex_indices_handle
);
f
->
glDeleteBuffers
(
1
,
&
vertex_offsets_handle
);
f
->
glDeleteBuffers
(
1
,
&
vertex_offsets_handle
);
f
->
glDeleteBuffers
(
1
,
&
edge_indices_handle
);
f
->
glDeleteBuffers
(
1
,
&
edge_indices_handle
);
f
->
glDeleteBuffers
(
1
,
&
output_handle
);
return
result
;
}
}
void
Subdivision
::
runVertexShader
(
GLuint
size
,
GLuint
vb_handle
,
GLuint
vertex_indices_handle
,
GLuint
vertex_offsets_handle
,
GLuint
output_handle
)
{
void
Subdivision
::
runVertexShader
(
GLuint
size
,
GLuint
vb_handle
,
GLuint
vertex_indices_handle
,
GLuint
vertex_offsets_handle
,
GLuint
output_handle
)
{
...
...
QTProject/subdivision.h
View file @
84b5aebf
...
@@ -31,13 +31,19 @@ private:
...
@@ -31,13 +31,19 @@ private:
QVector
<
GLuint
>
index_buffer
;
QVector
<
GLuint
>
index_buffer
;
};
};
struct
Result
{
GLuint
vb_handle
;
QVector
<
Vertex
>
vertex_buffer
;
};
QOpenGLFunctions_4_3_Core
*
f
;
QOpenGLFunctions_4_3_Core
*
f
;
QOpenGLShaderProgram
*
edgeShader
;
QOpenGLShaderProgram
*
edgeShader
;
QOpenGLShaderProgram
*
vertexShader
;
QOpenGLShaderProgram
*
vertexShader
;
QOpenGLShaderProgram
*
initComputeShaderProgram
(
QString
&
source
);
QOpenGLShaderProgram
*
initComputeShaderProgram
(
QString
&
source
);
Tables
precomputeTables
(
Input
input
);
Tables
precomputeTables
(
Input
input
);
void
runShader
(
Input
input
,
Tables
&
tables
);
Result
runShader
(
Input
input
,
Tables
&
tables
);
void
runVertexShader
(
GLuint
size
,
GLuint
vb_handle
,
GLuint
vertex_indices_handle
,
GLuint
vertex_offsets_handle
,
GLuint
output_handle
);
void
runVertexShader
(
GLuint
size
,
GLuint
vb_handle
,
GLuint
vertex_indices_handle
,
GLuint
vertex_offsets_handle
,
GLuint
output_handle
);
void
runEdgeShader
(
GLuint
size
,
GLuint
vb_handle
,
GLuint
edge_indices_handle
,
GLuint
output_handle
,
GLuint
offset
);
void
runEdgeShader
(
GLuint
size
,
GLuint
vb_handle
,
GLuint
edge_indices_handle
,
GLuint
output_handle
,
GLuint
offset
);
};
};
...
...
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