2.5
[blender.git] / source / blender / editors / space_view3d / view3d_view.c
index 5f1957b84b6ed926f0081f24bc04c714c72d0f76..7c2f5a7d5ab9efb745a9ac1bf5d0719b7ad08468 100644 (file)
@@ -51,6 +51,7 @@
 
 #include "BKE_anim.h"
 #include "BKE_action.h"
+#include "BKE_context.h"
 #include "BKE_object.h"
 #include "BKE_global.h"
 #include "BKE_main.h"
 
 #define BL_NEAR_CLIP 0.001
 
+/* use this call when executing an operator,
+   event system doesn't set for each event the
+   opengl drawing context */
+void view3d_operator_needs_opengl(const bContext *C)
+{
+       ARegion *ar= CTX_wm_region(C);
+
+       /* for debugging purpose, context should always be OK */
+       if(ar->regiontype!=RGN_TYPE_WINDOW)
+               printf("view3d_operator_needs_opengl error, wrong region\n");
+       else {
+               ScrArea *sa= CTX_wm_area(C);
+               View3D *v3d= sa->spacedata.first;
+               
+               wmSubWindowSet(CTX_wm_window(C), ar->swinid);
+               glMatrixMode(GL_PROJECTION);
+               wmLoadMatrix(v3d->winmat);
+               glMatrixMode(GL_MODELVIEW);
+               wmLoadMatrix(v3d->viewmat);
+       }
+}
+
 float *give_cursor(Scene *scene, View3D *v3d)
 {
        if(v3d && v3d->localview) return v3d->cursor;