Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Open sidebar
C-Fu
OpenGL
Commits
dca6e61c
Commit
dca6e61c
authored
Dec 31, 2016
by
Anakin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
parent matrix works,
texture works, next fix multimodel problem
parent
3758a260
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
36 additions
and
17 deletions
+36
-17
QtMeshViewer/Header/GeometryEngine.h
QtMeshViewer/Header/GeometryEngine.h
+2
-2
QtMeshViewer/Source/GeometryEngine.cpp
QtMeshViewer/Source/GeometryEngine.cpp
+34
-14
QtMeshViewer/Source/MshFile.cpp
QtMeshViewer/Source/MshFile.cpp
+0
-1
No files found.
QtMeshViewer/Header/GeometryEngine.h
View file @
dca6e61c
...
...
@@ -25,8 +25,8 @@ private:
QVector
<
QOpenGLTexture
*>
m_textures
;
QVector
<
DrawInformation
>
m_drawList
;
void
initCubeGeometry
(
);
void
init
Texture
();
void
loadFile
(
const
char
*
filePath
);
void
load
Texture
(
const
char
*
filePath
);
public:
void
drawGeometry
(
QOpenGLShaderProgram
*
program
);
...
...
QtMeshViewer/Source/GeometryEngine.cpp
View file @
dca6e61c
...
...
@@ -15,7 +15,7 @@ GeometryEngine::GeometryEngine()
m_indexBuf
.
create
();
// Initializes cube geometry and transfers it to VBOs
initCubeGeometry
(
);
loadFile
(
"..
\\
Release
\\
Msh
\\
triClothMan.msh"
);
}
GeometryEngine
::~
GeometryEngine
()
...
...
@@ -33,18 +33,21 @@ GeometryEngine::~GeometryEngine()
/////////////////////////////////////////////////////////////////////////
// private functions
void
GeometryEngine
::
initCubeGeometry
(
)
void
GeometryEngine
::
loadFile
(
const
char
*
filePath
)
{
QVector
<
Model
*>*
models
;
QVector
<
VertexData
>
vertexData
;
QVector
<
GLuint
>
indexData
;
try
{
MshFile
file
(
"..
\\
Release
\\
Msh
\\
triClothMan.msh"
);
models
=
file
.
getModels
();
//TODO normalize
//TODO: handle the textures
QVector
<
Model
*>*
models
;
QVector
<
std
::
string
>*
textureNames
;
QVector
<
VertexData
>
vertexData
;
QVector
<
GLuint
>
indexData
;
// open file and get the information
MshFile
file
(
filePath
);
models
=
file
.
getModels
();
textureNames
=
file
.
getTextureNames
();
// collect data
unsigned
int
offsetCount
(
0
);
...
...
@@ -73,6 +76,8 @@ void GeometryEngine::initCubeGeometry()
}
}
//TODO: cleanup old stuff
// Transfer vertex data to VBO 0
m_arrayBuf
.
bind
();
m_arrayBuf
.
allocate
(
vertexData
.
data
(),
vertexData
.
size
()
*
sizeof
(
VertexData
));
...
...
@@ -81,8 +86,15 @@ void GeometryEngine::initCubeGeometry()
m_indexBuf
.
bind
();
m_indexBuf
.
allocate
(
indexData
.
data
(),
indexData
.
size
()
*
sizeof
(
GLuint
));
// load the texture
initTexture
();
// get textures path
std
::
string
path
=
filePath
;
while
(
path
.
back
()
!=
'/'
&&
path
.
back
()
!=
'\\'
)
path
.
pop_back
();
// load the textures
for
(
auto
&
it
:
*
textureNames
)
loadTexture
(
std
::
string
(
path
+
it
).
c_str
());
}
catch
(
std
::
invalid_argument
e
)
...
...
@@ -94,10 +106,18 @@ void GeometryEngine::initCubeGeometry()
}
void
GeometryEngine
::
init
Texture
()
void
GeometryEngine
::
load
Texture
(
const
char
*
filePath
)
{
// Load cube.png image
QOpenGLTexture
*
new_texture
=
new
QOpenGLTexture
(
QImage
(
":images/cube.png"
).
mirrored
());
QImage
img
;
if
(
!
img
.
load
(
filePath
))
{
img
=
QImage
(
1
,
1
,
QImage
::
Format_RGB32
);
img
.
fill
(
Qt
::
red
);
}
// Load image to OglTexture
QOpenGLTexture
*
new_texture
=
new
QOpenGLTexture
(
img
.
mirrored
());
// Set nearest filtering mode for texture minification
new_texture
->
setMinificationFilter
(
QOpenGLTexture
::
Nearest
);
...
...
QtMeshViewer/Source/MshFile.cpp
View file @
dca6e61c
...
...
@@ -17,7 +17,6 @@ MshFile::MshFile(const char * path)
MshFile
::~
MshFile
()
{
//TODO: clean up
}
...
...
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