Re: Copy RGBA pixels directly to target texture without blending
Sanette <[email protected]> Thu, 16 Mar 2017 16:18:54 +0100
| Newsgroups | gmane.comp.lib.sdl |
|---|---|
| Message-ID | <[email protected]> |
This is a multi-part message in MIME format.
--===============7757766396217497755==
Content-Type: multipart/alternative;
boundary="------------850E7FD430B71738CE45D3C6"
This is a multi-part message in MIME format.
--------------850E7FD430B71738CE45D3C6
Content-Type: text/plain; charset=iso-8859-15; format=flowed
Content-Transfer-Encoding: 8bit
have you tried SDL_BLENDMODE_NONE ?
(instead of SDL_BLENDMODE_BLEND)
Le 16/03/2017 à 16:11, stewambo a écrit :
> Hello,
> I have a texture with static (or streaming) access and I need to
> render other stuff onto it, so I need to convert it to a
> target-texture. Therefor I just created an empty texture with
> SDL_TEXTUREACCESS_TARGET and set it as rendering target, but when i
> render my semi-transparent static/streaming texture onto it the black
> transparent background of the target-texture bleeds into the
> transparent part of my original texture
>
> Original image:
>
>
> Left: original texture rendered directly;
> Right: target-texture with original texture rendered ontop (obviously
> not the same, but darker)
>
>
> Code to create the image above:
>
>
>
>
>
>
>
> Code:
>
> SDL_Surface* surface =
> SDL_ConvertSurfaceFormat(IMG_Load("D:/Documents/Visual Studio
> 2015/Projects/SDLTest/resources/textures/gradientTexture.png"),
> SDL_PIXELFORMAT_RGBA8888, NULL);
> SDL_Texture* staticTexture = SDL_CreateTextureFromSurface(renderer,
> surface);
> SDL_Texture* targetTexture = SDL_CreateTexture( renderer,
> SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_TARGET, 50, 50 );
>
> SDL_SetRenderTarget(renderer, targetTexture);
> SDL_SetTextureBlendMode(targetTexture, SDL_BLENDMODE_BLEND);
> SDL_RenderCopy(renderer, staticTexture, NULL, NULL);
> SDL_SetRenderTarget(renderer, NULL);
>
> SDL_Rect rect0{ 50,50,50,50 };
> SDL_RenderCopy(renderer, staticTexture, NULL, &rect0);
> SDL_Rect rect1{ 100,50,50,50 };
> SDL_RenderCopy(renderer, targetTexture, NULL, &rect1);
>
>
>
> The solution to my problem in this topic
> <https://forums.libsdl.org/viewtopic.php?t=12064> was to set the
> background color of the target texture to one solid color, but here
> this doesn't work because the static texture is not a solid color...
>
> So how can i get my target-texture to look exactly like my original
> texture, or is there a way to copy the RGBA information directly into
> the new texture without the need to render it using a blend mode?
>
> Thanks Smile
>
>
> _______________________________________________
> SDL mailing list
> [email protected]
> http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
--
sanette -- full_time_linux
--------------850E7FD430B71738CE45D3C6
Content-Type: text/html; charset=iso-8859-15
Content-Transfer-Encoding: 8bit
<html>
<head>
<meta content="text/html; charset=iso-8859-15"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<div class="moz-cite-prefix">have you tried SDL_BLENDMODE_NONE ?<br>
<br>
(instead of SDL_BLENDMODE_BLEND)<br>
<br>
<br>
Le 16/03/2017 à 16:11, stewambo a écrit :<br>
</div>
<blockquote cite="mid:[email protected]"
type="cite">
<style type="text/css">
<!--
/*
The original subSilver Theme for phpBB version 2+
Created by subBlue design
http://www.subBlue.com
NOTE: These CSS definitions are stored within the main page body so that you can use the phpBB2
theme administration centre. When you have finalised your style you could cut the final CSS code
and place it in an external file, deleting this section to save bandwidth.
*/
/* General page style. The scroll bar colours only visible in IE5.5+ */
body {
background-color: #;
font-family: ;
font-size: 11;
color: #;
}
/* General font families for common tags */
font,th,td,p { font-family: }
p, td { font-size : 11; color : #; }
a:link,a:active,a:visited { color : #; }
a:hover { text-decoration: underline; color : #; }
hr { height: 0px; border: solid # 0px; border-top-width: 1px;}
h1,h2 { font-family: "Trebuchet MS", Verdana, Arial, Helvetica, sans-serif; font-size : 22px; font-weight : bold; text-decoration : none; line-height : 120%; color : #000000;}
/* This is the border line & background colour round the entire page */
.bodyline { background-color: #; border: 1px # solid; }
/* General text */
.gen { font-size : 12px; }
.genmed { font-size : 11px; }
.gensmall { font-size : 10px; line-height: 12px}
.gen,.genmed,.gensmall { color : #; }
a.gen,a.genmed,a.gensmall { color: #; text-decoration: none; }
a.gen:hover,a.genmed:hover,a.gensmall:hover { color: #; text-decoration: underline; }
/* Forum title: Text and link to the forums used in: index.php */
.forumlink { font-weight: bold; font-size: 12px; color : #; }
a.forumlink { text-decoration: none; color : #; }
a.forumlink:hover{ text-decoration: underline; color : #; }
/* The content of the posts (body of text) */
.postbody { font-size : 12px; line-height: 18px}
a.postlink:link { text-decoration: none; color : # }
a.postlink:visited { text-decoration: none; color : #; }
a.postlink:hover { text-decoration: underline; color : #}
/* Quote & Code blocks */
.code {
font-family: ; font-size: 11px; color: #3FB753;
background-color: #; border: #; border-style: solid;
border-left-width: 1px; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px
}
.quote {
font-family: ; font-size: 11px; color: #444444; line-height: 125%;
background-color: #; border: #; border-style: solid;
border-left-width: 1px; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px
}
-->
</style>
<div class="postbody">Hello,<br>
I have a texture with static (or streaming) access and I need to
render other stuff onto it, so I need to convert it to a
target-texture. Therefor I just created an empty texture with
SDL_TEXTUREACCESS_TARGET and set it as rendering target, but
when i render my semi-transparent static/streaming texture onto
it the black transparent background of the target-texture bleeds
into the transparent part of my original texture <br>
<br>
Original image:<br>
<img moz-do-not-send="true" src="http://i.imgur.com/5ByTcgv.png"
border="0"><br>
<br>
Left: original texture rendered directly; <br>
Right: target-texture with original texture rendered ontop
(obviously not the same, but darker)<br>
<img moz-do-not-send="true" src="http://i.imgur.com/z7ukpYr.png"
border="0"><br>
<br>
Code to create the image above:<br>
<div align="center"><br>
<br>
<br>
<br>
<br>
<br>
<br>
<table class="code" border="0" cellpadding="2" cellspacing="1"
align="center" width="90%">
<tbody>
<tr>
<td class="code_header" align="left">Code:</td>
</tr>
<tr>
<td class="code" align="left"><br>
SDL_Surface* surface =
SDL_ConvertSurfaceFormat(IMG_Load("D:/Documents/Visual
Studio
2015/Projects/SDLTest/resources/textures/gradientTexture.png"),
SDL_PIXELFORMAT_RGBA8888, NULL);<br>
SDL_Texture* staticTexture =
SDL_CreateTextureFromSurface(renderer, surface);<br>
SDL_Texture* targetTexture = SDL_CreateTexture(
renderer, SDL_PIXELFORMAT_RGBA8888,
SDL_TEXTUREACCESS_TARGET, 50, 50 ); <br>
<br>
SDL_SetRenderTarget(renderer, targetTexture); <br>
SDL_SetTextureBlendMode(targetTexture,
SDL_BLENDMODE_BLEND);<br>
SDL_RenderCopy(renderer, staticTexture, NULL, NULL);<br>
SDL_SetRenderTarget(renderer, NULL);<br>
<br>
SDL_Rect rect0{ 50,50,50,50 };<br>
SDL_RenderCopy(renderer, staticTexture, NULL,
&rect0);<br>
SDL_Rect rect1{ 100,50,50,50 };<br>
SDL_RenderCopy(renderer, targetTexture, NULL,
&rect1);<br>
</td>
</tr>
</tbody>
</table>
</div>
<br>
<br>
The solution to my problem in <a moz-do-not-send="true"
href="https://forums.libsdl.org/viewtopic.php?t=12064"
target="_blank">this topic</a> was to set the background color
of the target texture to one solid color, but here this doesn't
work because the static texture is not a solid color...<br>
<br>
<span style="font-style: italic"><span style="font-weight: bold">So
how can i get my target-texture to look exactly like my
original texture, or is there a way to copy the RGBA
information directly into the new texture without the need
to render it using a blend mode?<br>
<br>
Thanks <img moz-do-not-send="true"
src="http://forums.libsdl.org/images/smiles/icon_smile.gif"
alt="Smile" border="0"></span></span></div>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
SDL mailing list
<a class="moz-txt-link-abbreviated" href="mailto:[email protected]">[email protected]</a>
<a class="moz-txt-link-freetext" href="http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org">http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org</a>
</pre>
</blockquote>
<br>
<br>
<pre class="moz-signature" cols="72">--
sanette -- full_time_linux</pre>
</body>
</html>
--------------850E7FD430B71738CE45D3C6--
--===============7757766396217497755==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
_______________________________________________
SDL mailing list
[email protected]
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
--===============7757766396217497755==--