Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
OpenGL
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Requirements
Requirements
List
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
Insights
Issue
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
C-Fu
OpenGL
Commits
1cbc9336
Commit
1cbc9336
authored
Nov 05, 2016
by
Anakin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixing some problems,
trying to draw instanced, now it crashes
parent
9c12598b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
9 deletions
+24
-9
MshViewer/Source/OpenGlController.cpp
MshViewer/Source/OpenGlController.cpp
+24
-9
No files found.
MshViewer/Source/OpenGlController.cpp
View file @
1cbc9336
...
...
@@ -92,15 +92,27 @@ void OpenGLController::processInit()
glBindBuffer
(
GL_ARRAY_BUFFER
,
0
);
glBindBuffer
(
GL_ARRAY_BUFFER
,
gluiInstanceBufferID
);
glVertexAttribPointer
(
2
,
4
,
GL_FLOAT
,
GL_FALSE
,
sizeof
(
glm
::
mat4
),
(
void
*
)(
sizeof
(
GL
_FLOAT
)
*
0
));
glVertexAttribPointer
(
3
,
4
,
GL_FLOAT
,
GL_FALSE
,
sizeof
(
glm
::
mat4
),
(
void
*
)(
sizeof
(
GL
_FLOAT
)
*
4
));
glVertexAttribPointer
(
4
,
4
,
GL_FLOAT
,
GL_FALSE
,
sizeof
(
glm
::
mat4
),
(
void
*
)(
sizeof
(
GL
_FLOAT
)
*
8
));
glVertexAttribPointer
(
5
,
4
,
GL_FLOAT
,
GL_FALSE
,
sizeof
(
glm
::
mat4
),
(
void
*
)(
sizeof
(
GL
_FLOAT
)
*
12
));
glVertexAttribPointer
(
2
,
4
,
GL_FLOAT
,
GL_FALSE
,
sizeof
(
glm
::
mat4
),
(
void
*
)(
sizeof
(
GL
float
)
*
0
));
glVertexAttribPointer
(
3
,
4
,
GL_FLOAT
,
GL_FALSE
,
sizeof
(
glm
::
mat4
),
(
void
*
)(
sizeof
(
GL
float
)
*
4
));
glVertexAttribPointer
(
4
,
4
,
GL_FLOAT
,
GL_FALSE
,
sizeof
(
glm
::
mat4
),
(
void
*
)(
sizeof
(
GL
float
)
*
8
));
glVertexAttribPointer
(
5
,
4
,
GL_FLOAT
,
GL_FALSE
,
sizeof
(
glm
::
mat4
),
(
void
*
)(
sizeof
(
GL
float
)
*
12
));
glBindBuffer
(
GL_ARRAY_BUFFER
,
0
);
// enable position, UV and mvp
glEnableVertexAttribArray
(
0
);
glEnableVertexAttribArray
(
1
);
glEnableVertexAttribArray
(
2
);
glEnableVertexAttribArray
(
3
);
glEnableVertexAttribArray
(
4
);
glEnableVertexAttribArray
(
5
);
// MPV only once per instance
glVertexAttribDivisor
(
2
,
1
);
glVertexAttribDivisor
(
3
,
1
);
glVertexAttribDivisor
(
4
,
1
);
glVertexAttribDivisor
(
5
,
1
);
// get the painter ready
try
{
...
...
@@ -251,10 +263,13 @@ void OpenGLController::updateScene()
// use shader prgm
glUseProgram
(
gluiShaderPrgmID
);
// tell shader transformation
//glUniformMatrix4fv(gluiMatrixID, 1, GL_FALSE, &getMVPMatrix()[0][0]);
// fill vector with MVPs of all Models (only 1 for testing)
std
::
vector
<
glm
::
mat4
>
mvpMatrices
;
mvpMatrices
.
push_back
(
getMVPMatrix
());
// give the MVPs to the shader
glBindBuffer
(
GL_UNIFORM_BUFFER
,
gluiInstanceBufferID
);
glBuffer
Data
(
GL_UNIFORM_BUFFER
,
sizeof
(
glm
::
mat4
)
*
1
,
NULL
,
GL_STREAM_DRAW
);
glBuffer
SubData
(
GL_UNIFORM_BUFFER
,
sizeof
(
glm
::
mat4
)
*
mvpMatrices
.
size
(),
NULL
,
mvpMatrices
.
data
()
);
glBindBuffer
(
GL_UNIFORM_BUFFER
,
0
);
// bind texture in texture unit 0
...
...
@@ -263,8 +278,8 @@ void OpenGLController::updateScene()
// tell sampler to use texture unit 0
glUniform1i
(
gluiSamplerID
,
0
);
//draw objects
glDrawArrays
(
GL_TRIANGLES
,
0
,
vModels
.
front
()
->
meshSize
);
//draw objects
hardcoded only 1 instance for testing
glDrawArrays
Instanced
(
GL_TRIANGLES
,
0
,
vModels
.
front
()
->
meshSize
,
1
);
glfwSwapBuffers
(
pWindow
);
glfwPollEvents
();
...
...
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