<p dir="ltr">Many thanks.It works as expected.</p>
<div class="gmail_quote">Il 15/giu/2014 10:08 "Corpsman" <<a href="mailto:corpsman@web.de">corpsman@web.de</a>> ha scritto:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
My Version uses glReadPixels, result is TBitmap, this can easily be atteched to the cliboard.<br>
<br>
Function OpenGLScreenshot: TBitmap;<br>
Var<br>
dim: Array[0..3] Of Integer;<br>
c: Array Of Array[0..3] Of Byte;<br>
z, i, j: integer;<br>
TempIntfImg: TLazIntfImage;<br>
ImgHandle, ImgMaskHandle: HBitmap;<br>
CurColor: TFPColor;<br>
Begin<br>
// Auslesen der Framebuffer Auflösung<br>
glGetIntegerv(GL_VIEWPORT, @dim[0]);<br>
// Erstellen des Bitmaps<br>
result := TBitmap.create;<br>
result.pixelformat := pf24bit;<br>
result.width := dim[2];<br>
result.height := dim[3];<br>
TempIntfImg := TLazIntfImage.Create(0, 0);<br>
TempIntfImg.LoadFromBitmap(<u></u>result.Handle, result.MaskHandle);<br>
setlength(c, dim[2] * dim[3]);<br>
// Auslesen des Framebuffers in einen temporären Speicher<br>
glReadPixels(dim[0], dim[1], dim[2], dim[3], GL_RGBA, GL_UNSIGNED_BYTE, @c[0, 0]);<br>
// Umschreiben des Temporären Speichers in das TBitmap<br>
z := 0;<br>
For j := 0 To result.height - 1 Do<br>
For i := 0 To result.width - 1 Do Begin<br>
CurColor.red := c[z][0] * 256;<br>
CurColor.green := c[z][1] * 256;<br>
CurColor.blue := c[z][2] * 256;<br>
// c[z][3] wäre der Alphakanal, aber den Braucht man ja hier nicht ...<br>
TempIntfImg.Colors[i, j] := CurColor;<br>
inc(z);<br>
End;<br>
TempIntfImg.CreateBitmaps(<u></u>ImgHandle, ImgMaskHandle, false);<br>
result.Handle := ImgHandle;<br>
result.MaskHandle := ImgMaskHandle;<br>
TempIntfImg.free;<br>
End;<br>
<br>
<br>
On 06/14/2014 12:13 PM, Michalis Kamburelis wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Andrea Mauri wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Dear all,<br>
<br>
Is it possible to copy the content of OpenGLContext to the clipboard?<br>
How can be done?<br>
<br>
</blockquote>
You could also copy the contents of OpenGL context (created by<br>
TOpenGLContext or any other similar control) using glReadPixels, and<br>
then convert the resulting bytes into a TBitmap instance. Then you can<br>
copy TBitmap contents to clipboard like Anton shows, using<br>
Clipboard.Assign (see<br>
<a href="http://wiki.lazarus.freepascal.org/Clipboard#Load_from_clipboard" target="_blank">http://wiki.lazarus.<u></u>freepascal.org/Clipboard#Load_<u></u>from_clipboard</a> ).<br>
<br>
Using glReadPixels and then converting the result will be<br>
cross-platform, as opposed to Anton's solution using<br>
Windows.CreateCompatibleBitmap .<br>
<br>
Michalis<br>
<br>
<br>
--<br>
______________________________<u></u>_________________<br>
Lazarus mailing list<br>
<a href="mailto:Lazarus@lists.lazarus.freepascal.org" target="_blank">Lazarus@lists.lazarus.<u></u>freepascal.org</a><br>
<a href="http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus" target="_blank">http://lists.lazarus.<u></u>freepascal.org/mailman/<u></u>listinfo/lazarus</a><br>
<br>
</blockquote>
<br>
<br>
-- <br>
<br>
Auf meiner Homepage <a href="http://www.Corpsman.de" target="_blank">www.Corpsman.de</a> ist immer was los, ständig wird sie aktualisiert und erweitert. Da ist für jeden was dabei.<br>
<br>
<br>
--<br>
______________________________<u></u>_________________<br>
Lazarus mailing list<br>
<a href="mailto:Lazarus@lists.lazarus.freepascal.org" target="_blank">Lazarus@lists.lazarus.<u></u>freepascal.org</a><br>
<a href="http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus" target="_blank">http://lists.lazarus.<u></u>freepascal.org/mailman/<u></u>listinfo/lazarus</a><br>
</blockquote></div>