3DS file loader for opengl - file

this is my 1st question in the site.
I need a 3DS model loader for opengl applications. Loader should also be able to load .jpg textures. I tried to use OpenSceneGraph for this purpose but this time I have to also use the whole OpenSceneGraph data structure to render the scene. Is it possible to use OpenSceneGraph only for model loading and do the rest with standart opengl code, especially glTranslate, glRotate, etc.

Googling turned up this: lib3ds
Not sure if it can read JPEGs but that should be easy enough with libjpeg or equivalent.

OpenSceneGraph uses "plugins" to load file formats - both models and textures. There are working plugins for 3ds and for jpeg, though at least the jpeg one (I believe) isn't built in the default configuration - when creating the OpenSceneGraph makefiles (or projects on Windows), you need to specify the location of the libjpeg files in order for it to be built (as the plugin is based on that library). Once you have these two plugins, you'll have no problem reading 3ds files and jpeg textures. Another option is to use some other convertor which supports both osg (or ive) - OpenSceneGraph's native format- and 3ds. Blender comes to mind, and it's free...
As for mixing openGL calls with OpenSceneGraph - that can be tricky, but possible. One option is to derive your own class from Drawable, then override its draw implementation method, and place it anywhere you want in the graph, though manually drawing the 3ds files defeats the whole purpose of using a scene-graph...

Related

How to import a pdf file as background to GtkDrawingArea

I need to import a pdf file as background that I can draw on it. I want to some new figures and I want to highlighten some areas.
I was searching the Internet for the last three days. The only thing I found ist the opposite, writing to pdf files.
/* does the other way */
cairo_pdf_surface_create();
First I tried this command but when I realized that it's overwriting my source file instead of importing it.
I am using GTK3 and C for writing my program.
As you've already figured out, it's not a straightforward task: GTK doesn't have PDF rendering features, so you have to use some external library.
I recommend taking a look at Evince, GTK document viewer. It has different backends for different document types. For PDF it's ev-poppler.cc and it uses poppler library.
Inside that ev-poppler.cc there is pdf_page_render which renders a single page and pdf_document_get_page which gets a single page from backend.

How to load image from embedded resources

I want to set image to button:
GtkImage* imageForButton = gtk_image_new_from_resource("which path is here?");
GtkWidget* btn = gtk_button_new();
gtk_button_set_image(GTK_BUTTON(btn));
How to make it work with embedded resources?
I have resource.h/resource.rc, gonna try to use MakeIntResource, but I don't see any use of it for GTK.
GTK+ doesn't support Windows resources (at least as far as I can tell). Instead, it uses its own cross-platform resource format, GResource. The easiest way to get embedded resources working is to use this. It isn't compatible with Windows resource editors, and requires generating an extra C source file, but it should work fine so long as you use GLib or GTK+. You should have the GResource compiler as part of your GTK+ install (but I'm not 100% sure). And if you go this route, you'll be able to keep using PNG files. (I don't know how to use PNG files with Windows resources, if that even is possible.)
If you insist on using Windows resources, though, I can think of one possible way to do this, though this isn't the only one: use the Windows API resource functions to load an HBITMAP from your resource, call GetObject() to get the BITMAP structure from the HBITMAP, and then calling gdk_pixbuf_new_from_data() with the appropriate fields from the BITMAP structure as parameters (rowstride == BITMAP.bmWidthBytes). Good luck!

CUDA-C importing bitmap image

Now, I have my simple project on changing the color image into white&black image using CUDA-C.
But I got a problem with importing/loading a bitmap image into program. I don't know how to import it.
So...
CUDA-C have a specific function about importing/loading bitmap image?
If yes, what is it and how to use it?
If no, how do you do with importing/loading bitmap image?
Thank you.
There's really nothing that is CUDA-specific about loading a bitmap image into an application.
If you have a preferred method for loading a bitmap image into an application, you should be able to use it with a CUDA app. You will obviously be loading the image into the host application space first. After that, if you want to transfer it to the device, you can use any of the standard methods for transferring data to the device to accomplish this.
CUDA (i.e. the runtime API) doesn't have any specific functions for importing/loading a bitmap image
-
There are many ways to load an image. If you are already using OpenGL or DirectX, then you will want to use a method associated with one of those APIs, and then use the appropriate interop API within CUDA to manipulate the object.
If you want to import a bitmap image directly into a CUDA program without using a graphics API, take a look at the CUDA samples, as a number of them do this and provide helper functions that you may want to re-use.
For example, the dct8x8 sample provides a file called BmpUtil.cpp which contains a number of useful bitmap import/handling routines, and the dct8x8 app (dct8x8.cu) shows how these may be used directly in a CUDA app.

Strange .XAP.PNG archives (bing maps)

When I was looking at the www.bing.com/maps html source file I came across some
strange "streetsidePrefetchFileUrls" URLs to .xap.png archives:
For exmaple:
hxxp://c0.ecn.catalogservice.virtualearth.net/cs/dc/pf/Xaps/bcbc3954e568c46cf8c3cc00737da32c_Microsoft.Maps.Framework.xap.png
This file has a PNG Header and contains an IDAT chunk. The IDAT chunk doesn't contain pixel data but a (corrupt) PKZIP archive with Microsoft Maps DLLs inside.
Does anybody know why Microsoft uses PNG as a container for xap Archives?
I've tried to unpack that archive with unzip and 7z. They all detect the ZIP-Archive inside the PNG but abort unpacking with an error.
Yes I noticed this they changed to this kind of protection just before the map app api came out of Beta. I presume it is their way of providing some protection for xap code from 3rd party developers, we have tried lots of ways to decrypt these without any luck but the code for it must be in the initial silverlight code so with a lot of decompiling you could probably find it
Many of the Bing Maps App's available on http://bing.com/maps contain proprietary algorithms and code. The png encoding is there to help prevent people from decrypting the XAP files and decompiling them. That said, if there is something you are trying to figure out how to do then try asking that question instead.

How to display streaming images in OpenCV?

I'd like to implement the live view function using EDSDK. I have used EdsGetPointer to get the pointer of the memory address for memory streaming. Now I want to display the streaming image on the PC.
I have read in some people use the API on VisualC such as ATL or CImage which able display the streaming image just by passing the pointer of the memory stream as the parameter, and the function could retrieve the streaming images by itself. I am thinking of using OpenCV in order to display the streaming images as I don't have VisualC installed on my computer. Is there any function on OpenCV that I can use to display streaming images? Or is there any other alternatives that I can use to deal with streaming images from EDSDK?
You can pack the data into an IplImage and show it using cvShowImage in a loop: http://opencv.willowgarage.com/documentation/user_interface.html The down side is you're tied into the OpenCV event loop.
There are alternatives. In the past I've used OpenGL to paint an image as a texture so that I could manage the viewport, draw on top of it, etc. You can get a simple and flexible working GUI pretty quickly using GLUT. A benefit to that is that whatever OpenGL code you write will be portable to any other UI library you use as long as that library has an OpenGL canvas widget. What I always do is Camera->IplImage->OpenGL Texture->wxWidgets glCanvas. I still use OpenCV for the actual image processing, etc. It's totally cross-platform and doesn't require the pay version of VC++.
are you want it for LiveView ? if not for liveview, you can save your streaming image in host
using
Error = EdsCreateFileStream(dirItemInfo.szFileName, EDSDK.EdsFileCreateDisposition.CreateAlways, EDSDK.EdsAccess.ReadWrite, out stream);
then you can load it
IplImage *inImg = cvLoadImage("photo2.jpg");
and then can process the image in opencv.

Resources