I have written my own software pipeline for 3D graphics in C (just to prove to myself I could do it) and, having seen it work, I want to use it in DLL form as a library for Visual Basic .NET. I have had good success with mixing C and VB in this way in the past (C does the hard work in a DLL, VB looks pretty), but what I want to do now is a little different. My software renderer needs to display the graphics in a VB form, most likely on a panel. Ideally, I would do one of two things. First, I could create an instance of a Bitmap class in Visual Basic, somehow pass a pointer to the pixel array to a rendering function in C, then paint the bitmap to the panel. Or second, I could somehow control the graphics on the panel more directly, but I'm not sure how that would work. Does anybody know how I could accomplish my goal?
Edit:
Up to this point I have been using SDL to display graphics.
I believe I may have found what I am looking for here.
http://msdn.microsoft.com/en-us/library/5ey6h79d.aspx
I will come back with more information as soon as I try my plan out. Basically, I can get the address of the pixel array for a bitmap with the lock bits method. I can pass this to my C rendering function. It should work perfectly.
Related
I've modeled using helixtoolkit which is done in a wpf user control library and hosted on ElementHost. I decided to do this because my model is fairly simple (just a stick element with lineVisual3d and bunch of small spheres).
Now I want to animate it and everything I find related to animation seems too complicated for what I'm trying to accomplish. I've seen storyboard being suggested as well as transform methods.
What I have is a 3D line connected by a bunch of points3D and I want to translate them only by a series of values at a fixed time increment.
I did this in a 2D graph using a timer for winform and even a forloop did the trick.
However, I'm not sure how to do the same for a 3D line element. I was thinking that since I have a simple structure simply redrawing it would suffice.
But my problem is I want to add a slider which acts in pretty much the same way as a video player, it will increment itself as the animation runs, I want to also be able to freeze it at any point in time and use the slider to go to any point in time much like how a video player works.
My biggest question here is how do I use a slider to control the animation. Again, this animation will simply be a bunch of values that I want to translate the stick element by(a series of points).
I've already got the values but I want to add an animation for these values at every increment while being able to control it using a slider.
--I will post any code if necessary, not posting any right now because I dont know what would help explain the question better
You can use TranslationTransform3D and apply the transform onto the 3D Model
I have a video playing of lines being drawn on the screen. Is it possible to create a pixel shader (for WPF) that turns newly colored pixels a certain color for N milliseconds?
That way, there can be some indication to the user to movement on the screen when the lines don't move often and the user isn't always looking at the screen.
You can use DirectShow. Its written in unmanaged code, so you need to use this wrapper DirectShow.NET in order to use it in your C# application which is running in managed environment (samples are included, even with EVR which stands for Enhanced video Renderer which means MUCH better video quality). And when you will be passing a control handle to wrapper method for setting the video output, you need a WinForms control, because only from them you can get your desired control handle. That WinForms control you can then host in your WPF application using the WindowsFormsHost control provided for such situations when you need to use some WinForms control(s) in a WPF application. Its just theory, so i dont know if its an ultimate solution for you.
BTW: The whole idea is based on fact, that DirectShow is just some query constructed from separated filters. Renderer is a filter (EVR, VMR-7, VMR-9). Sound player is a filter. And they are connected through their pins. Its like a diagram. Electronic schema or something like that. And you can put for example Grey scale filter in there. And voila, video output will be greyscale. There is a bunch of tutorials for that. And completed simple filters as well. Unfortunately, filters must be written in C++:(
PS: I never said its gonna be easy:D
I'd like to know a library to draw graphics in WPF..
I'd like to plot a line graph with a lot of points which increases at runtime..
I tried with DynamicDataDisplay, but it was very slow in my app...
So.. Can you suggest me a library / project to use to solve my problem?
Maaany thanks!
I'd suggest binding your data to a System.Windows.Shapes.Path using a converter, you just need to implement a notifying interface if points are added or removed to update the graph.
(Recently wrote a generic cartesian point array converter for this question)
Hey Guys, I am building a cards game which displays a stack of Cards( Some thing like Solitaire). I was wondering you give me some advise regarding it? Also if you could direct me to a tutorial for stuff like these( I am already going through the gtk doc).
You should check what have already be done in GnomeGames :
Aisleriot
Blackjack
Get the code and see how they have done it. It seems that they render each and every card :
For example, in Aisleriot source code, in game.h, you have the definition of an ArSlot struct which stores all the cards of one slot. In there, you can see that they define the 'expansion' union which is just defining the offset between the cards.
So if you wish to create a heap of cards, you can draw each one of them, or if you consider it's too slow, just draw a few cards with a random offset of one or two pixels, and then draw the last card on the top : with this algorithm, your heap of cards looks like a heap, and it's quick to render on screen.
Unfortunately, there's no widget included in GTK+ that displays stack of cards, so yu have to write one yourself. You should use GtkDrawingArea (preferably by subclassing it), and in handler for expose_event signal do your drawing stuff. To draw you can use either plain GDK which is more basic, or use Cairo, which is more flexible drawing library (nb. Cairo is used by GTK+ anyway, so it's not additional dependency. If you want more, you can even use OpenGL (then you have to use GtkGlExt library).
GTK Tutorial has a chapter dedicated for creating own widgets.
Is there any sane way to work with bitmaps in WPF? I'd like similar functionality as System.Drawing.Bitmap: be able to load image from file and get and set the color of particular pixels.
I know about WriteableBitmap, but I don't want to work with Arrays of gods-know-what (I couldn't find that on MSDN), or pointers. I just want to read or write pixel, it shouldn't be that hard!
I also know that I can use Interop to work with System.Drawing.Bitmap in WPF, but that's not nice either.
Here's something on how to do get pixel info from a System.Windows.Media.Imaging.BitmapImage.
Although, if you'd prefer to work with a System.Drawing.Bitmap you might want to add a reference to System.Drawing.dll and use it instead.
Here's a somewhat-related forum post on image manipulation in WPF.