Skip to content

Instantly share code, notes, and snippets.

@rtroe
Last active March 7, 2016 11:29
Show Gist options
  • Save rtroe/d956c689de0b3e28dbf5 to your computer and use it in GitHub Desktop.
Save rtroe/d956c689de0b3e28dbf5 to your computer and use it in GitHub Desktop.
Handle(V3d_Viewer) wxOCEWindow::Viewer (wxWindow* panel,
const Standard_ExtString theName,
const Standard_CString theDomain,
const Standard_Real theViewSize,
const V3d_TypeOfOrientation theViewProj,
const Standard_Boolean theComputedMode,
const Standard_Boolean theDefaultComputedMode )
{
static Handle(OpenGl_GraphicDriver) aGraphicDriver;
aDisplayConnection = new Aspect_DisplayConnection();
if (aGraphicDriver.IsNull())
{
aDisplayConnection = new Aspect_DisplayConnection ();
aGraphicDriver = new OpenGl_GraphicDriver (aDisplayConnection);
}
Handle(V3d_Viewer) v = new V3d_Viewer (aGraphicDriver,
theName,
theDomain,
theViewSize,
theViewProj,
Quantity_NOC_GRAY30,
V3d_ZBUFFER,
V3d_GOURAUD,
V3d_WAIT,
theComputedMode,
theDefaultComputedMode,
V3d_TEX_NONE);
//Create the View
mView = v->CreateView();
//This works in GTK 1,0 apperantly but breaks in GTK 2.0...need a better solution
//GdkWindow* draw_window = GTK_PIZZA(this)->bin_window;
//First Retreive the GTK Widget (This is handled differently in MSW and MAC)
GtkWidget* widget = panel->GetHandle();
// Mandatory. Otherwise, a segfault happens. (Learned this one the hard way)
gtk_widget_realize( widget );
//Old Habbts I guess...
gtk_widget_set_double_buffered(widget, 1);
//Now retireve the X11 Window
Window wid = GDK_WINDOW_XWINDOW( widget->window );
//The above line can be done with the following as well.
// Window wid = gdk_x11_drawable_get_xid(gtk_widget_get_window(panel->GetHandle()));
XSync(GDK_WINDOW_XDISPLAY(widget->window), False);
//Now create the Xw window as a wrapper of the window we've so tirelessly had to go and retreive.
wind = new Xw_Window(aDisplayConnection, wid);
//Un Comment this line below to create a seperate window (defeats the purpose of this hole exercise though)
//Handle(Xw_Window) wind = new Xw_Window(aDisplayConnection,"test", 20,20,400,400);
//Now set the Window to the View
mView->SetWindow(wind);
//Don't forget to Map the Window
if(!wind->IsMapped()) wind->Map();
//Now Draw the Scene
mView->Redraw();
return v;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment