I am stuck on OpenGL 1.1 for a particular game-modding project, and I am using a display list as a sort of snapshot of part of the game, where I begin the display list, direct those parts to render, and close the display list. This correctly results in a display list I can then transform and render at will.
However, while I am transforming and rendering that display list, the part of the game that was snapshotted ceases to exist, and it destroys any display lists that it had been using, meaning when I render my snapshot, those parts that were display lists then fail to render.
What I would like to be able to do is somehow direct OpenGL to copy the contents of nested display lists into the top-level one instead of just embedding the call to the nested display list. I haven't been able to find any function that would do what I want. Does one exist?
(No, the parts of the game I am snapshotting are not predictable, and are likely to be wildly different every single time.)
I think your best bet would be to hook into all relevant OpenGL calls, by injecting a "opengl32.dll" hooking DLL with entry points identical to the OpenGL ones, but each one making a copy of the relevant data.
Related
I've inherited a Javascript application that has uses Raphael JS to draw a diagram. Drawing the diagram contributes very substantially to the loading time of the application. I thought that since the diagram is never scaled and is drawn exactly the same time each time the page loads, it might make sense to render the diagram as a simple raster image. However, this doesn't work because mouse events are attached to the individual figures within the diagram.
Looking thru the code, I see that it consists of repeated calls to Raphael.path.
Unfortunately, for reasons beyond my control, my users are constrained to use IE 11.
Is there some practical way that I can make the application render the diagram faster? Is there perhaps some practical way to serialize the result of calling Raphael.path repeatedly so that the user doesn't have to wait for these operations at every page load?
I have a device context which has some font selected into it, and I would like to DrawText on an ID2D1RenderTarget.
Currently, I go the following route to acchieve this:
Obtain an IDWriteFontFace via CreateFontFaceFromHdc.
Obtain an IDWriteFont from the IDWriteFontFace via the default system font collection (which I get via GetSystemFontCollection - see the next step).
Obtain an IDWriteTextFormat via CreateTextFormat, supplying the parameters specified in the IDWriteFont and specifying nullptr as fontCollection, indicating that I would like to use the default system font collection.
Pass the IDWriteTextFormat to DrawText.
What I find strange about this is that I already have an IDWriteFontFace in the first step, and apparently have to "go back" and ask a font collection for an IDWriteFont, just to pass that to a DrawTextFormat, which can then be used to DrawText. This seems unnecessarily complicated - especially since to draw the text, the system probably has to go down to a IDWriteFontFace anyway, right?
I found DrawGlyphRun, but this takes e.g. a baselineOrigin, which I would have to compute beforehand (not to mention the glyphRun itself).
Isn't there a simpler way to draw text onto an ID2D1RenderTarget if I already have an IDWriteFontFace?
That's the only way, like you described. You go back to construct text format instance, and then use it for DirectWrite-style rendering. DrawGlyphRun is a low level method, you can use it of course, but you'll have to implement a lot of layout logic yourself, and that's something to avoid. Generally speaking DrawText is the least efficient method of rendering with Direct2D, better way is to create layout object once and use it every time you need to redraw.
I tried to implement(i.e. draw on) two UserControl with the same OpenGL context in the same one form. In other words, i wanna show two same picture simultaneous on the form. My tool is VC6 and use C++.
I've tried many methods but failed. Could someone give me a simple sample code or some advises?
edit
It looks like there's two possibilities - either copy the final image to the second GUI element or create a second "device context" for the second element, use *MakeCurrent to change to it (see link and discussion below) and re-render or blit the result.
Copy:
Assuming the GL context draws directly to your primary GUI element (which would stop you using the GUI library to do the copy), you can copy the data via glReadPixels or investigate drawing to a texture via a Frame Buffer Object and use glGetTexImage2D. Then I guess find some way to display the raw image data on the second GUI element (this part I have no experience in).
MakeCurrent:
Make current OpenGL context on Linux
I have to design a GUI using Qt. I would like to draw multiple lines depicting relationships between two objects. It's the same idea as matching a word with a definition by drawing a straight line (which might be a diagonal) between the two.
In my case it is an a label (with image inside of it) that needs to be matched with another label.
So we have something like this - http://dl.dropbox.com/u/46437808/DrawLines.png
And I want to add lines to make it look something like this http://dl.dropbox.com/u/46437808/DrawLines2.png
I need to do this in run time because the relationship will be changing based on different factors.
Thanks!
Do you need interaction or is this just an image that the user needs to see based on other information? If it's just a static image, I would simply draw it onto a QImage and show it. That way you have complete control over how things are drawn. So you can either cache the relationship diagrams you need ahead of time, or just draw them on the fly onto the QImage based on the relationship that needs to be displayed at the time. You can look at Qt's painting example for some ideas on how to accomplish what you need.
If you need interactivity, I would probably go with the Graphics View Framework. This way if you need push buttons, check boxes, etc. for any reason you can use the QGraphicsProxyWidget to get them, or you can just make your own from QGraphicsItem subclasses.
I used the owner-drawn strategy on CMyListBox class which derives from CListBox. I only want the DrawItem() method to perform when I insert an item in the listbox. But the method is invoked many times. How can I change to invoke it whenever I need.
You could always cache the initial drawing by outputting the content to an in-memory bitmap and then drawing that, it does mean you need to track when something has changed so you can run the actual rending code agaain. It does save running through your render code everytime if there's a lot of it.
I've done exactly what Kieron suggests by caching bitmaps, but only in very expensive rendering code. I actually have to keep multiple cached "states" depending on if an item is highlighted, disabled, normal, etc (this is for toolbar buttons, not listitem - but I think it applies). I only cache the pre-rendered image when I first need it - that way I only cache "states" that I actually need.
My drawing was pure GDI calls. Mostly bitmap manipulations and other drawing that just takes time, plus I was being redrawn much too often (for no good reason - long story).
Changing the fundamentals in the framework I was using (MFC and Stingray) was just not an option. The caching was a last resort after all other optimizations weren't good enough (damn slow virtual machines!!).
Normally drawing is fast enough to do when you're invalidated (DrawItem in this case). I would take a look at what exactly you're doing in DrawItem. I would look into caching data and calculations that are needed by rendering and not the rendering itself (eg the final bitmaps) unless there are no other options.
Also, I read the Vista rending is more optimized, they cache what you've drawn on your window to reduce the contain invalidate/redraw cycle when, for example, a window is moved from behind another.
The DrawItem() method is called whenever there is a requirement to draw any given item in the listbox. If you do not respond to it you are likely to get a blank area in your list box, where the drawn data has been erased and you have not refreshed it. If you really do not think the drawing is necessary, you could do something like
void CMyListBox::DrawItem( LPDRAWITEMSTRUCT lpDrawItemStruct )
{
if (!m_DrawingEnabled)
return;
}
Where m_DrawingEnabled is a member you maintain to stop unnecessary draws,