Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
angle
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Chen Yisong
angle
Commits
b7915a55
Commit
b7915a55
authored
Nov 12, 2011
by
daniel@transgaming.com
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add the ReadnPixelsEXT command
Trac #18608 Signed-off-by: Nicolas Capens git-svn-id:
https://angleproject.googlecode.com/svn/trunk@865
736b8ea6-26fd-11df-bfd4-992fa37f6226
parent
9112d2a9
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
91 additions
and
36 deletions
+91
-36
Context.cpp
src/libGLESv2/Context.cpp
+13
-2
Context.h
src/libGLESv2/Context.h
+1
-1
libGLESv2.cpp
src/libGLESv2/libGLESv2.cpp
+77
-33
No files found.
src/libGLESv2/Context.cpp
View file @
b7915a55
...
...
@@ -2208,7 +2208,8 @@ void Context::applyTextures(SamplerType type)
}
}
void
Context
::
readPixels
(
GLint
x
,
GLint
y
,
GLsizei
width
,
GLsizei
height
,
GLenum
format
,
GLenum
type
,
void
*
pixels
)
void
Context
::
readPixels
(
GLint
x
,
GLint
y
,
GLsizei
width
,
GLsizei
height
,
GLenum
format
,
GLenum
type
,
GLsizei
*
bufSize
,
void
*
pixels
)
{
Framebuffer
*
framebuffer
=
getReadFramebuffer
();
...
...
@@ -2222,6 +2223,17 @@ void Context::readPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum
return
error
(
GL_INVALID_OPERATION
);
}
GLsizei
outputPitch
=
ComputePitch
(
width
,
format
,
type
,
mState
.
packAlignment
);
// sized query sanity check
if
(
bufSize
)
{
int
requiredSize
=
outputPitch
*
height
;
if
(
requiredSize
>
*
bufSize
)
{
return
error
(
GL_INVALID_OPERATION
);
}
}
IDirect3DSurface9
*
renderTarget
=
framebuffer
->
getRenderTarget
();
if
(
!
renderTarget
)
...
...
@@ -2286,7 +2298,6 @@ void Context::readPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum
unsigned
char
*
dest
=
(
unsigned
char
*
)
pixels
;
unsigned
short
*
dest16
=
(
unsigned
short
*
)
pixels
;
int
inputPitch
=
-
lock
.
Pitch
;
GLsizei
outputPitch
=
ComputePitch
(
width
,
format
,
type
,
mState
.
packAlignment
);
for
(
int
j
=
0
;
j
<
rect
.
bottom
-
rect
.
top
;
j
++
)
{
...
...
src/libGLESv2/Context.h
View file @
b7915a55
...
...
@@ -420,7 +420,7 @@ class Context
bool
getQueryParameterInfo
(
GLenum
pname
,
GLenum
*
type
,
unsigned
int
*
numParams
);
void
readPixels
(
GLint
x
,
GLint
y
,
GLsizei
width
,
GLsizei
height
,
GLenum
format
,
GLenum
type
,
void
*
pixels
);
void
readPixels
(
GLint
x
,
GLint
y
,
GLsizei
width
,
GLsizei
height
,
GLenum
format
,
GLenum
type
,
GLsizei
*
bufSize
,
void
*
pixels
);
void
clear
(
GLbitfield
mask
);
void
drawArrays
(
GLenum
mode
,
GLint
first
,
GLsizei
count
);
void
drawElements
(
GLenum
mode
,
GLsizei
count
,
GLenum
type
,
const
void
*
indices
);
...
...
src/libGLESv2/libGLESv2.cpp
View file @
b7915a55
...
...
@@ -53,6 +53,46 @@ bool validImageSize(GLint level, GLsizei width, GLsizei height)
return
false
;
}
// check for combinations of format and type that are valid for ReadPixels
bool
validReadFormatType
(
GLenum
format
,
GLenum
type
)
{
switch
(
format
)
{
case
GL_RGBA
:
switch
(
type
)
{
case
GL_UNSIGNED_BYTE
:
break
;
default:
return
false
;
}
break
;
case
GL_BGRA_EXT
:
switch
(
type
)
{
case
GL_UNSIGNED_BYTE
:
case
GL_UNSIGNED_SHORT_4_4_4_4_REV_EXT
:
case
GL_UNSIGNED_SHORT_1_5_5_5_REV_EXT
:
break
;
default:
return
false
;
}
break
;
case
gl
:
:
IMPLEMENTATION_COLOR_READ_FORMAT
:
switch
(
type
)
{
case
gl
:
:
IMPLEMENTATION_COLOR_READ_TYPE
:
break
;
default:
return
false
;
}
break
;
default:
return
false
;
}
return
true
;
}
extern
"C"
{
...
...
@@ -4054,7 +4094,41 @@ void __stdcall glPolygonOffset(GLfloat factor, GLfloat units)
}
}
void
__stdcall
glReadPixels
(
GLint
x
,
GLint
y
,
GLsizei
width
,
GLsizei
height
,
GLenum
format
,
GLenum
type
,
GLvoid
*
pixels
)
void
__stdcall
glReadnPixelsEXT
(
GLint
x
,
GLint
y
,
GLsizei
width
,
GLsizei
height
,
GLenum
format
,
GLenum
type
,
GLsizei
bufSize
,
GLvoid
*
data
)
{
EVENT
(
"(GLint x = %d, GLint y = %d, GLsizei width = %d, GLsizei height = %d, "
"GLenum format = 0x%X, GLenum type = 0x%X, GLsizei bufSize = 0x%d, GLvoid *data = 0x%0.8p)"
,
x
,
y
,
width
,
height
,
format
,
type
,
bufSize
,
data
);
try
{
if
(
width
<
0
||
height
<
0
||
bufSize
<
0
)
{
return
error
(
GL_INVALID_VALUE
);
}
if
(
!
validReadFormatType
(
format
,
type
))
{
return
error
(
GL_INVALID_OPERATION
);
}
gl
::
Context
*
context
=
gl
::
getNonLostContext
();
if
(
context
)
{
context
->
readPixels
(
x
,
y
,
width
,
height
,
format
,
type
,
&
bufSize
,
data
);
}
}
catch
(
std
::
bad_alloc
&
)
{
return
error
(
GL_OUT_OF_MEMORY
);
}
}
void
__stdcall
glReadPixels
(
GLint
x
,
GLint
y
,
GLsizei
width
,
GLsizei
height
,
GLenum
format
,
GLenum
type
,
GLvoid
*
pixels
)
{
EVENT
(
"(GLint x = %d, GLint y = %d, GLsizei width = %d, GLsizei height = %d, "
"GLenum format = 0x%X, GLenum type = 0x%X, GLvoid* pixels = 0x%0.8p)"
,
...
...
@@ -4067,38 +4141,8 @@ void __stdcall glReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLe
return
error
(
GL_INVALID_VALUE
);
}
switch
(
format
)
if
(
!
validReadFormatType
(
format
,
type
)
)
{
case
GL_RGBA
:
switch
(
type
)
{
case
GL_UNSIGNED_BYTE
:
break
;
default
:
return
error
(
GL_INVALID_OPERATION
);
}
break
;
case
GL_BGRA_EXT
:
switch
(
type
)
{
case
GL_UNSIGNED_BYTE
:
case
GL_UNSIGNED_SHORT_4_4_4_4_REV_EXT
:
case
GL_UNSIGNED_SHORT_1_5_5_5_REV_EXT
:
break
;
default
:
return
error
(
GL_INVALID_OPERATION
);
}
break
;
case
gl
:
:
IMPLEMENTATION_COLOR_READ_FORMAT
:
switch
(
type
)
{
case
gl
:
:
IMPLEMENTATION_COLOR_READ_TYPE
:
break
;
default
:
return
error
(
GL_INVALID_OPERATION
);
}
break
;
default
:
return
error
(
GL_INVALID_OPERATION
);
}
...
...
@@ -4106,7 +4150,7 @@ void __stdcall glReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLe
if
(
context
)
{
context
->
readPixels
(
x
,
y
,
width
,
height
,
format
,
type
,
pixels
);
context
->
readPixels
(
x
,
y
,
width
,
height
,
format
,
type
,
NULL
,
pixels
);
}
}
catch
(
std
::
bad_alloc
&
)
...
...
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