I downloaded Directx SDK November2008 release. in SDK I got some samples when I compile that samples it is compiling ok, but when I run this sample it is giving this error.
"The procedure entry point __CxxFrameHandler3 could not be located in the dynamic link library"
if any body have solution for this problem it would be thank full.
I'm developing a vector graphics app and I'm trying to find the most efficient way to scale a rotated shape. As an example, lets say the user adds a rectangular shape to the drawing surface. Once they rotate the shape to, say 45 degrees, how can I most effeciently perform scaling once they decide to resize the shape?
My current solution is to get the amount of pixels the mouse has moved, then rotate the shape back to 0 degrees, then offset the points by the delta amount, then rotate the points back to the current rotation. I don't think this is the best method because if the user has created a complex polygon and rotates it, I may end performing thousands of calculations!
Can anybody help me?
My code this week has no errors. But it's Monday morning and I haven't got out of bed.
this is one approach:
- create an abstract base class that represents a drawable item; give it a Transformation Matrix member that initially is set to the unity matrix.
- derive all drawable items (lines, rectangles, circles, ...) from it; in the Paint handler, apply the transformation matrix to your Graphics object before drawing the object.
- when one or more drawable items are selected and a transformation gets ordered (translation, rotation, scaling) adjust the matrix for each selected object, i.e. calculate the matrix that represents the new transformation and combine it with the individual matrices.
The main problem that remains now is mapping mouse positions to the relevant drawable item;
there is no inverse matrix so you can't directly go from mouse position to item; you have to enumerate the items, for each enumerate the clickable parts (points, edges, surfaces), apply the transformation to them and check for a mouse hit.
Thanks for the reply.
I've toyed around with using the matrix class but I can't seem to justify transforming a whole collection of shapes every time I need the coordinates. The transforms would also have to be applied on every paint operation. This seems to be too much of a cpu hog.
I wish I had a more firm grip on trigonomerty so the points could be scaled along the rotational axis.
My code this week has no errors. But it's Monday morning and I haven't got out of bed.
if you don't want to store and re-apply the transformation matrices on every paint or mouse action, you will have to store actual coordinates in the derived class, and modify those when you apply a new transformation. The logic required to transform a single point can still be implemented once in the base class, and used in the derived classes as often as is required.
If its a CPU hog, consider buffering or picking a framework like Piccolo or WPF which takes care of most of the details for you.
An affine transform matrix can almost be seen as a cache of how the input vertex relates to the output vertex. I would expect that performing the actual trig operation on every vertex would be quite slow indeed.
Take a look at the graphics primer that the Piccolo project provides, you'll probably find it fairly helpful.
I am creating a generic custom controls (for instance, say button) using OpenGL for drawing. So what I did is, created a window and initialized the OpenGL with window handle and DC. And drawn something to OpenGL context and so on.
So when multiple instance of my control is used, the OpenGL context will be created for each (control) window.
My question is that, creating many OpenGL contexts (with wglCreateContext) is having problems of any kind?
I have some images in an old non-standard file format that I'd like to display into the MDI window of my new app. I've got the image read in from the file and MFC is making the correct size window for it but how do I blt the array to the window?
I'm fairly sure that there is no existing MFC function that will do this easily. But, if you want to use the BitBlt[^] GDI function to display your array, it must be in the native windows bitmap format. I have no idea what your "old non-standard file format" is like. But, if you can read the existing pixel data into a continuous linear array, with a bit depth that is equivalent to one of the standard bitmap bitsperpixel values (16, 24, or 32 bpp), and write the headers yourself, it should work. You should read this: Bitmap Header Types[^].
Hey I just got it working, thank God! I've been using the CImage class to load in all the other types of images and I just do a CImage::Create to setup a bitmap with the correct dimensions and bpp, and then call SetPixel to load each pixel into the bitmap. It works! Maybe a little slow for some larger images but it works. I tried this before w/o the Create call and it didn't work, so that was the key.
There might be a faster way so if you think of one let me know.
I would like to check the following idea having problems or not...
1. Initiates openGL with double buffer enabled
2. Render something to back buffer and call SwapBuffers.
3. Render the same again. (To fill the other buffer)
4. Called SwapBuffers only for handling WM_PAINT. That is, no repeated rendering since there is no change in what to draw.
So the point is that, rendering is done when needed to modify the drawing. But whenever repainting is needed the buffer is just swapped to retain the painting. I checked the same and its working fine. But rendering need to be done two times to update both front and back buffers.
Is this way OK? If so how can I avoid the rendering two times?
Matters on what you are trying to do, you don't need to use wm_paint at all, you can update the render whenever you feel you need to.
If you need to continually update the window, u can use a pump, ie:
I get the feeling that the best approach for you is to use a FBO and do offscreen rendering.
Google "opengl render to texture", you can bind a frame buffer at the start of your rendering, then blit it as needed.
I'm working with a file format that outputs graphics (in line segments only, no polygons, no points), but has a very screwy way of doing so. Without giving too much away, I'm able to retrieve the list of points from the file with some fairly straightforward calls. However, I need to transform these points and store them (they'll later be used to draw, but I need the points for further manipulation). The problem is that the way the points are currently stored is as follows:
A) The origin (0,0) is in the middle of the drawing, like you would have on a piece of graph paper. I need to transform it so that it will look right on the screen.
B) The image is centered on the origin.
C) The image is inverted along the Y axis.
D) The points in question are already in a nice data structure that includes color and other information.
How can I quickly transform all these points such that if I just used DrawLines, that they would come out correctly? All the matrix code I can find is based around applying transforms to the graphics object, which I don't need to do at the moment. Also, in what order should I do the relevant transforms? I'm thinking that I should flip it first, then shift it (+width, +height). Is that the correct approach?
Performance is not an issue, as users won't be waiting on this operation to complete (or if they are, I can revisit the issue with the intent of collecting more money from them).
you would need one or more of the transform methods in the Graphics class.
Graphics.TranslateTransform does translation, such as moving the origin to the center;
Graphics.ScaleTransform does scaling, and if you use a negative number you are actually flipping the drawing;
Graphics.RotateTransform does rotations, which you don't seem to need.
I trust all of these internally construct a single 3*3 transformation matrix which then gets applied
to all the drawing methods called thereafter.
When you would use more than one of the above, you can choose the order; first scale, then translate,
or first translate, then scale can be made to result in exactly the same, but it would require different parameter values since the first transformation gets applied to the parameters of the second translation.
You can also calculate the entire transformation matrix yourself and just use Graphics.Matrix
Hint: initially you will probably make mistakes in the polarity and magnitude of the transformation parameters, sending your points way outside your plotting area, hence I suggest you start with a very small drawing in a big surface, improving the chance you do see something. You then can fix whatever needs fixing step by step.
As a heads up - keep in mind the GDI+ Matrix object is marked IDisposable. Fairly crazy for a small float array I know - but you will leak handles if you don't dispose of it.
Also creating / destroying these seems to be moderately expensive. I used GDI+ for a crap debug renderer for Entanglar before I got a DirectX one up - and it was quite slow until I started reusing the "camera" matrix every frame with "LoadThisStuff(float)".