Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
O
OpenFlipper
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Merge Requests
2
Merge Requests
2
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Container Registry
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Jobs
Commits
Open sidebar
OpenFlipper-Free
OpenFlipper
Commits
2ed6b317
Commit
2ed6b317
authored
Apr 26, 2019
by
Jascha Wedowski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
expose object / state query functionality in GLState
parent
19dd8917
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
136 additions
and
2 deletions
+136
-2
cmake/FindSPIRV.cmake
cmake/FindSPIRV.cmake
+26
-0
cmake/Findglslang.cmake
cmake/Findglslang.cmake
+35
-0
libs_required/ACG/GL/GLState.cc
libs_required/ACG/GL/GLState.cc
+48
-0
libs_required/ACG/GL/GLState.hh
libs_required/ACG/GL/GLState.hh
+26
-1
libs_required/ACG/GL/RenderObject.hh
libs_required/ACG/GL/RenderObject.hh
+1
-1
No files found.
cmake/FindSPIRV.cmake
0 → 100644
View file @
2ed6b317
# Try to find glslang/SPIRV
# Once done, this will define
# SPIRV_FOUND
# SPIRV_INCLUDE_DIR
# SPIRV_LIBRARIES
## SPIRV
find_path
(
SPIRV_INCLUDE_DIR
NAMES SPIRV/SpvTools.h
PATHS
"
${
CMAKE_SOURCE_DIR
}
/"
DOC
"SPIRV Include Directory"
)
find_library
(
SPIRV_LIBRARY
NAMES SPIRV
PATHS
"
${
CMAKE_SOURCE_DIR
}
/"
DOC
"SPIRV Libraries"
)
IF
(
SPIRV_LIBRARY
)
SET
(
SPIRV_FOUND TRUE
)
ELSE
(
SPIRV_LIBRARY
)
SET
(
SPIRV_FOUND FALSE
)
ENDIF
(
SPIRV_LIBRARY
)
cmake/Findglslang.cmake
0 → 100644
View file @
2ed6b317
# Try to find glslang
# Once done, this will define
# GLSLANG_FOUND
# GLSLANG_INCLUDE_DIR
# GLSLANG_LIBRARY
#
# SPIRV_FOUND
# SPIRV_INCLUDE_DIR
# SPIRV_LIBRARIES
## GLSLANG core
find_path
(
GLSLANG_INCLUDE_DIR
NAMES glslang/Include/Common.h
PATHS
"
${
CMAKE_SOURCE_DIR
}
/"
/home/
DOC
"GLSLANG Include Directory"
)
find_library
(
GLSLANG_LIBRARY
NAMES glslang
PATHS
"
${
CMAKE_SOURCE_DIR
}
/"
/usr/
/home/
DOC
"GLSLANG Libraries"
)
IF
(
GLSLANG_LIBRARY AND GLSLANG_INCLUDE_DIR
)
SET
(
GLSLANG_FOUND TRUE
)
ELSE
(
GLSLANG_LIBRARY AND GLSLANG_INCLUDE_DIR
)
SET
(
GLSLANG_FOUND FALSE
)
ENDIF
(
GLSLANG_LIBRARY AND GLSLANG_INCLUDE_DIR
)
libs_required/ACG/GL/GLState.cc
View file @
2ed6b317
...
...
@@ -1860,6 +1860,49 @@ GLuint GLState::getBoundBuf(GLenum _target)
return
stateStack_
.
back
().
glBufferTargetState_
[
getBufferTargetIndex
(
_target
)];
}
GLenum
GLState
::
getShaderType
(
GLuint
_shader
)
{
auto
isShader
=
glIsShader
(
_shader
);
if
(
isShader
==
GL_FALSE
)
{
return
GL_NONE
;
}
GLint
type
=
GL_NONE
;
glGetShaderiv
(
_shader
,
GL_SHADER_TYPE
,
&
type
);
return
static_cast
<
GLenum
>
(
type
);
}
GLuint
GLState
::
getAttachedShader
(
GLuint
_program
,
GLenum
_type
)
{
if
(
glIsProgram
(
_program
)
==
GL_FALSE
)
{
return
GL_NONE
;
}
// vertex, fragment, tess control, tess eval, geometry
static
const
GLsizei
maxNumShaders
=
5
;
GLuint
shaders
[
maxNumShaders
]
=
{};
GLsizei
numShaders
=
0
;
glGetAttachedShaders
(
_program
,
maxNumShaders
,
&
numShaders
,
shaders
);
for
(
auto
i
=
0
;
i
<
numShaders
;
++
i
)
{
const
auto
&
shader
=
shaders
[
i
];
if
(
getShaderType
(
shader
)
==
_type
)
{
return
shader
;
}
}
return
GL_NONE
;
}
size_t
GLState
::
getShaderSourceLength
(
GLuint
_shader
)
{
if
(
glIsShader
(
_shader
)
==
GL_FALSE
)
{
return
0
;
}
GLint
length
=
0
;
glGetShaderiv
(
_shader
,
GL_SHADER_SOURCE_LENGTH
,
&
length
);
return
static_cast
<
size_t
>
(
length
);
}
size_t
GLState
::
getShaderSource
(
GLuint
_shader
,
char
*
_buffer
,
size_t
_bufferSize
)
{
if
(
glIsShader
(
_shader
)
==
GL_FALSE
)
{
return
0
;
}
GLsizei
length
=
0
;
glGetShaderSource
(
_shader
,
static_cast
<
GLsizei
>
(
_bufferSize
),
&
length
,
_buffer
);
return
static_cast
<
size_t
>
(
length
);
}
//-----------------------------------------------------------------------------
void
GLState
::
activeTexture
(
GLenum
_texunit
)
...
...
@@ -2207,6 +2250,11 @@ GLboolean GLState::unmapBuffer (GLenum target) {
return
glUnmapBuffer
(
target
);
}
size_t
GLState
::
getBufferSize
(
GLenum
target
)
{
GLint
size
=
0
;
glGetBufferParameteriv
(
target
,
GL_BUFFER_SIZE
,
&
size
);
return
static_cast
<
size_t
>
(
size
);
}
//---------------------------------------------------------------------
...
...
libs_required/ACG/GL/GLState.hh
View file @
2ed6b317
...
...
@@ -570,6 +570,12 @@ public:
*/
static
GLboolean
unmapBuffer
(
GLenum
target
);
/**
* Wraps glGetBufferParameteriv for GL_BUFFER_SIZE
* Useful where glew cannot be included
*/
static
size_t
getBufferSize
(
GLenum
_target
);
/**
* Simple wrapper around glDeleteBuffers.
* Useful where glew cannot be included.
...
...
@@ -593,7 +599,26 @@ public:
/// get currently bound buffer
static
GLuint
getBoundBuf
(
GLenum
_target
);
/// get the type of a shader object
/// returns GL_NONE if the passed name doesn't identify a valid shader object
static
GLenum
getShaderType
(
GLuint
_shader
);
/// get the length of a shaders source
/// returns 0 on failure
static
size_t
getShaderSourceLength
(
GLuint
_shader
);
/// get glsl source from a shader object
/// expects a char array of sufficient size, size can be queried with getShaderSourceLength() before calling this
/// returns the actual size of the source string, excluding null terminator
static
size_t
getShaderSource
(
GLuint
_shader
,
char
*
_buffer
,
size_t
_bufferSize
);
/// get the attached shader of type of a program
/// NOTE: this assumes that only _one_ shader of any type is attached to the program!
/// returns GL_NONE if the program doesn't have a shader of requested type attached or if the passed name doesn't
/// identify a valid shader program
static
GLuint
getAttachedShader
(
GLuint
_program
,
GLenum
_type
);
/// replaces glDrawBuffer, supports locking
static
void
drawBuffer
(
GLenum
_mode
);
/// replaces glDrawBuffers, supports locking
...
...
libs_required/ACG/GL/RenderObject.hh
View file @
2ed6b317
...
...
@@ -167,7 +167,7 @@ struct ACGDLLEXPORT RenderObject
/// VBO, IBO ids, ignored if VAO is provided
GLuint
vertexBuffer
,
indexBuffer
;
indexBuffer
;
/** \brief Use system memory index buffer
*
...
...
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