Two fixes;

- borderselect draws cleaner info in bottom/left corner window
- OGL render (in view3d header) option didn't work on successive renders.
  was due to removing hack that reopened the window each time. But now it
  needed to be assigned correctly to blender's 'mywindow' system.
This commit is contained in:
2004-09-29 10:49:19 +00:00
parent 01e6d69ff5
commit ceb7d3db46
5 changed files with 73 additions and 39 deletions

View File

@@ -227,6 +227,7 @@ void default_gl_light(void)
glDisable(GL_COLOR_MATERIAL); glDisable(GL_COLOR_MATERIAL);
} }
/* also called when render 'ogl' */
void init_gl_stuff(void) void init_gl_stuff(void)
{ {
float mat_specular[] = { 0.5, 0.5, 0.5, 1.0 }; float mat_specular[] = { 0.5, 0.5, 0.5, 1.0 };
@@ -1930,24 +1931,21 @@ void drawview3dspace(ScrArea *sa, void *spacedata)
*/ */
void drawview3d_render(struct View3D *v3d) void drawview3d_render(struct View3D *v3d)
{ {
extern void mywindow_build_and_set_renderwin(void);
extern short v3d_windowmode; extern short v3d_windowmode;
Base *base; Base *base;
Object *ob; Object *ob;
free_all_realtime_images(); free_all_realtime_images();
mywindow_build_and_set_renderwin();
v3d_windowmode= 1; v3d_windowmode= 1;
setwinmatrixview3d(0); setwinmatrixview3d(0);
v3d_windowmode= 0; v3d_windowmode= 0;
glMatrixMode(GL_PROJECTION); glMatrixMode(GL_PROJECTION);
glLoadMatrixf(R.winmat); myloadmatrix(R.winmat);
glMatrixMode(GL_MODELVIEW); glMatrixMode(GL_MODELVIEW);
setviewmatrixview3d(); setviewmatrixview3d();
glLoadMatrixf(v3d->viewmat); myloadmatrix(v3d->viewmat);
Mat4MulMat4(v3d->persmat, v3d->viewmat, R.winmat); Mat4MulMat4(v3d->persmat, v3d->viewmat, R.winmat);
Mat4Invert(v3d->persinv, v3d->persmat); Mat4Invert(v3d->persinv, v3d->persmat);
Mat4Invert(v3d->viewinv, v3d->viewmat); Mat4Invert(v3d->viewinv, v3d->viewmat);
@@ -1964,11 +1962,10 @@ void drawview3d_render(struct View3D *v3d)
BIF_GetThemeColor3fv(TH_BACK, col); BIF_GetThemeColor3fv(TH_BACK, col);
glClearColor(col[0], col[1], col[2], 0.0); glClearColor(col[0], col[1], col[2], 0.0);
} }
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity(); glLoadIdentity();
glLoadMatrixf(v3d->viewmat); myloadmatrix(v3d->viewmat);
/* abuse! to make sure it doesnt draw the helpstuff */ /* abuse! to make sure it doesnt draw the helpstuff */
G.f |= G_SIMULATION; G.f |= G_SIMULATION;
@@ -2083,7 +2080,7 @@ void drawview3d_render(struct View3D *v3d)
} }
if(G.scene->radio) RAD_drawall(G.vd->drawtype>=OB_SOLID); if(G.scene->radio) RAD_drawall(G.vd->drawtype>=OB_SOLID);
if(G.zbuf) { if(G.zbuf) {
G.zbuf= FALSE; G.zbuf= FALSE;
glDisable(GL_DEPTH_TEST); glDisable(GL_DEPTH_TEST);

View File

@@ -71,21 +71,22 @@
#include "BKE_lattice.h" #include "BKE_lattice.h"
#include "BKE_mesh.h" #include "BKE_mesh.h"
#include "BIF_gl.h"
#include "BIF_mywindow.h"
#include "BIF_screen.h"
#include "BIF_interface.h"
#include "BIF_space.h"
#include "BIF_editview.h"
#include "BIF_glutil.h"
#include "BIF_toolbox.h"
#include "BIF_editmesh.h" #include "BIF_editmesh.h"
#include "BIF_editview.h"
#include "BIF_gl.h"
#include "BIF_glutil.h"
#include "BIF_interface.h"
#include "BIF_mywindow.h"
#include "BIF_resources.h"
#include "BIF_space.h"
#include "BIF_screen.h"
#include "BIF_toolbox.h"
#include "BSE_view.h"
#include "BSE_edit.h" #include "BSE_edit.h"
#include "BSE_trans_types.h"
#include "BSE_drawipo.h" #include "BSE_drawipo.h"
#include "BSE_drawview.h" #include "BSE_drawview.h"
#include "BSE_trans_types.h"
#include "BSE_view.h"
#include "BDR_editobject.h" #include "BDR_editobject.h"
#include "BDR_editmball.h" #include "BDR_editmball.h"
@@ -214,15 +215,18 @@ int get_border(rcti *rect, short col)
/* draw size information in corner */ /* draw size information in corner */
if(curarea->spacetype==SPACE_VIEW3D) { if(curarea->spacetype==SPACE_VIEW3D) {
glColor3f(0.4375, 0.4375, 0.4375); BIF_ThemeColor(TH_BACK);
glRecti(0, 10, 250, 20); glRecti(10, 25, 250, 40);
glColor3f(0.0, 0.0, 0.0);
if(G.vd->persp==0) { if(G.vd->persp==0) {
window_to_3d(dvec, mvalo[0]-x1, mvalo[1]-y1); window_to_3d(dvec, mvalo[0]-x1, mvalo[1]-y1);
glRasterPos2i(10, 10);
sprintf(str, "X %.4f Y %.4f Z %.4f Dia %.4f", dvec[0], dvec[1], dvec[2], sqrt(dvec[0]*dvec[0]+dvec[1]*dvec[1]+dvec[2]*dvec[2])); sprintf(str, "X %.4f Y %.4f Z %.4f Dia %.4f", dvec[0], dvec[1], dvec[2], sqrt(dvec[0]*dvec[0]+dvec[1]*dvec[1]+dvec[2]*dvec[2]));
glColor3f(0.0, 0.0, 0.0);
glRasterPos2i(15, 27);
BMF_DrawString(G.fonts, str);
glColor3f(0.7, 0.7, 0.7);
glRasterPos2i(16, 28);
BMF_DrawString(G.fonts, str); BMF_DrawString(G.fonts, str);
} }
else if(G.vd->persp==2) { else if(G.vd->persp==2) {
@@ -236,25 +240,32 @@ int get_border(rcti *rect, short col)
fac2= (mvalo[1]-y1)/( (float) (vb.ymax-vb.ymin) ); fac2= (mvalo[1]-y1)/( (float) (vb.ymax-vb.ymin) );
fac2*= 0.01*G.scene->r.size*G.scene->r.ysch; fac2*= 0.01*G.scene->r.size*G.scene->r.ysch;
glRasterPos2i(10, 10);
sprintf(str, "X %.1f Y %.1f Dia %.1f", fabs(fac1), fabs(fac2), sqrt(fac1*fac1 + fac2*fac2) ); sprintf(str, "X %.1f Y %.1f Dia %.1f", fabs(fac1), fabs(fac2), sqrt(fac1*fac1 + fac2*fac2) );
glColor3f(0.0, 0.0, 0.0);
glRasterPos2i(15, 27);
BMF_DrawString(G.fonts, str);
glColor3f(0.7, 0.7, 0.7);
glRasterPos2i(16, 28);
BMF_DrawString(G.fonts, str); BMF_DrawString(G.fonts, str);
} }
} }
else if(curarea->spacetype==SPACE_IPO) { else if(curarea->spacetype==SPACE_IPO) {
SpaceIpo *sipo= curarea->spacedata.first; SpaceIpo *sipo= curarea->spacedata.first;
glColor3f(.40625, .40625, .40625); BIF_ThemeColor(TH_BACK);
glRecti(20, 30, 170, 40); glRecti(20, 30, 170, 40);
glColor3f(0.0, 0.0, 0.0);
mvalo[2]= x1; mvalo[2]= x1;
mvalo[3]= y1; mvalo[3]= y1;
areamouseco_to_ipoco(&sipo->v2d, mval, dvec, dvec+1); areamouseco_to_ipoco(&sipo->v2d, mval, dvec, dvec+1);
areamouseco_to_ipoco(&sipo->v2d, mvalo+2, dvec+2, dvec+3); areamouseco_to_ipoco(&sipo->v2d, mvalo+2, dvec+2, dvec+3);
glRasterPos2i(30, 30);
sprintf(str, "Time: %.4f Y %.4f", dvec[0]-dvec[2], dvec[1]-dvec[3]); sprintf(str, "Time: %.4f Y %.4f", dvec[0]-dvec[2], dvec[1]-dvec[3]);
glRasterPos2i(30, 30);
glColor3f(0.0, 0.0, 0.0);
BMF_DrawString(G.fonts, str);
glRasterPos2i(31, 31);
glColor3f(0.9, 0.9, 0.9);
BMF_DrawString(G.fonts, str); BMF_DrawString(G.fonts, str);
} }

View File

@@ -114,16 +114,27 @@ void mywindow_init_mainwin(Window *win, int orx, int ory, int sizex, int sizey)
} }
} }
/* XXXXXXXXXXXXXXXX very hacky, not allowed to release again after 2.24 /* XXXXXXXXXXXXXXXX very hacky, because of blenderwindows vs ghostwindows vs renderwindow
* again after 2.24 this routine sets up a blenderwin (a mywin)
*/ */
void mywindow_build_and_set_renderwin(void) void mywindow_build_and_set_renderwin( int orx, int ory, int sizex, int sizey)
{ {
swinarray[2]= &renderwindow;
renderwindow.xmin= orx;
renderwindow.ymin= ory;
renderwindow.xmax= orx+sizex-1;
renderwindow.ymax= ory+sizey-1;
renderwindow.qevents= NULL;
myortho2(-0.5, (float)sizex-0.5, -0.5, (float)sizey-0.5);
glLoadIdentity();
glGetFloatv(GL_PROJECTION_MATRIX, (float *)renderwindow.winmat); glGetFloatv(GL_PROJECTION_MATRIX, (float *)renderwindow.winmat);
glGetFloatv(GL_MODELVIEW_MATRIX, (float *)renderwindow.viewmat); glGetFloatv(GL_MODELVIEW_MATRIX, (float *)renderwindow.viewmat);
swinarray[2]= &renderwindow; mywinset(2);
renderwindow.qevents= NULL;
curswin= 2; curswin= 2;
} }
@@ -318,8 +329,7 @@ void mywinset(int wid)
printf("mywinset %d: doesn't exist\n", wid); printf("mywinset %d: doesn't exist\n", wid);
return; return;
} }
if (wid == 1 || wid == 2) { /* main window or renderwindow*/
if (wid == 1) { /* main window */
glViewport(0, 0, ( win->xmax-win->xmin)+1, ( win->ymax-win->ymin)+1); glViewport(0, 0, ( win->xmax-win->xmin)+1, ( win->ymax-win->ymin)+1);
glScissor(0, 0, ( win->xmax-win->xmin)+1, ( win->ymax-win->ymin)+1); glScissor(0, 0, ( win->xmax-win->xmin)+1, ( win->ymax-win->ymin)+1);
} }

View File

@@ -467,6 +467,7 @@ static char *renderwin_get_title(int doswap)
/* opens window and allocs struct */ /* opens window and allocs struct */
static void open_renderwin(int winpos[2], int winsize[2]) static void open_renderwin(int winpos[2], int winsize[2])
{ {
extern void mywindow_build_and_set_renderwin( int orx, int ory, int sizex, int sizey); // mywindow.c
Window *win; Window *win;
char *title; char *title;
@@ -481,7 +482,12 @@ static void open_renderwin(int winpos[2], int winsize[2])
winlay_process_events(0); winlay_process_events(0);
window_make_active(render_win->win); window_make_active(render_win->win);
winlay_process_events(0); winlay_process_events(0);
/* mywindow has to know about it too */
mywindow_build_and_set_renderwin(winpos[0], winpos[1], winsize[0], winsize[1]);
/* and we should be able to draw 3d in it */
init_gl_stuff();
renderwin_draw(render_win, 1); renderwin_draw(render_win, 1);
renderwin_draw(render_win, 1); renderwin_draw(render_win, 1);
} }
@@ -565,6 +571,7 @@ static void renderwin_init_display_cb(void)
else { else {
window_raise(render_win->win); window_raise(render_win->win);
window_make_active(render_win->win); window_make_active(render_win->win);
mywinset(2); // to assign scissor/viewport again in mywindow.c. is hackish yes
} }
renderwin_reset_view(render_win); renderwin_reset_view(render_win);
@@ -849,7 +856,7 @@ static void do_render(View3D *ogl_render_view3d, int anim, int force_dispwin)
window_set_cursor(render_win->win, CURSOR_WAIT); window_set_cursor(render_win->win, CURSOR_WAIT);
// when opening new window... not cross platform identical behaviour, so // when opening new window... not cross platform identical behaviour, so
// for now call it each time // for now call it each time
if(ogl_render_view3d) init_gl_stuff(); // if(ogl_render_view3d) init_gl_stuff();
} }
waitcursor(1); waitcursor(1);
@@ -924,6 +931,14 @@ static void scalefastrect(unsigned int *recto, unsigned int *rectn, int oldx, in
/* -------------- API: externally called --------------- */ /* -------------- API: externally called --------------- */
void BIF_renderwin_make_active(void)
{
if(render_win) {
window_make_active(render_win->win);
mywinset(2);
}
}
/* set up display, render an image or scene */ /* set up display, render an image or scene */
void BIF_do_render(int anim) void BIF_do_render(int anim)
{ {

View File

@@ -586,6 +586,7 @@ void viewmove(int mode)
short v3d_windowmode=0; short v3d_windowmode=0;
/* important to not set windows active in here, can be renderwin for example */
void setwinmatrixview3d(rctf *rect) /* rect: for picking */ void setwinmatrixview3d(rctf *rect) /* rect: for picking */
{ {
Camera *cam=0; Camera *cam=0;
@@ -629,7 +630,7 @@ void setwinmatrixview3d(rctf *rect) /* rect: for picking */
} }
} }
if(v3d_windowmode) { if(v3d_windowmode) { // hackish
winx= R.rectx; winx= R.rectx;
winy= R.recty; winy= R.recty;
} }
@@ -723,7 +724,7 @@ void obmat_to_viewmat(Object *ob)
Mat3ToQuat(tmat, G.vd->viewquat); Mat3ToQuat(tmat, G.vd->viewquat);
} }
/* dont set windows active in in here, is used by renderwin too */
void setviewmatrixview3d() void setviewmatrixview3d()
{ {
Camera *cam; Camera *cam;