I'm making a GUI editor for a game engine that only allows DDS image files. I've had no luck finding any WinForm way to load DDS files so I looked at the XNA route. I found a DDSLib that uses XNA to load DDS files to Texture2D types. Then I think I can save those in memory as bitmap and use them in my WinForm. However this requires a Graphics Device object. How can I get this Graphics Device object without having any sort of visual thing. Everything I see shows controls which makes sense if you want to show something, but in my case I just need it behind the scenes to do these conversions.
It may not be an elegant solution but you could just set the XNA frame within the winform to not be visible?
Edit:
Just found this: How to load .dds files into a picturebox?
Related
I am writing an application that renders an OpenGL scene. This application has two windows:
A large window that shows only the rendered scene
A "control window" that offers several settings and a preview of the rendered scene
This application is written in .NET (for the control window part) and uses a native C++ DLL to create the rendering window and do the actual OpenGL rendering.
This works fine, but one important part is still missing: getting a live preview of the rendered scene into my .NET control window.
So far I could think of two solutions:
Render the scene not only to the screen, but also to memory. Then shove that blob of memory to my .NET WinForm. Finally draw the image to a PictureBox or something. <- This sounds horribly slow!
Make my native OpenGL renderer render the scene twice, once to the native full size window, once to a control (panel?) on my .NET form.
Option 2 sounds faster, but I have no idea if/how that even works.
Can this be done? Are there better alternatives?
Look into the documentation on framebuffers. It is basically the destination of your rendering, by default it's your viewport (or the backbuffer, which switches with the displayed buffer once it's ready).
The first option should generally be faster as you render the scene once and then just basically copy a texture.
I have tried to approach this problem several ways.
I have a web application that will load a sprite (which is a large jpeg that 'holds' 100 frames. Using the offset of div properties I am able to 'move' the image along so it looks like a movie clip.
This works well.
I need to produce the same on mobile devices.
I have to support Windows Mobile 6.5.
I was using jQuery/ajax to move the sprite image along to stop any flickering of the image within the browser.
Windows mobile 6.5 does not support this.
So, i decided to do a native app using C# Framework 2.0.
I thought about converting the sprite to a mp4 file and playing within a web browser control. but IE on the device will not support html5.
I have been told there is a CAB file from adobe so that I can play flash videos on the IE. But, apart from using ffmpeg to convert these images to a flv there is not much control as to adding menu like pause,stop,play etc when playing the flv file. I have not started any of this by the way i assume that would be the case.
So.. I thought if I download the sprite to the device i could use the graphics object of a picture box and render the rectangle of interest from large sprite to picture box.
I could not download the Sprite and save it to an image though. I get 'out of memory exception'.
I used the OpenNetCF.Drawing as it is supposed to support large files. I still get the error message. I have reduced the size of the image and it will work on about 20 frames.
I would then have to 'stack' these images containing 20 frames and load them up when necessary.
I am beginning to wonder now whether i am doing the right thing?
Is there a different way of trying to achieve what i am trying to achieve that is quicker and more efficient as I have run out of ideas.
If I am OK doing it this way then what is the best way to render images in a picturebox like a video. Memory efficiency says load the image from the file on the device when needed and dispose of it but that would cause 'flickering'. What IS the best way to handle multitude of images on a device?
i have plenty of code I can upload but I was worried the question would look 'messy' as I have tried so many things. I will of course edit/upload the code as required.
Thanks.
I have a program to make 2d animation and when I save my animation the format is scml and I can't open that animation in XNA.
Do I have to put it in another format?
The software is Spriter.
For one, XNA dosen't include content loaders for anything more than your default file types such as PNG, JPEG, TxT, etc.
I saw an exacmple of a scml file from spriter, and you will need to create your own content loader for it, but that is probably going to be a bit hard.
Your best bet is to take an animation example, and take the pictures that Spriter has made, and arrange them into a spritesheet.
I'm afraid this isnt as simple as you thought, but manually making a spritesheet will probably be your best bet.
Important Edit:
Your in luck, someone already made a content loader for Spriter in XNA!
https://github.com/schmelze/SpriterXNA and I belive a newer version https://bitbucket.org/dylanwolf/xspriter
I'm writing a tile editor for a game and would like to be able to select which level file to open. Once open I would load the level into an XNA window and click to add/remove tiles to the level. When the editing is finished I would save the file layout back to the original file.
Currently I don't see a way to integrate windows forms and XNA. Is this even possible?
When I was working on a small, "2.5D" isometric game in XNA, I found it worth while to also have a separate WinForms version that would just render a 2D top-down view using GDI. This was due to my inexperience with XNA and my (relative) comfort using WinForms.
This approach also had the useful side-effect of enforcing separation between logic and rendering code. It made it easier (for me, at least) to test changes without having to worry about how to deal with the XNA rendering aspects.
It may not be exactly what you had in mind, but it might be something to consider.
WinForms and Xna can cooperate, but it's not recommended to use Xna's built in Game class with WinFroms. There are two samples demonstrating it:
http://xbox.create.msdn.com/en-US/education/catalog/sample/winforms_series_1
http://xbox.create.msdn.com/en-US/education/catalog/sample/winforms_series_2
I'm looking at trying to create a simple 'slider puzzle' game. You've seen the ones, you have an image and you shuffle the tiles.
However, I want to make one that will play back videos instead. What I'm trying to determine is whether it's possible to playback a video in C# and render the video on different controls (probably buttons, or panels). I've spotted the Microsoft.DirectX.AudioVideoPlayback classes but haven't found much documentation on them yet.
So to throw it up in the air, is this going to be possible to do without too much difficulty? Are there any useful (free) libraries that might help me along?
Have a look at DirectShowNet that wraps the DirectShow API, in the samples page there is a sample called PlayWnd the shows how to play a video file.
Depending upon how large and how long your video sources are, you could accomplish this very simply by first converting your videos to animated GIFs. A .Net PictureBox control will display and animate a GIF automatically, and you could easily use PictureBoxes for your tiles.
One big advantage of this approach is that (thanks to Mono) your application could work unaltered on Windows, Mac and the iPhone (also Linux and a couple others).