|
forums.silverfrost.com Welcome to the Silverfrost forums
|
View previous topic :: View next topic |
Author |
Message |
EKruck
Joined: 09 Jan 2010 Posts: 224 Location: Aalen, Germany
|
Posted: Tue Sep 30, 2014 3:58 pm Post subject: GIF file from %og graphics ? |
|
|
I'm looking for a possibility to create a gif-file from my OpenGL line graphics window.
Any experience? |
|
Back to top |
|
|
JohnCampbell
Joined: 16 Feb 2006 Posts: 2554 Location: Sydney
|
Posted: Wed Oct 01, 2014 8:26 am Post subject: |
|
|
I am not familiar with OpenGL, but to dump an active window (either %gr or virtual window) I use export_image@. (screen, window, region; it's all a bit confusing, but not %og region!) This is fairly flexible as it supports .gif, .jpg and also .png. I would recommend you look at .png, which is effectively the replacement for .gif and has a much better colour palette.
Dan may have a comment on the restrictions of dumping a %og region.
I think there are restrictions as to what you can do with a %og region but a possible option might be to create another background graphics region via create_graphics_region@ then if it is possible, copy the %og region to this region. Once copied, this region could be selected then exported with export_image@. Background or virtual regions work well once you have all the coding bugs removed, although check on the memory usage.
I had a look in the documentation, but could not find what routines would access a %og region.
John |
|
Back to top |
|
|
LitusSaxonicum
Joined: 23 Aug 2005 Posts: 2388 Location: Yateley, Hants, UK
|
Posted: Wed Oct 01, 2014 3:37 pm Post subject: |
|
|
You should search for the Clearwin+ thread 'Graphics region export' which was started in 2010.
John Horspool (who sadly has passed away) was an expert in %og, and there he tells you how to do the graphics export. It is more or less as John C says.
Eddie |
|
Back to top |
|
|
EKruck
Joined: 09 Jan 2010 Posts: 224 Location: Aalen, Germany
|
Posted: Mon Oct 13, 2014 8:56 am Post subject: |
|
|
John,
I tried:
Code: | ma = winio@ ('%pv&')
ma = winio@ ('%^og[double,depth16] &', iBasicSize, iBasicSize, cb_CreateMainGLwin) ! Create main openGL window
MA = WINIO@ ('%lc&', iGraphicHandle)
:
:
iTempHandle = 4711
MA = CREATE_GRAPHICS_REGION@ (iTempHandle, iCurrDrawSizeX, iCurrDrawSizeY)
MA = SELECT_GRAPHICS_OBJECT@ (iGraphicHandle)
MA = COPY_GRAPHICS_REGION@ (iTempHandle, 0, 0, iCurrDrawSizeX, iCurrDrawSizeY, &
& iGraphicHandle, 0, 0, iCurrDrawSizeX, iCurrDrawSizeY, 13369376) ! CC0020
|
Select and copy functions return zero (error) ?? |
|
Back to top |
|
|
LitusSaxonicum
Joined: 23 Aug 2005 Posts: 2388 Location: Yateley, Hants, UK
|
Posted: Mon Oct 13, 2014 11:36 am Post subject: |
|
|
I think that you cannot use %lc (I may be wrong) in this context but you should use a grave accent modifier and use a device handle that you supply like in %gr. There is some information in the CWPLUS.ENH file (item 224) that is relevant if you want to explore it.
Note that this is just a guess.
I struggled with understanding handles, and once wrote a post 'When is a handle not a handle?' It turns out that some handles are given to you by Windows, but some (like the one for %gr) are supplied by you the programmer.
Eddie |
|
Back to top |
|
|
EKruck
Joined: 09 Jan 2010 Posts: 224 Location: Aalen, Germany
|
Posted: Mon Oct 13, 2014 2:35 pm Post subject: |
|
|
Using %lc or %`og makes no difference for the handle. It is available in both cases after creating the OpenGL window.
I have read item 224 and tried
Code: | CALL SET_OPENGL_CONTEXT@ |
instead of
Code: | SELECT_GRAPHICS_OBJECT@ |
--> No success, no change.
Erwin |
|
Back to top |
|
|
LitusSaxonicum
Joined: 23 Aug 2005 Posts: 2388 Location: Yateley, Hants, UK
|
Posted: Mon Oct 13, 2014 3:03 pm Post subject: |
|
|
Ah well, it was worth a try. Apologies that it wasn't helpful.
Another approach might be to use a printer driver that creates GIFs and other file formats, and install it, then use the OpenGL print functionality. The first such printer driver I found with a Google search was this one:
http://www.pdfill.com/freewriter_image.html
It has the benefit of being free!
Eddie |
|
Back to top |
|
|
EKruck
Joined: 09 Jan 2010 Posts: 224 Location: Aalen, Germany
|
Posted: Tue Oct 14, 2014 8:24 am Post subject: |
|
|
As long as I have no access to the graphics window, I can neither copy to file nor print.
Erwin |
|
Back to top |
|
|
LitusSaxonicum
Joined: 23 Aug 2005 Posts: 2388 Location: Yateley, Hants, UK
|
Posted: Tue Oct 14, 2014 7:25 pm Post subject: |
|
|
I don't understand "no access to the OpenGL window" - I thought you could create it and write to it.
The procedure for printing appears to be to start the printer with:
I=OPEN_GL_PRINTER@ ...
(or OPEN_GL_PRINTER1@)
then go through the graphics creation routines again (just like on the screen window), then use
I=PRINT_OPENGL_IMAGE@
to finish the print. The printer driver I pointed to will give you a file in the image format you select instead of a hard copy on a physical printer.
Eddie |
|
Back to top |
|
|
EKruck
Joined: 09 Jan 2010 Posts: 224 Location: Aalen, Germany
|
Posted: Wed Oct 15, 2014 1:39 pm Post subject: |
|
|
Hi Eddie
It would be great if you could make a running example.
I get only the error message "No OpenGL buffers are open" when I redraw.
Erwin |
|
Back to top |
|
|
EKruck
Joined: 09 Jan 2010 Posts: 224 Location: Aalen, Germany
|
Posted: Wed Oct 15, 2014 4:49 pm Post subject: |
|
|
John, Paul,
from #179 in file cwplus.enh I understand, there is no OpenGL graphic in memory, therefor it cannot be copied.
Any idea how to get the graphic into a GRAPHICS_REGION that can be copied?
It's a very important point for me to save the graphic to file or to paste buffer using Ctrl+s or Ctrl+c like in my five other graphic programs created using %gr.
Erwin |
|
Back to top |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7916 Location: Salford, UK
|
Posted: Wed Oct 15, 2014 7:49 pm Post subject: |
|
|
Sorry but I have not worked with OpenGL. I can only look at the documentation and examples. |
|
Back to top |
|
|
LitusSaxonicum
Joined: 23 Aug 2005 Posts: 2388 Location: Yateley, Hants, UK
|
|
Back to top |
|
|
LitusSaxonicum
Joined: 23 Aug 2005 Posts: 2388 Location: Yateley, Hants, UK
|
Posted: Wed Oct 15, 2014 9:06 pm Post subject: |
|
|
I had a go at modifying the Silverfrost 'Teapots.for' OpenGL demo, incorporating John Horspool's code for using a DIB block. I put the modified code here:
https://dl.dropboxusercontent.com/u/76596632/TP.for
It succeeds (for me at least) in creating a BMP file, at the original size of the %og area, and as that has a %pv pivot, after resizing, the bitmap reflects that resized area (although the array of teapots doesn't get any bigger). Apologies that my modifications are not very elegant.
As for GIF - then I'm in the dark! (I don't use OpenGL, or GIF files). However, with a 'printer' driver that writes to different file formats, I imagine that DIB_PRINT@ would create them. You are also on your own creating bitmap files with a different size than the %og control. Sorry.
Eddie |
|
Back to top |
|
|
DanRRight
Joined: 10 Mar 2008 Posts: 2813 Location: South Pole, Antarctica
|
Posted: Fri Oct 17, 2014 12:29 am Post subject: |
|
|
I use the trick of J.Horspool to make BMPs. Trick uses put_dib_block which Paul may make capable of other graphics formats if he already not done that (i have not try). For simple access i repost it here
Code: | !!===============================================================
! thanks to John Horspool for these subs
!
integer function SaveOpengl_Bitmap()
include <clearwin.ins>,nolist
include <opengl.ins>,nolist
integer wOpGL,hOpGL
common /OpenGL_image_size/wOpGL,hOpGL
wOpGL=clearwin_info@('OPENGL_WIDTH')
hOpGL=clearwin_info@('OPENGL_DEPTH')
call do_bitmap(wOpGL,hOpGL)
SaveOpengl_Bitmap=2
end
!-----------------------------------------------
subroutine do_bitmap(wOpGL,hOpGL)
include <clearwin.ins>,nolist
include <opengl.ins>,nolist
integer wOpGL,hOpGL,ierr,koff,kount,i,j,k
CHARACTER*1 ImageData(3*(wOpGL+3)*hOpGL), ImageDib(3,wOpGL,hOpGL)
CHARACTER*128 file_name
logical exst
ImageData=' '
ImageDib =' '
call glReadPixels(0,0,wOpGL,hOpGL,
* GL_RGB,GL_UNSIGNED_BYTE,ImageData)
koff=mod(wOpGL,4)
kount=0
do j=1,hOpGL
do i=1,wOpGL
do k=1,3
kount=kount+1
ImageDib(k,i,hOpGL-j+1)=ImageData(kount)
end do
end do
kount=kount+koff
end do
file_name='Opengl .bmp'
k=0
5 k=k+1
write(file_name(7:9),'(I3)')k
if (file_name(7:7).eq.' ') file_name(7:7)='0'
if (file_name(8:8).eq.' ') file_name(8:8)='0'
INQUIRE(FILE=file_name,EXIST=EXST)
IF (EXST) go to 5
call put_dib_block@(file_name,ImageDib,wOpGL,hOpGL,
* 0,0,wOpGL,hOpGL,24,ierr)
return
end
| I3 |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|