Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
CommonGUI
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Frédéric Larue
CommonGUI
Commits
b4071b0b
Commit
b4071b0b
authored
Apr 15, 2018
by
Frédéric Larue
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Functions added to the GPU module for best computation of GL pack/unpack alignment
parent
9241ccac
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
90 additions
and
0 deletions
+90
-0
GPU/Alignment.h
GPU/Alignment.h
+89
-0
GPU/GPU.h
GPU/GPU.h
+1
-0
No files found.
GPU/Alignment.h
0 → 100644
View file @
b4071b0b
/*
* (c) LSIIT, UMR CNRS/UdS
* Authors: F. Larue.
*
* See licence.txt for additional information.
*/
#ifndef __GPU__ALIGNMENT_H__
#define __GPU__ALIGNMENT_H__
#include "GPUdefs.h"
#include <assert.h>
namespace
GPU
{
inline
unsigned
int
ChannelCount
(
GLenum
format
)
{
switch
(
format
)
{
case
GL_LUMINANCE
:
return
1
;
case
GL_RGB
:
return
3
;
case
GL_RGBA
:
return
4
;
default
:
assert
(
false
);
}
return
0
;
}
inline
unsigned
int
TypeSize
(
GLenum
type
)
{
switch
(
type
)
{
case
GL_UNSIGNED_BYTE
:
return
sizeof
(
GLubyte
);
case
GL_BYTE
:
return
sizeof
(
GLbyte
);
case
GL_UNSIGNED_SHORT
:
return
sizeof
(
GLushort
);
case
GL_SHORT
:
return
sizeof
(
GLshort
);
case
GL_UNSIGNED_INT
:
return
sizeof
(
GLuint
);
case
GL_INT
:
return
sizeof
(
GLint
);
case
GL_FLOAT
:
return
sizeof
(
GLfloat
);
case
GL_DOUBLE
:
return
sizeof
(
GLdouble
);
default
:
assert
(
false
);
}
return
0
;
}
inline
unsigned
int
PixelSize
(
GLenum
format
,
GLenum
type
)
{
return
ChannelCount
(
format
)
*
TypeSize
(
type
);
}
inline
void
SetAlignment
(
GLenum
alignParam
,
unsigned
int
stride
)
{
static
const
int
alignment
[
8
]
=
{
8
,
1
,
2
,
1
,
4
,
1
,
2
,
1
};
glPixelStorei
(
alignParam
,
alignment
[
stride
&
7
]
);
}
inline
void
SetPackAlignment
(
unsigned
int
stride
)
{
SetAlignment
(
GL_PACK_ALIGNMENT
,
stride
);
}
inline
void
SetPackAlignment
(
unsigned
int
width
,
GLenum
format
,
GLenum
type
)
{
SetPackAlignment
(
width
*
PixelSize
(
format
,
type
)
);
}
inline
void
SetUnpackAlignment
(
unsigned
int
stride
)
{
SetAlignment
(
GL_UNPACK_ALIGNMENT
,
stride
);
}
inline
void
SetUnpackAlignment
(
unsigned
int
width
,
GLenum
format
,
GLenum
type
)
{
SetUnpackAlignment
(
width
*
PixelSize
(
format
,
type
)
);
}
}
#endif //__GPU__ALIGNMENT_H__
GPU/GPU.h
View file @
b4071b0b
...
...
@@ -12,6 +12,7 @@
#include "Alignment.h"
#include "Shader.h"
#include "VBO.h"
#include "FrameBuffer.h"
...
...
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