I am working on an application with VTK windows. (my VTK version is 5.8.0)
Leaving "VTK render window", all other windows are hidden.
But it is necessary to render the hidden windows because the rendered images of the hidden windows are needed to be stored as images.
here is sample code.
std::vector<vtkRenderer*> renderers;
renderers.reserve(m_numberOfRenderer); // m_numberOfRenderer = 4
std::vector<vtkRenderWindow*> windows;
windows.reserve(m_numberOfRenderer);
for(int i=0; i<m_numberOfRenderer; i++)
{
vtkRenderer* renderer = vtkRenderer::New();
vtkRenderWindow* window = vtkRenderWindow::New();
renderer->TwoSidedLightingOff();
window->OffScreenRenderingOn();
window->SetSize(m_width, m_height);
window->AddRenderer(renderer);
renderer->SetActiveCamera(m_renderCamera.at(i));
renderer->AddActor(m_actor.at(i));
renderer->AddActor(m_outActor.at(i));
renderers.push_back(renderer);
windows.push_back(window);
}
My code is working fine but sometimes crashes on OffScreenRenderingOn method
THIS IS VTK CLASS REF --- http://www.vtk.org/doc/nightly/html/classvtkWindow.html#a25c2cd7f6dad61d91f148da42bc8e780)
virtual void vtkWindow::OffScreenRenderingOn()
Creates a window in memory instead of on the screen. This may not be supported for every type of window and on some windows you may need to invoke this prior to the first render.
i don't know that some windows you may need to invoke this prior to the first render.
i appreciate any help,
Thanks in advance
Related
I have a C++ program that I used this simple gtk code at first of my main() function, and my goal is my app shows an image when it started and keeping showing the image and keep the rest of program.
GtkWidget* window;
GtkWidget* image1;
GtkWidget* image2;
gtk_init (NULL,NULL);
window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
image1 = gtk_image_new_from_file("1.jpg");
image2 = gtk_image_new_from_file("2.jpg");
window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
g_signal_connect(G_OBJECT (window), "destroy",
G_CALLBACK (destroy), NULL);
gtk_container_add(GTK_CONTAINER (window), image1);
gtk_widget_show_all(window);
gtk_main();
THE REST OF PROGRAM THAT WONT EXECUTE!
But when it opens a window and shows the image, it stuck there and doesn't execute the rest of code! Why this happens?
After you execute gtk_main, your code will "block", if i can say that, in that line until gtk_main_quit it's called/executed.
This is the nature of graphical user interfaces. Typically, you setup everything, call the main loop and wait for user interaction.
I would suggest that you read GNOME's Getting Started with GTK+.
As an example, if you do any printf below gtk_main, it will get printed after you close the GtkWindow.
Your application logic must be defined previously, then by means of user interaction, pressing buttons and other widgets, the application will do "things".
When you call gtk_main, the main loop starts.
The main event loop manages all the available sources of events for
GLib and GTK+ applications. These events can come from any number of
different types of sources such as file descriptors (plain files,
pipes or sockets) and timeouts.
You can read more about it here.
I'm trying to move other applications in OSX using the accessibility API. I actually have this working. But I ran into a major issue.
AXUIElementRef appRef = AXUIElementCreateApplication(self.pid);
This uses the PID of my application to to later move the window. I found that multiple windows have the same PID, and when i try and move the second window of application my app crashes.
Can I move my application using just WindowID?
The way to uniquely identify a particular window if you really need to is by going through the results of CGWindowListCopyWindowInfo to select the ones matching the pid that you're using for appRef there; then the kCGWindowNumber CFNumber is Quartz's unique CGWindowID for that window.
However, sounds more likely that you're just indexing through the windows incorrectly. This should work for your appRef:
CFArrayRef windows;
AXUIElementCopyAttributeValue(appRef, kAXWindowsAttribute, (CFTypeRef*)&windows);
int windowCount = windows ? CFArrayGetCount(windows) : 0;
for (int windowIndex = 0; windowIndex < windowCount; windowIndex++)
{
AXUIElementRef windowRef = (AXUIElementRef)CFArrayGetValueAtIndex(windows, windowIndex);
... move windowRef here ...
}
If that doesn't make the problem obvious, post the code which crashes and how it does so.
I have a working game where I am loading all the textures from a different class. It works perfectly fine for the PC version.
Now, I am trying to port it to win8 using Monogame.
If I load a texture from Game1.cs using .xnb file it works absolutely fine. However, when I try to load the same texture by using a different class, it doesn't. It gives me an NullReferenceException error on
GraphicsDevice.Clear(Color.Cornflowerblue);
HungryCoder:
I don't know how you are loading the texture from the class, however, right now MonoGame doesn't yet have a Content Pipeline like you were provided with in building and XNA Game for the PC (they are working on it), therefore, you cannot add graphic files in the same manner.
In my walkthrough of building a Windows 8 XNA game, I create my Shooter player graphic from my own Player class by passing into my Initialize function within the class the Content.Load<> with the Texture type and location:
player.Initialize(Content.Load("Graphics\player"), playerPosition);
Note the .xnb file is located in a folder Graphics within my project.
In my background, I have also created a parallaxing background from a my background class by passing in the full Content Manager to my Initialize method of my Background class as well.
bgLayer1 = new ParallaxingBackground();
bgLayer1.Initialize(Content, "Graphics\bgLayer1", GraphicsDevice.Viewport.Width, -1);
Both of these examples work within my project/game.
If you interested have posted the player code example as a part of blog tutorial series on MonoGame on Windows 8. As I complete the code for the background, I will also add the full code example for the background as well. Hope this helps.
http://blogs.msdn.com/tarawalker
I created a fullscreen app with the following to hide the mouse...
// need this hack to hide the mouse for AIR for some reason...for OSX
// http://blog.formatlos.de/2008/11/16/air-hiding-the-mouse/
stage.nativeWindow.activate();
stage.nativeWindow.orderToBack();
stage.nativeWindow.orderToFront();
Mouse.hide();
This works on my machine at home running OSX Lion...but when this is installed on the client's machine (also running OSX...I need to find out the version), the mouse does not hide?
When I take out the 3 line hack before the Mouse.hide(), the mouse does not hide on my machine. Will test this out on the client's machine too.
Anyone experience this before?
Are you including flash.ui.Mouse in your code?
import flash.ui.Mouse;
Take a look in this site: http://samhassan.co.uk/2008/10/08/air-10-mousehide-work-around/
You could try to hide mouse cursor when the first enterFrame event is fired. Some elements are not fully available till the first frame is build:
// i.e. on main app initilize event handler
addEventListener(Event.ENTER_FRAME, onEnterFrame);
private function onEnterFrame(event:Event):void {
Mouse.hide();
removeEventListener(Event.ENTER_FRAME, onEnterFrame);
}
This way, you have not to rely on hacks or workarounds.
I'm trying to gauge the possibility of a patch to WebKit which would allow all rendered graphics to be rendered onto a fully transparent background.
The desired effect is to render web content without any background at all, it should appear to float over the desktop (or whatever is displayed behind the browser window).
Has anyone seen an app do this? (I can think of some terminal emulators that can.) If anyone has worked inside of WebKit (or possibly Gecko?) do you think it would be possible to do this?
Update: I've come to realize that Mac OSX dashboard widgets use this exact technique. So, this must be possible.
Update 2: I've compiled WebKit on linux and noticed the configure options include:
--enable-dashboard-support
enable Dashboard support default=yes
I'm getting closer. Can anyone help?
Update 3: I continue to find references to this in posts on various related mailing lists.
https://lists.webkit.org/pipermail/webkit-dev/2008-September/005019.html
https://lists.webkit.org/pipermail/webkit-dev/2009-June/008182.html
Solved!
Through ongoing research, scouring forums and source code repositories, I peiced together the necessary steps to accomplish this using only libwebkit and a standard compiz desktop (any Xorg desktop with compositing should do).
For a current libwebkit (1.1.10-SVN), there is an Ubuntu PPA:
deb http://ppa.launchpad.net/webkit-team/ppa/ubuntu jaunty main
deb-src http://ppa.launchpad.net/webkit-team/ppa/ubuntu jaunty main
As far as the code goes, the key is calling webkit_web_view_set_transparent.
And of course the system you're running it on should have a capable graphics card (intel, radeon, or nvidia) and be running a compositing window manager (like Compiz).
And finally, to actually see transparency, the content you're viewing must set a transparent background using CSS3, otherwise it's still completely opaque.
It's as simple as:
BODY { background-color: rgba(0,0,0,0); }
Here' is the full sample for the simplest possible webkit browser app, with transparency support:
#include <gtk/gtk.h>
#include <webkit/webkit.h>
static void destroy_cb(GtkWidget* widget, gpointer data) {
gtk_main_quit();
}
int main(int argc, char* argv[]) {
gtk_init(&argc, &argv);
if(!g_thread_supported())
g_thread_init(NULL);
// Create a Window, set colormap to RGBA
GtkWidget* window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
GdkScreen *screen = gtk_widget_get_screen(window);
GdkColormap *rgba = gdk_screen_get_rgba_colormap (screen);
if (rgba && gdk_screen_is_composited (screen)) {
gtk_widget_set_default_colormap(rgba);
gtk_widget_set_colormap(GTK_WIDGET(window), rgba);
}
gtk_window_set_default_size(GTK_WINDOW(window), 800, 800);
g_signal_connect(window, "destroy", G_CALLBACK(destroy_cb), NULL);
// Optional: for dashboard style borderless windows
gtk_window_set_decorated(GTK_WINDOW(window), FALSE);
// Create a WebView, set it transparent, add it to the window
WebKitWebView* web_view = web_view = WEBKIT_WEB_VIEW(webkit_web_view_new());
webkit_web_view_set_transparent(web_view, TRUE);
gtk_container_add (GTK_CONTAINER(window), GTK_WIDGET(web_view));
// Load a default page
webkit_web_view_load_uri(web_view, "http://stackoverflow.com/");
// Show it and continue running until the window closes
gtk_widget_grab_focus(GTK_WIDGET(web_view));
gtk_widget_show_all(window);
gtk_main();
return 0;
}
Back in Safari 1.3 and 2, there was a hidden debug menu (invoked via the Terminal: defaults write com.apple.Safari IncludeDebugMenu 1) that included a “Use Transparent Window” option.
http://www.macosxhints.com/article.php?story=20050418015445258
http://www.wiredatom.com/blog/2005/10/20/safari-transparency/
Not sure if this was a WebKit thing or a Safari thing though.
(In Safari 3, the debug menu seems to have been replaced by the “Develop” menu (enable in Preferences > Advanced) which doesn’t have the transparent window option.)
Basically you want to be setting the ARGB colour space to be sending to the window manager. Obviously only window managers that support compositing will be able to take advantage of this.
You might want to talk to the screenlet and compiz developers they should be able to help out more.
This gist works for me, as of 2013, tested only with ubuntu:
https://gist.github.com/pouria-mellati/7771779
I have a new solution which is really easy to do, for a single screenshot. It's using node.js with phantom.js library.
install node.js
run 'npm install -g phantomjs' in console/terminal
save the following as script.js and run it from console 'phantomjs script.js'
var page = require('webpage').create();
page.viewportSize = { width: 1920, height: 1500 };
page.open("http://www.theWebYouWantToRender");
page.onLoadFinished = function(status) {
page.evaluate(function() {
document.body.style.background = 'transparent';
});
page.render('render.png');
phantom.exit();
};
profit? :) enjoy