Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
OpenGL
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Container registry
Model registry
Analyze
Contributor analytics
Repository analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
C-Fu
OpenGL
Commits
211b406c
Commit
211b406c
authored
8 years ago
by
Anakin
Browse files
Options
Downloads
Patches
Plain Diff
dynamical decide whether to use the given texture or solid red
parent
c3d73895
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
MshViewer/Header/Object.h
+1
-0
1 addition, 0 deletions
MshViewer/Header/Object.h
MshViewer/Source/Object.cpp
+16
-3
16 additions, 3 deletions
MshViewer/Source/Object.cpp
MshViewer/Source/OpenGlController.cpp
+16
-6
16 additions, 6 deletions
MshViewer/Source/OpenGlController.cpp
with
33 additions
and
9 deletions
MshViewer/Header/Object.h
+
1
−
0
View file @
211b406c
...
...
@@ -71,5 +71,6 @@ private:
public:
std
::
vector
<
GLfloat
>
getVertex
()
const
;
std
::
vector
<
GLfloat
>
getUV
()
const
;
std
::
list
<
std
::
string
>
getTexture
()
const
;
};
This diff is collapsed.
Click to expand it.
MshViewer/Source/Object.cpp
+
16
−
3
View file @
211b406c
...
...
@@ -148,9 +148,10 @@ void Object::analyseModlChunks(Modl* dataDestination, std::list<ChunkHeader*>& c
if
(
!
strcmp
(
"PRNT"
,
(
*
it
)
->
name
))
{
fsMesh
.
seekg
((
*
it
)
->
position
);
char
tempName
[
33
]
=
{
0
};
fsMesh
.
read
(
reinterpret_cast
<
char
*>
(
&
tempName
[
0
]),
(
*
it
)
->
size
>
32
?
32
:
(
*
it
)
->
size
);
dataDestination
->
parent
=
tempName
;
char
*
buffer
=
new
char
[(
*
it
)
->
size
];
fsMesh
.
read
(
buffer
,
(
*
it
)
->
size
);
dataDestination
->
parent
=
buffer
;
delete
buffer
;
continue
;
}
...
...
@@ -160,6 +161,7 @@ void Object::analyseModlChunks(Modl* dataDestination, std::list<ChunkHeader*>& c
char
*
buffer
=
new
char
[(
*
it
)
->
size
];
fsMesh
.
read
(
buffer
,
(
*
it
)
->
size
);
dataDestination
->
name
=
buffer
;
delete
buffer
;
continue
;
}
...
...
@@ -373,6 +375,7 @@ void Object::analyseClthChunks(Modl * dataDestination, std::list<ChunkHeader*>&
char
*
buffer
=
new
char
[(
*
it
)
->
size
];
fsMesh
.
read
(
buffer
,
(
*
it
)
->
size
);
dataDestination
->
texture
=
buffer
;
delete
buffer
;
continue
;
}
...
...
@@ -491,6 +494,16 @@ std::vector<GLfloat> Object::getUV() const
return
tempData
;
}
std
::
list
<
std
::
string
>
Object
::
getTexture
()
const
{
std
::
list
<
std
::
string
>
tempData
;
for
(
std
::
list
<
Modl
*>::
const_iterator
it
=
lModls
.
begin
();
it
!=
lModls
.
end
();
it
++
)
tempData
.
push_back
((
*
it
)
->
texture
);
return
tempData
;
}
/////////////////////////////////////////////////////////////////////////
// public functions
...
...
This diff is collapsed.
Click to expand it.
MshViewer/Source/OpenGlController.cpp
+
16
−
6
View file @
211b406c
...
...
@@ -296,12 +296,22 @@ void OpenGLController::loadMsh(const char * path)
glGenTextures
(
1
,
&
gluiTextureID
);
glBindTexture
(
GL_TEXTURE_2D
,
gluiTextureID
);
// if texture && open ok, then
//TextureTGA tempTex(TEXTURE_NAME);
//glTexImage2D(GL_TEXTURE_2D, 0, tempTex.hasAlpha() ? GL_RGBA : GL_RGB, tempTex.getWidth(), tempTex.getHeight(), 0, tempTex.hasAlpha() ? GL_BGRA : GL_BGR, GL_UNSIGNED_BYTE, tempTex.getData().data());
// else
std
::
list
<
std
::
string
>
listTextures
;
try
{
if
(
listTextures
.
empty
())
throw
std
::
invalid_argument
(
"no texture names"
);
TextureTGA
tempTex
(
listTextures
.
front
().
c_str
());
glTexImage2D
(
GL_TEXTURE_2D
,
0
,
tempTex
.
hasAlpha
()
?
GL_RGBA
:
GL_RGB
,
tempTex
.
getWidth
(),
tempTex
.
getHeight
(),
0
,
tempTex
.
hasAlpha
()
?
GL_BGRA
:
GL_BGR
,
GL_UNSIGNED_BYTE
,
tempTex
.
getData
().
data
());
}
catch
(
std
::
invalid_argument
e
)
{
GLubyte
solidColor
[
4
]
=
{
255
,
0
,
0
,
255
};
glTexImage2D
(
GL_TEXTURE_2D
,
0
,
GL_RGBA
,
1
,
1
,
0
,
GL_RGBA
,
GL_UNSIGNED_BYTE
,
(
const
GLvoid
*
)
solidColor
);
}
glTexParameteri
(
GL_TEXTURE_2D
,
GL_TEXTURE_WRAP_S
,
GL_REPEAT
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment