Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
libSDL
Project
Project
Details
Activity
Releases
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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
PocketInsanity
libSDL
Commits
2f6aa755
Commit
2f6aa755
authored
Mar 10, 2011
by
Sam Lantinga
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed bug 1162 (Error calling SDL_RenderReadPixels() with format=0)
parent
903efd98
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
11 deletions
+23
-11
SDL_render_gl.c
src/render/opengl/SDL_render_gl.c
+23
-11
No files found.
src/render/opengl/SDL_render_gl.c
View file @
2f6aa755
...
@@ -921,44 +921,56 @@ GL_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect,
...
@@ -921,44 +921,56 @@ GL_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect,
{
{
GL_RenderData
*
data
=
(
GL_RenderData
*
)
renderer
->
driverdata
;
GL_RenderData
*
data
=
(
GL_RenderData
*
)
renderer
->
driverdata
;
SDL_Window
*
window
=
renderer
->
window
;
SDL_Window
*
window
=
renderer
->
window
;
Uint32
temp_format
=
SDL_PIXELFORMAT_ARGB8888
;
void
*
temp_pixels
;
int
temp_pitch
;
GLint
internalFormat
;
GLint
internalFormat
;
GLenum
format
,
type
;
GLenum
format
,
type
;
Uint8
*
src
,
*
dst
,
*
tmp
;
Uint8
*
src
,
*
dst
,
*
tmp
;
int
w
,
h
,
length
,
rows
;
int
w
,
h
,
length
,
rows
;
int
status
;
GL_ActivateRenderer
(
renderer
);
GL_ActivateRenderer
(
renderer
);
if
(
!
convert_format
(
data
,
pixel_format
,
&
internalFormat
,
&
format
,
&
type
))
{
temp_pitch
=
rect
->
w
*
SDL_BYTESPERPIXEL
(
temp_format
);
/* FIXME: Do a temp copy to a format that is supported */
temp_pixels
=
SDL_malloc
(
rect
->
h
*
temp_pitch
);
SDL_SetError
(
"Unsupported pixel format"
);
if
(
!
temp_pixels
)
{
SDL_OutOfMemory
();
return
-
1
;
return
-
1
;
}
}
convert_format
(
data
,
temp_format
,
&
internalFormat
,
&
format
,
&
type
);
SDL_GetWindowSize
(
window
,
&
w
,
&
h
);
SDL_GetWindowSize
(
window
,
&
w
,
&
h
);
data
->
glPixelStorei
(
GL_PACK_ALIGNMENT
,
1
);
data
->
glPixelStorei
(
GL_PACK_ALIGNMENT
,
1
);
data
->
glPixelStorei
(
GL_PACK_ROW_LENGTH
,
data
->
glPixelStorei
(
GL_PACK_ROW_LENGTH
,
(
pitch
/
SDL_BYTESPERPIXEL
(
pixel
_format
)));
(
temp_pitch
/
SDL_BYTESPERPIXEL
(
temp
_format
)));
data
->
glReadPixels
(
rect
->
x
,
(
h
-
rect
->
y
)
-
rect
->
h
,
rect
->
w
,
rect
->
h
,
data
->
glReadPixels
(
rect
->
x
,
(
h
-
rect
->
y
)
-
rect
->
h
,
rect
->
w
,
rect
->
h
,
format
,
type
,
pixels
);
format
,
type
,
temp_
pixels
);
/* Flip the rows to be top-down */
/* Flip the rows to be top-down */
length
=
rect
->
w
*
SDL_BYTESPERPIXEL
(
pixel
_format
);
length
=
rect
->
w
*
SDL_BYTESPERPIXEL
(
temp
_format
);
src
=
(
Uint8
*
)
pixels
+
(
rect
->
h
-
1
)
*
pitch
;
src
=
(
Uint8
*
)
temp_pixels
+
(
rect
->
h
-
1
)
*
temp_
pitch
;
dst
=
(
Uint8
*
)
pixels
;
dst
=
(
Uint8
*
)
temp_
pixels
;
tmp
=
SDL_stack_alloc
(
Uint8
,
length
);
tmp
=
SDL_stack_alloc
(
Uint8
,
length
);
rows
=
rect
->
h
/
2
;
rows
=
rect
->
h
/
2
;
while
(
rows
--
)
{
while
(
rows
--
)
{
SDL_memcpy
(
tmp
,
dst
,
length
);
SDL_memcpy
(
tmp
,
dst
,
length
);
SDL_memcpy
(
dst
,
src
,
length
);
SDL_memcpy
(
dst
,
src
,
length
);
SDL_memcpy
(
src
,
tmp
,
length
);
SDL_memcpy
(
src
,
tmp
,
length
);
dst
+=
pitch
;
dst
+=
temp_
pitch
;
src
-=
pitch
;
src
-=
temp_
pitch
;
}
}
SDL_stack_free
(
tmp
);
SDL_stack_free
(
tmp
);
return
0
;
status
=
SDL_ConvertPixels
(
rect
->
w
,
rect
->
h
,
temp_format
,
temp_pixels
,
temp_pitch
,
pixel_format
,
pixels
,
pitch
);
SDL_free
(
temp_pixels
);
return
status
;
}
}
static
void
static
void
...
...
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