This repository has been archived on 2023-10-09. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
blender-archive/source/blender/src/renderwin.c

1236 lines
30 KiB
C
Raw Normal View History

2002-10-12 11:37:38 +00:00
/**
* $Id$
*
* ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version. The Blender
* Foundation also sells licenses for use in proprietary software under
* the Blender License. See http://www.blender.org/BL/ for information
* about this.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
* All rights reserved.
*
* The Original Code is: all of this file.
*
* Contributor(s): none yet.
*
* ***** END GPL/BL DUAL LICENSE BLOCK *****
*/
#ifdef WIN32
/* for the multimedia timer */
#include <windows.h>
#include <mmsystem.h>
#endif
2002-10-12 11:37:38 +00:00
#include <string.h>
#include <stdarg.h>
#include <math.h>
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
2002-10-12 11:37:38 +00:00
#ifdef WIN32
#include "BLI_winstuff.h"
#else
/* for signal callback, not (fully) supported at windows */
#include <sys/time.h>
#include <signal.h>
2002-10-12 11:37:38 +00:00
#endif
#include "BLI_blenlib.h"
#include "MEM_guardedalloc.h"
#include "BMF_Api.h"
#include "DNA_view3d_types.h"
#include "DNA_screen_types.h"
#include "DNA_vec_types.h"
#include "BKE_global.h"
#include "BKE_utildefines.h"
#include "BIF_gl.h"
#include "BIF_glutil.h"
#include "BIF_graphics.h"
#include "BIF_screen.h"
#include "BIF_space.h"
#include "BIF_mywindow.h"
Biiig commit! Thanks to 2-3 weeks of cvs freeze... Render: - New; support for dual CPU render (SDL thread) Currently only works with alternating scanlines, but gives excellent performance. For both normal render as unified implemented. Note the "mutex" locks on z-transp buffer render and imbuf loads. - This has been made possible by major cleanups in render code, especially getting rid of globals (example Tin Tr Tg Tb Ta for textures) or struct OSA or using Materials or Texture data to write to. - Made normal render fully 4x32 floats too, and removed all old optimizes with chars or shorts. - Made normal render and unified render use same code for sky and halo render, giving equal (and better) results for halo render. Old render now also uses PostProcess options (brightness, mul, gamma) - Added option ("FBuf") in F10 Output Panel, this keeps a 4x32 bits buffer after render. Using PostProcess menu you will note an immediate re- display of image too (32 bits RGBA) - Added "Hue" and "Saturation" sliders to PostProcess options - Render module is still not having a "nice" API, but amount of dependencies went down a lot. Next todo: remove abusive "previewrender" code. The last main global in Render (struct Render) now can be re-used for fully controlling a render, to allow multiple "instances" of render to open. - Renderwindow now displays a smal bar on top with the stats, and keeps the stats after render too. Including "spare" page support. Not only easier visible that way, but also to remove the awkward code that was drawing stats in the Info header (extreme slow on some ATIs too) - Cleaned up blendef.h and BKE_utildefines.h, these two had overlapping defines. - I might have forgotten stuff... and will write a nice doc on the architecture!
2004-12-27 19:28:52 +00:00
#include "BIF_previewrender.h"
2002-10-12 11:37:38 +00:00
#include "BIF_renderwin.h"
Biiig commit! Thanks to 2-3 weeks of cvs freeze... Render: - New; support for dual CPU render (SDL thread) Currently only works with alternating scanlines, but gives excellent performance. For both normal render as unified implemented. Note the "mutex" locks on z-transp buffer render and imbuf loads. - This has been made possible by major cleanups in render code, especially getting rid of globals (example Tin Tr Tg Tb Ta for textures) or struct OSA or using Materials or Texture data to write to. - Made normal render fully 4x32 floats too, and removed all old optimizes with chars or shorts. - Made normal render and unified render use same code for sky and halo render, giving equal (and better) results for halo render. Old render now also uses PostProcess options (brightness, mul, gamma) - Added option ("FBuf") in F10 Output Panel, this keeps a 4x32 bits buffer after render. Using PostProcess menu you will note an immediate re- display of image too (32 bits RGBA) - Added "Hue" and "Saturation" sliders to PostProcess options - Render module is still not having a "nice" API, but amount of dependencies went down a lot. Next todo: remove abusive "previewrender" code. The last main global in Render (struct Render) now can be re-used for fully controlling a render, to allow multiple "instances" of render to open. - Renderwindow now displays a smal bar on top with the stats, and keeps the stats after render too. Including "spare" page support. Not only easier visible that way, but also to remove the awkward code that was drawing stats in the Info header (extreme slow on some ATIs too) - Cleaned up blendef.h and BKE_utildefines.h, these two had overlapping defines. - I might have forgotten stuff... and will write a nice doc on the architecture!
2004-12-27 19:28:52 +00:00
#include "BIF_resources.h"
2002-10-12 11:37:38 +00:00
#include "BIF_toets.h"
#include "BDR_editobject.h"
#include "BSE_view.h"
#include "BSE_drawview.h"
#include "BSE_filesel.h"
#include "BSE_headerbuttons.h"
#include "blendef.h"
#include "mydevice.h"
#include "winlay.h"
#include "render.h"
/* ------------ renderwin struct, to prevent too much global vars --------- */
/* ------------ only used for display in a 2nd window --------- */
/* flags escape presses during event handling
* so we can test for user break later.
*/
#define RW_FLAGS_ESCAPE (1<<0)
/* old zoom style (2x, locked to mouse, exits
* when mouse leaves window), to be removed
* at some point.
*/
#define RW_FLAGS_OLDZOOM (1<<1)
/* on when image is being panned with middlemouse
*/
#define RW_FLAGS_PANNING (1<<2)
/* on when the mouse is dragging over the image
* to examine pixel values.
*/
#define RW_FLAGS_PIXEL_EXAMINING (1<<3)
/* forces draw of alpha */
#define RW_FLAGS_ALPHA (1<<4)
2002-10-12 11:37:38 +00:00
Biiig commit! Thanks to 2-3 weeks of cvs freeze... Render: - New; support for dual CPU render (SDL thread) Currently only works with alternating scanlines, but gives excellent performance. For both normal render as unified implemented. Note the "mutex" locks on z-transp buffer render and imbuf loads. - This has been made possible by major cleanups in render code, especially getting rid of globals (example Tin Tr Tg Tb Ta for textures) or struct OSA or using Materials or Texture data to write to. - Made normal render fully 4x32 floats too, and removed all old optimizes with chars or shorts. - Made normal render and unified render use same code for sky and halo render, giving equal (and better) results for halo render. Old render now also uses PostProcess options (brightness, mul, gamma) - Added option ("FBuf") in F10 Output Panel, this keeps a 4x32 bits buffer after render. Using PostProcess menu you will note an immediate re- display of image too (32 bits RGBA) - Added "Hue" and "Saturation" sliders to PostProcess options - Render module is still not having a "nice" API, but amount of dependencies went down a lot. Next todo: remove abusive "previewrender" code. The last main global in Render (struct Render) now can be re-used for fully controlling a render, to allow multiple "instances" of render to open. - Renderwindow now displays a smal bar on top with the stats, and keeps the stats after render too. Including "spare" page support. Not only easier visible that way, but also to remove the awkward code that was drawing stats in the Info header (extreme slow on some ATIs too) - Cleaned up blendef.h and BKE_utildefines.h, these two had overlapping defines. - I might have forgotten stuff... and will write a nice doc on the architecture!
2004-12-27 19:28:52 +00:00
/* space for info text */
#define RW_HEADERY 18
2002-10-12 11:37:38 +00:00
typedef struct {
Window *win;
float zoom, zoomofs[2];
int active;
int mbut[3];
int lmouse[2];
unsigned int flags;
float pan_mouse_start[2], pan_ofs_start[2];
char *info_text;
Biiig commit! Thanks to 2-3 weeks of cvs freeze... Render: - New; support for dual CPU render (SDL thread) Currently only works with alternating scanlines, but gives excellent performance. For both normal render as unified implemented. Note the "mutex" locks on z-transp buffer render and imbuf loads. - This has been made possible by major cleanups in render code, especially getting rid of globals (example Tin Tr Tg Tb Ta for textures) or struct OSA or using Materials or Texture data to write to. - Made normal render fully 4x32 floats too, and removed all old optimizes with chars or shorts. - Made normal render and unified render use same code for sky and halo render, giving equal (and better) results for halo render. Old render now also uses PostProcess options (brightness, mul, gamma) - Added option ("FBuf") in F10 Output Panel, this keeps a 4x32 bits buffer after render. Using PostProcess menu you will note an immediate re- display of image too (32 bits RGBA) - Added "Hue" and "Saturation" sliders to PostProcess options - Render module is still not having a "nice" API, but amount of dependencies went down a lot. Next todo: remove abusive "previewrender" code. The last main global in Render (struct Render) now can be re-used for fully controlling a render, to allow multiple "instances" of render to open. - Renderwindow now displays a smal bar on top with the stats, and keeps the stats after render too. Including "spare" page support. Not only easier visible that way, but also to remove the awkward code that was drawing stats in the Info header (extreme slow on some ATIs too) - Cleaned up blendef.h and BKE_utildefines.h, these two had overlapping defines. - I might have forgotten stuff... and will write a nice doc on the architecture!
2004-12-27 19:28:52 +00:00
char *render_text, *render_text_spare;
2002-10-12 11:37:38 +00:00
} RenderWin;
static RenderWin *render_win= NULL;
/* --------------- help functions for RenderWin struct ---------------------------- */
/* only called in function open_renderwin */
static RenderWin *renderwin_alloc(Window *win)
2002-10-12 11:37:38 +00:00
{
RenderWin *rw= MEM_mallocN(sizeof(*rw), "RenderWin");
rw->win= win;
rw->zoom= 1.0;
rw->active= 0;
rw->flags= 0;
rw->zoomofs[0]= rw->zoomofs[1]= 0;
rw->info_text= NULL;
Biiig commit! Thanks to 2-3 weeks of cvs freeze... Render: - New; support for dual CPU render (SDL thread) Currently only works with alternating scanlines, but gives excellent performance. For both normal render as unified implemented. Note the "mutex" locks on z-transp buffer render and imbuf loads. - This has been made possible by major cleanups in render code, especially getting rid of globals (example Tin Tr Tg Tb Ta for textures) or struct OSA or using Materials or Texture data to write to. - Made normal render fully 4x32 floats too, and removed all old optimizes with chars or shorts. - Made normal render and unified render use same code for sky and halo render, giving equal (and better) results for halo render. Old render now also uses PostProcess options (brightness, mul, gamma) - Added option ("FBuf") in F10 Output Panel, this keeps a 4x32 bits buffer after render. Using PostProcess menu you will note an immediate re- display of image too (32 bits RGBA) - Added "Hue" and "Saturation" sliders to PostProcess options - Render module is still not having a "nice" API, but amount of dependencies went down a lot. Next todo: remove abusive "previewrender" code. The last main global in Render (struct Render) now can be re-used for fully controlling a render, to allow multiple "instances" of render to open. - Renderwindow now displays a smal bar on top with the stats, and keeps the stats after render too. Including "spare" page support. Not only easier visible that way, but also to remove the awkward code that was drawing stats in the Info header (extreme slow on some ATIs too) - Cleaned up blendef.h and BKE_utildefines.h, these two had overlapping defines. - I might have forgotten stuff... and will write a nice doc on the architecture!
2004-12-27 19:28:52 +00:00
rw->render_text= rw->render_text_spare= NULL;
2002-10-12 11:37:38 +00:00
rw->lmouse[0]= rw->lmouse[1]= 0;
rw->mbut[0]= rw->mbut[1]= rw->mbut[2]= 0;
return rw;
}
static void renderwin_queue_redraw(RenderWin *rw)
{
window_queue_redraw(rw->win); // to ghost
2002-10-12 11:37:38 +00:00
}
static void renderwin_reshape(RenderWin *rw)
{
;
}
static void renderwin_get_disprect(RenderWin *rw, float disprect_r[2][2])
{
float display_w, display_h;
float cent_x, cent_y;
int w, h;
window_get_size(rw->win, &w, &h);
Biiig commit! Thanks to 2-3 weeks of cvs freeze... Render: - New; support for dual CPU render (SDL thread) Currently only works with alternating scanlines, but gives excellent performance. For both normal render as unified implemented. Note the "mutex" locks on z-transp buffer render and imbuf loads. - This has been made possible by major cleanups in render code, especially getting rid of globals (example Tin Tr Tg Tb Ta for textures) or struct OSA or using Materials or Texture data to write to. - Made normal render fully 4x32 floats too, and removed all old optimizes with chars or shorts. - Made normal render and unified render use same code for sky and halo render, giving equal (and better) results for halo render. Old render now also uses PostProcess options (brightness, mul, gamma) - Added option ("FBuf") in F10 Output Panel, this keeps a 4x32 bits buffer after render. Using PostProcess menu you will note an immediate re- display of image too (32 bits RGBA) - Added "Hue" and "Saturation" sliders to PostProcess options - Render module is still not having a "nice" API, but amount of dependencies went down a lot. Next todo: remove abusive "previewrender" code. The last main global in Render (struct Render) now can be re-used for fully controlling a render, to allow multiple "instances" of render to open. - Renderwindow now displays a smal bar on top with the stats, and keeps the stats after render too. Including "spare" page support. Not only easier visible that way, but also to remove the awkward code that was drawing stats in the Info header (extreme slow on some ATIs too) - Cleaned up blendef.h and BKE_utildefines.h, these two had overlapping defines. - I might have forgotten stuff... and will write a nice doc on the architecture!
2004-12-27 19:28:52 +00:00
h-= RW_HEADERY;
2002-10-12 11:37:38 +00:00
display_w= R.rectx*rw->zoom;
display_h= R.recty*rw->zoom;
cent_x= (rw->zoomofs[0] + R.rectx/2)*rw->zoom;
cent_y= (rw->zoomofs[1] + R.recty/2)*rw->zoom;
disprect_r[0][0]= w/2 - cent_x;
disprect_r[0][1]= h/2 - cent_y;
disprect_r[1][0]= disprect_r[0][0] + display_w;
disprect_r[1][1]= disprect_r[0][1] + display_h;
}
/**
* Project window coordinate to image pixel coordinate.
* Returns true if resulting coordinate is within image.
*/
static int renderwin_win_to_image_co(RenderWin *rw, int winco[2], int imgco_r[2])
{
float disprect[2][2];
renderwin_get_disprect(rw, disprect);
imgco_r[0]= (int) ((winco[0]-disprect[0][0])/rw->zoom);
imgco_r[1]= (int) ((winco[1]-disprect[0][1])/rw->zoom);
2002-10-12 11:37:38 +00:00
return (imgco_r[0]>=0 && imgco_r[1]>=0 && imgco_r[0]<R.rectx && imgco_r[1]<R.recty);
}
/**
* Project window coordinates to normalized device coordinates
* Returns true if resulting coordinate is within window.
*/
static int renderwin_win_to_ndc(RenderWin *rw, int win_co[2], float ndc_r[2])
{
int w, h;
window_get_size(rw->win, &w, &h);
Biiig commit! Thanks to 2-3 weeks of cvs freeze... Render: - New; support for dual CPU render (SDL thread) Currently only works with alternating scanlines, but gives excellent performance. For both normal render as unified implemented. Note the "mutex" locks on z-transp buffer render and imbuf loads. - This has been made possible by major cleanups in render code, especially getting rid of globals (example Tin Tr Tg Tb Ta for textures) or struct OSA or using Materials or Texture data to write to. - Made normal render fully 4x32 floats too, and removed all old optimizes with chars or shorts. - Made normal render and unified render use same code for sky and halo render, giving equal (and better) results for halo render. Old render now also uses PostProcess options (brightness, mul, gamma) - Added option ("FBuf") in F10 Output Panel, this keeps a 4x32 bits buffer after render. Using PostProcess menu you will note an immediate re- display of image too (32 bits RGBA) - Added "Hue" and "Saturation" sliders to PostProcess options - Render module is still not having a "nice" API, but amount of dependencies went down a lot. Next todo: remove abusive "previewrender" code. The last main global in Render (struct Render) now can be re-used for fully controlling a render, to allow multiple "instances" of render to open. - Renderwindow now displays a smal bar on top with the stats, and keeps the stats after render too. Including "spare" page support. Not only easier visible that way, but also to remove the awkward code that was drawing stats in the Info header (extreme slow on some ATIs too) - Cleaned up blendef.h and BKE_utildefines.h, these two had overlapping defines. - I might have forgotten stuff... and will write a nice doc on the architecture!
2004-12-27 19:28:52 +00:00
h-= RW_HEADERY;
2002-10-12 11:37:38 +00:00
ndc_r[0]= ((float)(win_co[0]*2)/(w-1) - 1.0);
ndc_r[1]= ((float)(win_co[1]*2)/(h-1) - 1.0);
2002-10-12 11:37:38 +00:00
return (fabs(ndc_r[0])<=1.0 && fabs(ndc_r[1])<=1.0);
}
static void renderwin_set_infotext(RenderWin *rw, char *info_text)
{
if (rw->info_text) MEM_freeN(rw->info_text);
rw->info_text= info_text?BLI_strdup(info_text):NULL;
}
static void renderwin_reset_view(RenderWin *rw)
{
int w, h, rectx, recty;
if (rw->info_text) renderwin_set_infotext(rw, NULL);
/* now calculate a zoom for when image is larger than window */
window_get_size(rw->win, &w, &h);
Biiig commit! Thanks to 2-3 weeks of cvs freeze... Render: - New; support for dual CPU render (SDL thread) Currently only works with alternating scanlines, but gives excellent performance. For both normal render as unified implemented. Note the "mutex" locks on z-transp buffer render and imbuf loads. - This has been made possible by major cleanups in render code, especially getting rid of globals (example Tin Tr Tg Tb Ta for textures) or struct OSA or using Materials or Texture data to write to. - Made normal render fully 4x32 floats too, and removed all old optimizes with chars or shorts. - Made normal render and unified render use same code for sky and halo render, giving equal (and better) results for halo render. Old render now also uses PostProcess options (brightness, mul, gamma) - Added option ("FBuf") in F10 Output Panel, this keeps a 4x32 bits buffer after render. Using PostProcess menu you will note an immediate re- display of image too (32 bits RGBA) - Added "Hue" and "Saturation" sliders to PostProcess options - Render module is still not having a "nice" API, but amount of dependencies went down a lot. Next todo: remove abusive "previewrender" code. The last main global in Render (struct Render) now can be re-used for fully controlling a render, to allow multiple "instances" of render to open. - Renderwindow now displays a smal bar on top with the stats, and keeps the stats after render too. Including "spare" page support. Not only easier visible that way, but also to remove the awkward code that was drawing stats in the Info header (extreme slow on some ATIs too) - Cleaned up blendef.h and BKE_utildefines.h, these two had overlapping defines. - I might have forgotten stuff... and will write a nice doc on the architecture!
2004-12-27 19:28:52 +00:00
h-= RW_HEADERY;
/* at this point the r.rectx/y values are not correct yet */
rectx= (G.scene->r.size*G.scene->r.xsch)/100;
recty= (G.scene->r.size*G.scene->r.ysch)/100;
if(rectx>w || recty>h) {
if(rectx-w > recty-h) rw->zoom= ((float)w)/((float)rectx);
else rw->zoom= ((float)h)/((float)recty);
}
else rw->zoom= 1.0;
rw->zoomofs[0]= rw->zoomofs[1]= 0;
renderwin_queue_redraw(rw);
}
Biiig commit! Thanks to 2-3 weeks of cvs freeze... Render: - New; support for dual CPU render (SDL thread) Currently only works with alternating scanlines, but gives excellent performance. For both normal render as unified implemented. Note the "mutex" locks on z-transp buffer render and imbuf loads. - This has been made possible by major cleanups in render code, especially getting rid of globals (example Tin Tr Tg Tb Ta for textures) or struct OSA or using Materials or Texture data to write to. - Made normal render fully 4x32 floats too, and removed all old optimizes with chars or shorts. - Made normal render and unified render use same code for sky and halo render, giving equal (and better) results for halo render. Old render now also uses PostProcess options (brightness, mul, gamma) - Added option ("FBuf") in F10 Output Panel, this keeps a 4x32 bits buffer after render. Using PostProcess menu you will note an immediate re- display of image too (32 bits RGBA) - Added "Hue" and "Saturation" sliders to PostProcess options - Render module is still not having a "nice" API, but amount of dependencies went down a lot. Next todo: remove abusive "previewrender" code. The last main global in Render (struct Render) now can be re-used for fully controlling a render, to allow multiple "instances" of render to open. - Renderwindow now displays a smal bar on top with the stats, and keeps the stats after render too. Including "spare" page support. Not only easier visible that way, but also to remove the awkward code that was drawing stats in the Info header (extreme slow on some ATIs too) - Cleaned up blendef.h and BKE_utildefines.h, these two had overlapping defines. - I might have forgotten stuff... and will write a nice doc on the architecture!
2004-12-27 19:28:52 +00:00
static void renderwin_draw_render_info(RenderWin *rw)
{
/* render text is added to top */
if(RW_HEADERY) {
float colf[3];
rcti rect;
window_get_size(rw->win, &rect.xmax, &rect.ymax);
rect.xmin= 0;
rect.ymin= rect.ymax-RW_HEADERY;
glEnable(GL_SCISSOR_TEST);
glaDefine2DArea(&rect);
/* clear header rect */
BIF_SetTheme(NULL); // sets view3d theme by default
BIF_GetThemeColor3fv(TH_HEADER, colf);
glClearColor(colf[0], colf[1], colf[2], 1.0);
glClear(GL_COLOR_BUFFER_BIT);
if(rw->render_text) {
BIF_ThemeColor(TH_TEXT);
glRasterPos2i(12, 5);
BMF_DrawString(G.fonts, rw->render_text);
}
}
}
2002-10-12 11:37:38 +00:00
static void renderwin_draw(RenderWin *rw, int just_clear)
{
float disprect[2][2];
int set_back_mainwindow;
2002-10-12 11:37:38 +00:00
rcti rect;
/* since renderwin uses callbacks (controlled by ghost) it can
mess up active window output with redraw events after a render.
this is patchy, still WIP */
set_back_mainwindow = (winlay_get_active_window() != rw->win);
window_make_active(rw->win);
2002-10-12 11:37:38 +00:00
rect.xmin= rect.ymin= 0;
window_get_size(rw->win, &rect.xmax, &rect.ymax);
Biiig commit! Thanks to 2-3 weeks of cvs freeze... Render: - New; support for dual CPU render (SDL thread) Currently only works with alternating scanlines, but gives excellent performance. For both normal render as unified implemented. Note the "mutex" locks on z-transp buffer render and imbuf loads. - This has been made possible by major cleanups in render code, especially getting rid of globals (example Tin Tr Tg Tb Ta for textures) or struct OSA or using Materials or Texture data to write to. - Made normal render fully 4x32 floats too, and removed all old optimizes with chars or shorts. - Made normal render and unified render use same code for sky and halo render, giving equal (and better) results for halo render. Old render now also uses PostProcess options (brightness, mul, gamma) - Added option ("FBuf") in F10 Output Panel, this keeps a 4x32 bits buffer after render. Using PostProcess menu you will note an immediate re- display of image too (32 bits RGBA) - Added "Hue" and "Saturation" sliders to PostProcess options - Render module is still not having a "nice" API, but amount of dependencies went down a lot. Next todo: remove abusive "previewrender" code. The last main global in Render (struct Render) now can be re-used for fully controlling a render, to allow multiple "instances" of render to open. - Renderwindow now displays a smal bar on top with the stats, and keeps the stats after render too. Including "spare" page support. Not only easier visible that way, but also to remove the awkward code that was drawing stats in the Info header (extreme slow on some ATIs too) - Cleaned up blendef.h and BKE_utildefines.h, these two had overlapping defines. - I might have forgotten stuff... and will write a nice doc on the architecture!
2004-12-27 19:28:52 +00:00
rect.ymax-= RW_HEADERY;
2002-10-12 11:37:38 +00:00
renderwin_get_disprect(rw, disprect);
Biiig commit! Thanks to 2-3 weeks of cvs freeze... Render: - New; support for dual CPU render (SDL thread) Currently only works with alternating scanlines, but gives excellent performance. For both normal render as unified implemented. Note the "mutex" locks on z-transp buffer render and imbuf loads. - This has been made possible by major cleanups in render code, especially getting rid of globals (example Tin Tr Tg Tb Ta for textures) or struct OSA or using Materials or Texture data to write to. - Made normal render fully 4x32 floats too, and removed all old optimizes with chars or shorts. - Made normal render and unified render use same code for sky and halo render, giving equal (and better) results for halo render. Old render now also uses PostProcess options (brightness, mul, gamma) - Added option ("FBuf") in F10 Output Panel, this keeps a 4x32 bits buffer after render. Using PostProcess menu you will note an immediate re- display of image too (32 bits RGBA) - Added "Hue" and "Saturation" sliders to PostProcess options - Render module is still not having a "nice" API, but amount of dependencies went down a lot. Next todo: remove abusive "previewrender" code. The last main global in Render (struct Render) now can be re-used for fully controlling a render, to allow multiple "instances" of render to open. - Renderwindow now displays a smal bar on top with the stats, and keeps the stats after render too. Including "spare" page support. Not only easier visible that way, but also to remove the awkward code that was drawing stats in the Info header (extreme slow on some ATIs too) - Cleaned up blendef.h and BKE_utildefines.h, these two had overlapping defines. - I might have forgotten stuff... and will write a nice doc on the architecture!
2004-12-27 19:28:52 +00:00
/* do this first, so window ends with correct scissor */
renderwin_draw_render_info(rw);
2002-10-12 11:37:38 +00:00
glEnable(GL_SCISSOR_TEST);
glaDefine2DArea(&rect);
glClearColor(.1875, .1875, .1875, 1.0);
glClear(GL_COLOR_BUFFER_BIT);
if (just_clear || !R.rectot) {
glColor3ub(0, 0, 0);
glRectfv(disprect[0], disprect[1]);
} else {
glPixelZoom(rw->zoom, rw->zoom);
if(rw->flags & RW_FLAGS_ALPHA) {
char *rect= (char *)R.rectot;
glColorMask(1, 0, 0, 0);
glaDrawPixelsSafe(disprect[0][0], disprect[0][1], R.rectx, R.recty, rect+3);
glColorMask(0, 1, 0, 0);
glaDrawPixelsSafe(disprect[0][0], disprect[0][1], R.rectx, R.recty, rect+2);
glColorMask(0, 0, 1, 0);
glaDrawPixelsSafe(disprect[0][0], disprect[0][1], R.rectx, R.recty, rect+1);
glColorMask(1, 1, 1, 1);
}
else {
glaDrawPixelsSafe(disprect[0][0], disprect[0][1], R.rectx, R.recty, R.rectot);
}
2002-10-12 11:37:38 +00:00
glPixelZoom(1.0, 1.0);
}
Biiig commit! Thanks to 2-3 weeks of cvs freeze... Render: - New; support for dual CPU render (SDL thread) Currently only works with alternating scanlines, but gives excellent performance. For both normal render as unified implemented. Note the "mutex" locks on z-transp buffer render and imbuf loads. - This has been made possible by major cleanups in render code, especially getting rid of globals (example Tin Tr Tg Tb Ta for textures) or struct OSA or using Materials or Texture data to write to. - Made normal render fully 4x32 floats too, and removed all old optimizes with chars or shorts. - Made normal render and unified render use same code for sky and halo render, giving equal (and better) results for halo render. Old render now also uses PostProcess options (brightness, mul, gamma) - Added option ("FBuf") in F10 Output Panel, this keeps a 4x32 bits buffer after render. Using PostProcess menu you will note an immediate re- display of image too (32 bits RGBA) - Added "Hue" and "Saturation" sliders to PostProcess options - Render module is still not having a "nice" API, but amount of dependencies went down a lot. Next todo: remove abusive "previewrender" code. The last main global in Render (struct Render) now can be re-used for fully controlling a render, to allow multiple "instances" of render to open. - Renderwindow now displays a smal bar on top with the stats, and keeps the stats after render too. Including "spare" page support. Not only easier visible that way, but also to remove the awkward code that was drawing stats in the Info header (extreme slow on some ATIs too) - Cleaned up blendef.h and BKE_utildefines.h, these two had overlapping defines. - I might have forgotten stuff... and will write a nice doc on the architecture!
2004-12-27 19:28:52 +00:00
/* info text is overlayed on bottom */
2002-10-12 11:37:38 +00:00
if (rw->info_text) {
float w;
glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_BLEND);
w=186.0*strlen(rw->info_text)/30;
glColor4f(.5,.5,.5,.25);
glRectf(0.0,0.0,w,30.0);
glDisable(GL_BLEND);
2002-10-12 11:37:38 +00:00
glColor3ub(255, 255, 255);
glRasterPos2i(10, 10);
BMF_DrawString(G.font, rw->info_text);
}
Biiig commit! Thanks to 2-3 weeks of cvs freeze... Render: - New; support for dual CPU render (SDL thread) Currently only works with alternating scanlines, but gives excellent performance. For both normal render as unified implemented. Note the "mutex" locks on z-transp buffer render and imbuf loads. - This has been made possible by major cleanups in render code, especially getting rid of globals (example Tin Tr Tg Tb Ta for textures) or struct OSA or using Materials or Texture data to write to. - Made normal render fully 4x32 floats too, and removed all old optimizes with chars or shorts. - Made normal render and unified render use same code for sky and halo render, giving equal (and better) results for halo render. Old render now also uses PostProcess options (brightness, mul, gamma) - Added option ("FBuf") in F10 Output Panel, this keeps a 4x32 bits buffer after render. Using PostProcess menu you will note an immediate re- display of image too (32 bits RGBA) - Added "Hue" and "Saturation" sliders to PostProcess options - Render module is still not having a "nice" API, but amount of dependencies went down a lot. Next todo: remove abusive "previewrender" code. The last main global in Render (struct Render) now can be re-used for fully controlling a render, to allow multiple "instances" of render to open. - Renderwindow now displays a smal bar on top with the stats, and keeps the stats after render too. Including "spare" page support. Not only easier visible that way, but also to remove the awkward code that was drawing stats in the Info header (extreme slow on some ATIs too) - Cleaned up blendef.h and BKE_utildefines.h, these two had overlapping defines. - I might have forgotten stuff... and will write a nice doc on the architecture!
2004-12-27 19:28:52 +00:00
2002-10-12 11:37:38 +00:00
window_swap_buffers(rw->win);
if (set_back_mainwindow) mainwindow_make_active();
2002-10-12 11:37:38 +00:00
}
/* ------ interactivity calls for RenderWin ------------- */
2002-10-12 11:37:38 +00:00
static void renderwin_mouse_moved(RenderWin *rw)
{
if (rw->flags & RW_FLAGS_PIXEL_EXAMINING) {
2002-10-12 11:37:38 +00:00
int imgco[2];
char buf[64];
if (R.rectot && renderwin_win_to_image_co(rw, rw->lmouse, imgco)) {
unsigned char *pxl= (char*) &R.rectot[R.rectx*imgco[1] + imgco[0]];
sprintf(buf, "R: %d, G: %d, B: %d, A: %d", pxl[0], pxl[1], pxl[2], pxl[3]);
renderwin_set_infotext(rw, buf);
renderwin_queue_redraw(rw);
} else {
renderwin_set_infotext(rw, NULL);
renderwin_queue_redraw(rw);
}
}
else if (rw->flags & RW_FLAGS_PANNING) {
2002-10-12 11:37:38 +00:00
int delta_x= rw->lmouse[0] - rw->pan_mouse_start[0];
int delta_y= rw->lmouse[1] - rw->pan_mouse_start[1];
rw->zoomofs[0]= rw->pan_ofs_start[0] - delta_x/rw->zoom;
rw->zoomofs[1]= rw->pan_ofs_start[1] - delta_y/rw->zoom;
rw->zoomofs[0]= CLAMPIS(rw->zoomofs[0], -R.rectx/2, R.rectx/2);
rw->zoomofs[1]= CLAMPIS(rw->zoomofs[1], -R.recty/2, R.recty/2);
renderwin_queue_redraw(rw);
}
else if (rw->flags & RW_FLAGS_OLDZOOM) {
2002-10-12 11:37:38 +00:00
float ndc[2];
int w, h;
window_get_size(rw->win, &w, &h);
Biiig commit! Thanks to 2-3 weeks of cvs freeze... Render: - New; support for dual CPU render (SDL thread) Currently only works with alternating scanlines, but gives excellent performance. For both normal render as unified implemented. Note the "mutex" locks on z-transp buffer render and imbuf loads. - This has been made possible by major cleanups in render code, especially getting rid of globals (example Tin Tr Tg Tb Ta for textures) or struct OSA or using Materials or Texture data to write to. - Made normal render fully 4x32 floats too, and removed all old optimizes with chars or shorts. - Made normal render and unified render use same code for sky and halo render, giving equal (and better) results for halo render. Old render now also uses PostProcess options (brightness, mul, gamma) - Added option ("FBuf") in F10 Output Panel, this keeps a 4x32 bits buffer after render. Using PostProcess menu you will note an immediate re- display of image too (32 bits RGBA) - Added "Hue" and "Saturation" sliders to PostProcess options - Render module is still not having a "nice" API, but amount of dependencies went down a lot. Next todo: remove abusive "previewrender" code. The last main global in Render (struct Render) now can be re-used for fully controlling a render, to allow multiple "instances" of render to open. - Renderwindow now displays a smal bar on top with the stats, and keeps the stats after render too. Including "spare" page support. Not only easier visible that way, but also to remove the awkward code that was drawing stats in the Info header (extreme slow on some ATIs too) - Cleaned up blendef.h and BKE_utildefines.h, these two had overlapping defines. - I might have forgotten stuff... and will write a nice doc on the architecture!
2004-12-27 19:28:52 +00:00
h-= RW_HEADERY;
2002-10-12 11:37:38 +00:00
renderwin_win_to_ndc(rw, rw->lmouse, ndc);
rw->zoomofs[0]= -0.5*ndc[0]*(w-R.rectx*rw->zoom)/rw->zoom;
rw->zoomofs[1]= -0.5*ndc[1]*(h-R.recty*rw->zoom)/rw->zoom;
renderwin_queue_redraw(rw);
}
}
static void renderwin_mousebut_changed(RenderWin *rw)
{
if (rw->mbut[0]) {
rw->flags|= RW_FLAGS_PIXEL_EXAMINING;
}
else if (rw->mbut[1]) {
2002-10-12 11:37:38 +00:00
rw->flags|= RW_FLAGS_PANNING;
rw->pan_mouse_start[0]= rw->lmouse[0];
rw->pan_mouse_start[1]= rw->lmouse[1];
rw->pan_ofs_start[0]= rw->zoomofs[0];
rw->pan_ofs_start[1]= rw->zoomofs[1];
}
else {
if (rw->flags & RW_FLAGS_PANNING) {
rw->flags &= ~RW_FLAGS_PANNING;
2002-10-12 11:37:38 +00:00
renderwin_queue_redraw(rw);
}
if (rw->flags & RW_FLAGS_PIXEL_EXAMINING) {
2002-10-12 11:37:38 +00:00
rw->flags&= ~RW_FLAGS_PIXEL_EXAMINING;
renderwin_set_infotext(rw, NULL);
renderwin_queue_redraw(rw);
}
}
}
/* handler for renderwin, passed on to Ghost */
2002-10-12 11:37:38 +00:00
static void renderwin_handler(Window *win, void *user_data, short evt, short val, char ascii)
{
RenderWin *rw= user_data;
Biiig commit! Thanks to 2-3 weeks of cvs freeze... Render: - New; support for dual CPU render (SDL thread) Currently only works with alternating scanlines, but gives excellent performance. For both normal render as unified implemented. Note the "mutex" locks on z-transp buffer render and imbuf loads. - This has been made possible by major cleanups in render code, especially getting rid of globals (example Tin Tr Tg Tb Ta for textures) or struct OSA or using Materials or Texture data to write to. - Made normal render fully 4x32 floats too, and removed all old optimizes with chars or shorts. - Made normal render and unified render use same code for sky and halo render, giving equal (and better) results for halo render. Old render now also uses PostProcess options (brightness, mul, gamma) - Added option ("FBuf") in F10 Output Panel, this keeps a 4x32 bits buffer after render. Using PostProcess menu you will note an immediate re- display of image too (32 bits RGBA) - Added "Hue" and "Saturation" sliders to PostProcess options - Render module is still not having a "nice" API, but amount of dependencies went down a lot. Next todo: remove abusive "previewrender" code. The last main global in Render (struct Render) now can be re-used for fully controlling a render, to allow multiple "instances" of render to open. - Renderwindow now displays a smal bar on top with the stats, and keeps the stats after render too. Including "spare" page support. Not only easier visible that way, but also to remove the awkward code that was drawing stats in the Info header (extreme slow on some ATIs too) - Cleaned up blendef.h and BKE_utildefines.h, these two had overlapping defines. - I might have forgotten stuff... and will write a nice doc on the architecture!
2004-12-27 19:28:52 +00:00
// added this for safety, while render it's just creating bezerk results
if(R.flag & R_RENDERING) {
if(evt==ESCKEY && val)
rw->flags|= RW_FLAGS_ESCAPE;
return;
}
2002-10-12 11:37:38 +00:00
if (evt==RESHAPE) {
renderwin_reshape(rw);
}
else if (evt==REDRAW) {
2002-10-12 11:37:38 +00:00
renderwin_draw(rw, 0);
}
else if (evt==WINCLOSE) {
BIF_close_render_display();
}
else if (evt==INPUTCHANGE) {
2002-10-12 11:37:38 +00:00
rw->active= val;
2002-10-12 11:37:38 +00:00
if (!val && (rw->flags&RW_FLAGS_OLDZOOM)) {
rw->flags&= ~RW_FLAGS_OLDZOOM;
renderwin_reset_view(rw);
}
}
else if (ELEM(evt, MOUSEX, MOUSEY)) {
2002-10-12 11:37:38 +00:00
rw->lmouse[evt==MOUSEY]= val;
renderwin_mouse_moved(rw);
}
else if (ELEM3(evt, LEFTMOUSE, MIDDLEMOUSE, RIGHTMOUSE)) {
2002-10-12 11:37:38 +00:00
int which= (evt==LEFTMOUSE)?0:(evt==MIDDLEMOUSE)?1:2;
rw->mbut[which]= val;
renderwin_mousebut_changed(rw);
}
else if (val) {
2002-10-12 11:37:38 +00:00
if (evt==ESCKEY) {
if (rw->flags&RW_FLAGS_OLDZOOM) {
rw->flags&= ~RW_FLAGS_OLDZOOM;
renderwin_reset_view(rw);
}
else {
2002-10-12 11:37:38 +00:00
rw->flags|= RW_FLAGS_ESCAPE;
mainwindow_raise();
mainwindow_make_active();
rw->active= 0;
2002-10-12 11:37:38 +00:00
}
}
else if( evt==AKEY) {
rw->flags ^= RW_FLAGS_ALPHA;
renderwin_queue_redraw(render_win);
}
else if (evt==JKEY) {
if(R.flag==0) BIF_swap_render_rects();
}
else if (evt==ZKEY) {
2002-10-12 11:37:38 +00:00
if (rw->flags&RW_FLAGS_OLDZOOM) {
rw->flags&= ~RW_FLAGS_OLDZOOM;
renderwin_reset_view(rw);
} else {
rw->zoom= 2.0;
rw->flags|= RW_FLAGS_OLDZOOM;
renderwin_mouse_moved(rw);
}
}
else if (evt==PADPLUSKEY) {
2002-10-12 11:37:38 +00:00
if (rw->zoom<15.9) {
if(rw->zoom>0.5 && rw->zoom<1.0) rw->zoom= 1.0;
else rw->zoom*= 2.0;
2002-10-12 11:37:38 +00:00
renderwin_queue_redraw(rw);
}
}
else if (evt==PADMINUS) {
2002-10-12 11:37:38 +00:00
if (rw->zoom>0.26) {
if(rw->zoom>1.0 && rw->zoom<2.0) rw->zoom= 1.0;
else rw->zoom*= 0.5;
2002-10-12 11:37:38 +00:00
renderwin_queue_redraw(rw);
}
}
else if (evt==PADENTER || evt==HOMEKEY) {
2002-10-12 11:37:38 +00:00
if (rw->flags&RW_FLAGS_OLDZOOM) {
rw->flags&= ~RW_FLAGS_OLDZOOM;
}
renderwin_reset_view(rw);
}
else if (evt==F3KEY) {
if(R.flag==0) {
mainwindow_raise();
mainwindow_make_active();
rw->active= 0;
areawinset(find_biggest_area()->win);
BIF_save_rendered_image();
}
}
else if (evt==F11KEY) {
2002-10-12 11:37:38 +00:00
BIF_toggle_render_display();
}
else if (evt==F12KEY) {
/* if it's rendering, this flag is set */
if(R.flag==0) BIF_do_render(0);
2002-10-12 11:37:38 +00:00
}
}
}
static char *renderwin_get_title(int doswap)
{
static int swap= 0;
char *title="";
swap+= doswap;
if(swap & 1) {
if (G.scene->r.renderer==R_YAFRAY) title = "YafRay:Render (spare)";
else title = "Blender:Render (spare)";
}
else {
if (G.scene->r.renderer==R_YAFRAY) title = "YafRay:Render";
else title = "Blender:Render";
}
return title;
}
2002-10-12 11:37:38 +00:00
/* opens window and allocs struct */
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;
char *title;
title= renderwin_get_title(0); /* 0 = no swap */
Biiig commit! Thanks to 2-3 weeks of cvs freeze... Render: - New; support for dual CPU render (SDL thread) Currently only works with alternating scanlines, but gives excellent performance. For both normal render as unified implemented. Note the "mutex" locks on z-transp buffer render and imbuf loads. - This has been made possible by major cleanups in render code, especially getting rid of globals (example Tin Tr Tg Tb Ta for textures) or struct OSA or using Materials or Texture data to write to. - Made normal render fully 4x32 floats too, and removed all old optimizes with chars or shorts. - Made normal render and unified render use same code for sky and halo render, giving equal (and better) results for halo render. Old render now also uses PostProcess options (brightness, mul, gamma) - Added option ("FBuf") in F10 Output Panel, this keeps a 4x32 bits buffer after render. Using PostProcess menu you will note an immediate re- display of image too (32 bits RGBA) - Added "Hue" and "Saturation" sliders to PostProcess options - Render module is still not having a "nice" API, but amount of dependencies went down a lot. Next todo: remove abusive "previewrender" code. The last main global in Render (struct Render) now can be re-used for fully controlling a render, to allow multiple "instances" of render to open. - Renderwindow now displays a smal bar on top with the stats, and keeps the stats after render too. Including "spare" page support. Not only easier visible that way, but also to remove the awkward code that was drawing stats in the Info header (extreme slow on some ATIs too) - Cleaned up blendef.h and BKE_utildefines.h, these two had overlapping defines. - I might have forgotten stuff... and will write a nice doc on the architecture!
2004-12-27 19:28:52 +00:00
win= window_open(title, winpos[0], winpos[1], winsize[0], winsize[1]+RW_HEADERY, 0);
render_win= renderwin_alloc(win);
/* Ghost calls handler */
window_set_handler(win, renderwin_handler, render_win);
winlay_process_events(0);
window_make_active(render_win->win);
winlay_process_events(0);
/* mywindow has to know about it too */
Biiig commit! Thanks to 2-3 weeks of cvs freeze... Render: - New; support for dual CPU render (SDL thread) Currently only works with alternating scanlines, but gives excellent performance. For both normal render as unified implemented. Note the "mutex" locks on z-transp buffer render and imbuf loads. - This has been made possible by major cleanups in render code, especially getting rid of globals (example Tin Tr Tg Tb Ta for textures) or struct OSA or using Materials or Texture data to write to. - Made normal render fully 4x32 floats too, and removed all old optimizes with chars or shorts. - Made normal render and unified render use same code for sky and halo render, giving equal (and better) results for halo render. Old render now also uses PostProcess options (brightness, mul, gamma) - Added option ("FBuf") in F10 Output Panel, this keeps a 4x32 bits buffer after render. Using PostProcess menu you will note an immediate re- display of image too (32 bits RGBA) - Added "Hue" and "Saturation" sliders to PostProcess options - Render module is still not having a "nice" API, but amount of dependencies went down a lot. Next todo: remove abusive "previewrender" code. The last main global in Render (struct Render) now can be re-used for fully controlling a render, to allow multiple "instances" of render to open. - Renderwindow now displays a smal bar on top with the stats, and keeps the stats after render too. Including "spare" page support. Not only easier visible that way, but also to remove the awkward code that was drawing stats in the Info header (extreme slow on some ATIs too) - Cleaned up blendef.h and BKE_utildefines.h, these two had overlapping defines. - I might have forgotten stuff... and will write a nice doc on the architecture!
2004-12-27 19:28:52 +00:00
mywindow_build_and_set_renderwin(winpos[0], winpos[1], winsize[0], winsize[1]+RW_HEADERY);
/* and we should be able to draw 3d in it */
init_gl_stuff();
renderwin_draw(render_win, 1);
renderwin_draw(render_win, 1);
}
/* -------------- callbacks for render loop: Window (RenderWin) ----------------------- */
2002-10-12 11:37:38 +00:00
/* calculations for window size and position */
2002-10-12 11:37:38 +00:00
void calc_renderwin_rectangle(int posmask, int renderpos_r[2], int rendersize_r[2])
{
int scr_w, scr_h, x, y, div= 0;
float ndc_x= 0.0, ndc_y= 0.0;
/* XXX, we temporarily hack the screen size and position so
* the window is always 60 pixels away from a side, really need
2002-10-12 11:37:38 +00:00
* a GHOST_GetMaxWindowBounds or so - zr
*/
winlay_get_screensize(&scr_w, &scr_h);
rendersize_r[0]= (G.scene->r.size*G.scene->r.xsch)/100;
rendersize_r[1]= (G.scene->r.size*G.scene->r.ysch)/100;
if(G.scene->r.mode & R_PANORAMA) {
rendersize_r[0]*= G.scene->r.xparts;
rendersize_r[1]*= G.scene->r.yparts;
}
/* increased size of clipping for OSX, should become an option instead */
rendersize_r[0]= CLAMPIS(rendersize_r[0], 100, scr_w-120);
rendersize_r[1]= CLAMPIS(rendersize_r[1], 100, scr_h-120);
2002-10-12 11:37:38 +00:00
for (y=-1; y<=1; y++) {
for (x=-1; x<=1; x++) {
if (posmask & (1<<((y+1)*3 + (x+1)))) {
ndc_x+= x;
ndc_y+= y;
div++;
}
}
}
if (div) {
ndc_x/= div;
ndc_y/= div;
}
renderpos_r[0]= 60 + (scr_w-90-rendersize_r[0])*(ndc_x*0.5 + 0.5);
renderpos_r[1]= 30 + (scr_h-90-rendersize_r[1])*(ndc_y*0.5 + 0.5);
2002-10-12 11:37:38 +00:00
}
/* init renderwin, alloc/open/resize */
2002-10-12 11:37:38 +00:00
static void renderwin_init_display_cb(void)
{
if (G.afbreek == 0) {
int rendersize[2], renderpos[2];
Biiig commit! Thanks to 2-3 weeks of cvs freeze... Render: - New; support for dual CPU render (SDL thread) Currently only works with alternating scanlines, but gives excellent performance. For both normal render as unified implemented. Note the "mutex" locks on z-transp buffer render and imbuf loads. - This has been made possible by major cleanups in render code, especially getting rid of globals (example Tin Tr Tg Tb Ta for textures) or struct OSA or using Materials or Texture data to write to. - Made normal render fully 4x32 floats too, and removed all old optimizes with chars or shorts. - Made normal render and unified render use same code for sky and halo render, giving equal (and better) results for halo render. Old render now also uses PostProcess options (brightness, mul, gamma) - Added option ("FBuf") in F10 Output Panel, this keeps a 4x32 bits buffer after render. Using PostProcess menu you will note an immediate re- display of image too (32 bits RGBA) - Added "Hue" and "Saturation" sliders to PostProcess options - Render module is still not having a "nice" API, but amount of dependencies went down a lot. Next todo: remove abusive "previewrender" code. The last main global in Render (struct Render) now can be re-used for fully controlling a render, to allow multiple "instances" of render to open. - Renderwindow now displays a smal bar on top with the stats, and keeps the stats after render too. Including "spare" page support. Not only easier visible that way, but also to remove the awkward code that was drawing stats in the Info header (extreme slow on some ATIs too) - Cleaned up blendef.h and BKE_utildefines.h, these two had overlapping defines. - I might have forgotten stuff... and will write a nice doc on the architecture!
2004-12-27 19:28:52 +00:00
calc_renderwin_rectangle(G.winpos, renderpos, rendersize);
2002-10-12 11:37:38 +00:00
if (!render_win) {
open_renderwin(renderpos, rendersize);
renderwin_reset_view(render_win); // incl. autozoom for large images
2002-10-12 11:37:38 +00:00
} else {
int win_x, win_y;
int win_w, win_h;
window_get_position(render_win->win, &win_x, &win_y);
window_get_size(render_win->win, &win_w, &win_h);
Biiig commit! Thanks to 2-3 weeks of cvs freeze... Render: - New; support for dual CPU render (SDL thread) Currently only works with alternating scanlines, but gives excellent performance. For both normal render as unified implemented. Note the "mutex" locks on z-transp buffer render and imbuf loads. - This has been made possible by major cleanups in render code, especially getting rid of globals (example Tin Tr Tg Tb Ta for textures) or struct OSA or using Materials or Texture data to write to. - Made normal render fully 4x32 floats too, and removed all old optimizes with chars or shorts. - Made normal render and unified render use same code for sky and halo render, giving equal (and better) results for halo render. Old render now also uses PostProcess options (brightness, mul, gamma) - Added option ("FBuf") in F10 Output Panel, this keeps a 4x32 bits buffer after render. Using PostProcess menu you will note an immediate re- display of image too (32 bits RGBA) - Added "Hue" and "Saturation" sliders to PostProcess options - Render module is still not having a "nice" API, but amount of dependencies went down a lot. Next todo: remove abusive "previewrender" code. The last main global in Render (struct Render) now can be re-used for fully controlling a render, to allow multiple "instances" of render to open. - Renderwindow now displays a smal bar on top with the stats, and keeps the stats after render too. Including "spare" page support. Not only easier visible that way, but also to remove the awkward code that was drawing stats in the Info header (extreme slow on some ATIs too) - Cleaned up blendef.h and BKE_utildefines.h, these two had overlapping defines. - I might have forgotten stuff... and will write a nice doc on the architecture!
2004-12-27 19:28:52 +00:00
win_h-= RW_HEADERY;
2002-10-12 11:37:38 +00:00
/* XXX, this is nasty and I guess bound to cause problems,
* but to ensure the window is at the user specified position
* and size we reopen the window all the time... we need
* a ghost _set_position to fix this -zr
*/
/* XXX, well... it is nasty yes, and reopens windows each time on
subsequent renders. Better rule is to make it reopen only only
size change, and use the preferred position only on open_renderwin
cases (ton)
*/
if(rendersize[0]!= win_w || rendersize[1]!= win_h) {
BIF_close_render_display();
open_renderwin(renderpos, rendersize);
}
else {
window_raise(render_win->win);
window_make_active(render_win->win);
mywinset(2); // to assign scissor/viewport again in mywindow.c. is hackish yes
}
2002-10-12 11:37:38 +00:00
renderwin_reset_view(render_win);
render_win->flags&= ~RW_FLAGS_ESCAPE;
render_win->active= 1;
2002-10-12 11:37:38 +00:00
}
/* make sure we are in normal draw again */
render_win->flags &= ~RW_FLAGS_ALPHA;
2002-10-12 11:37:38 +00:00
}
}
/* callback for redraw render win */
2002-10-12 11:37:38 +00:00
static void renderwin_clear_display_cb(short ignore)
{
if (render_win) {
window_make_active(render_win->win);
renderwin_draw(render_win, 1);
}
}
/* XXX, this is not good, we do this without any regard to state
* ... better is to make this an optimization of a more clear
* implementation. the bug shows up when you do something like
* open the window, then draw part of the progress, then get
Biiig commit! Thanks to 2-3 weeks of cvs freeze... Render: - New; support for dual CPU render (SDL thread) Currently only works with alternating scanlines, but gives excellent performance. For both normal render as unified implemented. Note the "mutex" locks on z-transp buffer render and imbuf loads. - This has been made possible by major cleanups in render code, especially getting rid of globals (example Tin Tr Tg Tb Ta for textures) or struct OSA or using Materials or Texture data to write to. - Made normal render fully 4x32 floats too, and removed all old optimizes with chars or shorts. - Made normal render and unified render use same code for sky and halo render, giving equal (and better) results for halo render. Old render now also uses PostProcess options (brightness, mul, gamma) - Added option ("FBuf") in F10 Output Panel, this keeps a 4x32 bits buffer after render. Using PostProcess menu you will note an immediate re- display of image too (32 bits RGBA) - Added "Hue" and "Saturation" sliders to PostProcess options - Render module is still not having a "nice" API, but amount of dependencies went down a lot. Next todo: remove abusive "previewrender" code. The last main global in Render (struct Render) now can be re-used for fully controlling a render, to allow multiple "instances" of render to open. - Renderwindow now displays a smal bar on top with the stats, and keeps the stats after render too. Including "spare" page support. Not only easier visible that way, but also to remove the awkward code that was drawing stats in the Info header (extreme slow on some ATIs too) - Cleaned up blendef.h and BKE_utildefines.h, these two had overlapping defines. - I might have forgotten stuff... and will write a nice doc on the architecture!
2004-12-27 19:28:52 +00:00
* a redraw event. whatever can go wrong will. -zr
*
* Note: blocked queue handling while rendering to prevent that (ton)
*/
/* in render window; display a couple of scanlines of rendered image (see callback below) */
static void renderwin_progress(RenderWin *rw, int start_y, int nlines, int rect_w, int rect_h, unsigned char *rect)
{
float disprect[2][2];
rcti win_rct;
win_rct.xmin= win_rct.ymin= 0;
window_get_size(rw->win, &win_rct.xmax, &win_rct.ymax);
Biiig commit! Thanks to 2-3 weeks of cvs freeze... Render: - New; support for dual CPU render (SDL thread) Currently only works with alternating scanlines, but gives excellent performance. For both normal render as unified implemented. Note the "mutex" locks on z-transp buffer render and imbuf loads. - This has been made possible by major cleanups in render code, especially getting rid of globals (example Tin Tr Tg Tb Ta for textures) or struct OSA or using Materials or Texture data to write to. - Made normal render fully 4x32 floats too, and removed all old optimizes with chars or shorts. - Made normal render and unified render use same code for sky and halo render, giving equal (and better) results for halo render. Old render now also uses PostProcess options (brightness, mul, gamma) - Added option ("FBuf") in F10 Output Panel, this keeps a 4x32 bits buffer after render. Using PostProcess menu you will note an immediate re- display of image too (32 bits RGBA) - Added "Hue" and "Saturation" sliders to PostProcess options - Render module is still not having a "nice" API, but amount of dependencies went down a lot. Next todo: remove abusive "previewrender" code. The last main global in Render (struct Render) now can be re-used for fully controlling a render, to allow multiple "instances" of render to open. - Renderwindow now displays a smal bar on top with the stats, and keeps the stats after render too. Including "spare" page support. Not only easier visible that way, but also to remove the awkward code that was drawing stats in the Info header (extreme slow on some ATIs too) - Cleaned up blendef.h and BKE_utildefines.h, these two had overlapping defines. - I might have forgotten stuff... and will write a nice doc on the architecture!
2004-12-27 19:28:52 +00:00
win_rct.ymax-= RW_HEADERY;
renderwin_get_disprect(rw, disprect);
Biiig commit! Thanks to 2-3 weeks of cvs freeze... Render: - New; support for dual CPU render (SDL thread) Currently only works with alternating scanlines, but gives excellent performance. For both normal render as unified implemented. Note the "mutex" locks on z-transp buffer render and imbuf loads. - This has been made possible by major cleanups in render code, especially getting rid of globals (example Tin Tr Tg Tb Ta for textures) or struct OSA or using Materials or Texture data to write to. - Made normal render fully 4x32 floats too, and removed all old optimizes with chars or shorts. - Made normal render and unified render use same code for sky and halo render, giving equal (and better) results for halo render. Old render now also uses PostProcess options (brightness, mul, gamma) - Added option ("FBuf") in F10 Output Panel, this keeps a 4x32 bits buffer after render. Using PostProcess menu you will note an immediate re- display of image too (32 bits RGBA) - Added "Hue" and "Saturation" sliders to PostProcess options - Render module is still not having a "nice" API, but amount of dependencies went down a lot. Next todo: remove abusive "previewrender" code. The last main global in Render (struct Render) now can be re-used for fully controlling a render, to allow multiple "instances" of render to open. - Renderwindow now displays a smal bar on top with the stats, and keeps the stats after render too. Including "spare" page support. Not only easier visible that way, but also to remove the awkward code that was drawing stats in the Info header (extreme slow on some ATIs too) - Cleaned up blendef.h and BKE_utildefines.h, these two had overlapping defines. - I might have forgotten stuff... and will write a nice doc on the architecture!
2004-12-27 19:28:52 +00:00
/* for efficiency & speed; not drawing in Blender UI while rendering */
//window_make_active(rw->win);
glEnable(GL_SCISSOR_TEST);
glaDefine2DArea(&win_rct);
glDrawBuffer(GL_FRONT);
glPixelZoom(rw->zoom, rw->zoom);
glaDrawPixelsSafe(disprect[0][0], disprect[0][1] + start_y*rw->zoom, rect_w, nlines, &rect[start_y*rect_w*4]);
glPixelZoom(1.0, 1.0);
glFlush();
glDrawBuffer(GL_BACK);
}
/* in render window; display a couple of scanlines of rendered image */
static void renderwin_progress_display_cb(int y1, int y2, int w, int h, unsigned int *rect)
2002-10-12 11:37:38 +00:00
{
if (render_win) {
renderwin_progress(render_win, y1, y2-y1+1, w, h, (unsigned char*) rect);
}
}
/* -------------- callbacks for render loop: in View3D ----------------------- */
2002-10-12 11:37:38 +00:00
static View3D *render_view3d = NULL;
/* init Render view callback */
2002-10-12 11:37:38 +00:00
static void renderview_init_display_cb(void)
{
ScrArea *sa;
/* Choose the first view with a persp camera,
* if one doesn't exist we will get the first
* View3D window.
*/
render_view3d= NULL;
for (sa= G.curscreen->areabase.first; sa; sa= sa->next) {
if (sa->win && sa->spacetype==SPACE_VIEW3D) {
View3D *vd= sa->spacedata.first;
if (vd->persp==2 && vd->camera==G.scene->camera) {
render_view3d= vd;
break;
} else if (!render_view3d) {
render_view3d= vd;
}
}
}
}
/* in 3d view; display a couple of scanlines of rendered image */
2002-10-12 11:37:38 +00:00
static void renderview_progress_display_cb(int y1, int y2, int w, int h, unsigned int *rect)
{
if (render_view3d) {
View3D *v3d= render_view3d;
int nlines= y2-y1+1;
float sx, sy, facx, facy;
rcti win_rct, vb;
calc_viewborder(v3d, &vb);
facx= (float) (vb.xmax-vb.xmin)/R.rectx;
facy= (float) (vb.ymax-vb.ymin)/R.recty;
bwin_get_rect(v3d->area->win, &win_rct);
glaDefine2DArea(&win_rct);
glDrawBuffer(GL_FRONT);
sx= vb.xmin;
sy= vb.ymin + facy*y1;
glPixelZoom(facx, facy);
glaDrawPixelsSafe(sx, sy, w, nlines, rect+w*y1);
glPixelZoom(1.0, 1.0);
glFlush();
glDrawBuffer(GL_BACK);
v3d->flag |= V3D_DISPIMAGE;
v3d->area->win_swap= WIN_FRONT_OK;
2002-10-12 11:37:38 +00:00
}
}
Biiig commit! Thanks to 2-3 weeks of cvs freeze... Render: - New; support for dual CPU render (SDL thread) Currently only works with alternating scanlines, but gives excellent performance. For both normal render as unified implemented. Note the "mutex" locks on z-transp buffer render and imbuf loads. - This has been made possible by major cleanups in render code, especially getting rid of globals (example Tin Tr Tg Tb Ta for textures) or struct OSA or using Materials or Texture data to write to. - Made normal render fully 4x32 floats too, and removed all old optimizes with chars or shorts. - Made normal render and unified render use same code for sky and halo render, giving equal (and better) results for halo render. Old render now also uses PostProcess options (brightness, mul, gamma) - Added option ("FBuf") in F10 Output Panel, this keeps a 4x32 bits buffer after render. Using PostProcess menu you will note an immediate re- display of image too (32 bits RGBA) - Added "Hue" and "Saturation" sliders to PostProcess options - Render module is still not having a "nice" API, but amount of dependencies went down a lot. Next todo: remove abusive "previewrender" code. The last main global in Render (struct Render) now can be re-used for fully controlling a render, to allow multiple "instances" of render to open. - Renderwindow now displays a smal bar on top with the stats, and keeps the stats after render too. Including "spare" page support. Not only easier visible that way, but also to remove the awkward code that was drawing stats in the Info header (extreme slow on some ATIs too) - Cleaned up blendef.h and BKE_utildefines.h, these two had overlapping defines. - I might have forgotten stuff... and will write a nice doc on the architecture!
2004-12-27 19:28:52 +00:00
/* in 3d view; display stats of rendered image */
static void renderview_draw_render_info(char *str)
{
if (render_view3d) {
View3D *v3d= render_view3d;
rcti vb, win_rct;
calc_viewborder(v3d, &vb);
bwin_get_rect(v3d->area->win, &win_rct);
glaDefine2DArea(&win_rct);
glDrawBuffer(GL_FRONT);
/* clear header rect */
BIF_ThemeColor(TH_HEADER);
glRecti(vb.xmin, vb.ymax, vb.xmax, vb.ymax+RW_HEADERY);
if(str) {
BIF_ThemeColor(TH_TEXT);
glRasterPos2i(vb.xmin+12, vb.ymax+5);
BMF_DrawString(G.fonts, str);
}
glFlush();
glDrawBuffer(GL_BACK);
v3d->area->win_swap= WIN_FRONT_OK;
}
}
/* -------------- callbacks for render loop: interactivity ----------------------- */
2002-10-12 11:37:38 +00:00
Biiig commit! Thanks to 2-3 weeks of cvs freeze... Render: - New; support for dual CPU render (SDL thread) Currently only works with alternating scanlines, but gives excellent performance. For both normal render as unified implemented. Note the "mutex" locks on z-transp buffer render and imbuf loads. - This has been made possible by major cleanups in render code, especially getting rid of globals (example Tin Tr Tg Tb Ta for textures) or struct OSA or using Materials or Texture data to write to. - Made normal render fully 4x32 floats too, and removed all old optimizes with chars or shorts. - Made normal render and unified render use same code for sky and halo render, giving equal (and better) results for halo render. Old render now also uses PostProcess options (brightness, mul, gamma) - Added option ("FBuf") in F10 Output Panel, this keeps a 4x32 bits buffer after render. Using PostProcess menu you will note an immediate re- display of image too (32 bits RGBA) - Added "Hue" and "Saturation" sliders to PostProcess options - Render module is still not having a "nice" API, but amount of dependencies went down a lot. Next todo: remove abusive "previewrender" code. The last main global in Render (struct Render) now can be re-used for fully controlling a render, to allow multiple "instances" of render to open. - Renderwindow now displays a smal bar on top with the stats, and keeps the stats after render too. Including "spare" page support. Not only easier visible that way, but also to remove the awkward code that was drawing stats in the Info header (extreme slow on some ATIs too) - Cleaned up blendef.h and BKE_utildefines.h, these two had overlapping defines. - I might have forgotten stuff... and will write a nice doc on the architecture!
2004-12-27 19:28:52 +00:00
/* callback for print info in top header of renderwin */
/* time is only not zero on last call, we then don't update the other stats */
static void printrenderinfo_cb(double time, int sample)
2002-10-12 11:37:38 +00:00
{
extern int mem_in_use;
Biiig commit! Thanks to 2-3 weeks of cvs freeze... Render: - New; support for dual CPU render (SDL thread) Currently only works with alternating scanlines, but gives excellent performance. For both normal render as unified implemented. Note the "mutex" locks on z-transp buffer render and imbuf loads. - This has been made possible by major cleanups in render code, especially getting rid of globals (example Tin Tr Tg Tb Ta for textures) or struct OSA or using Materials or Texture data to write to. - Made normal render fully 4x32 floats too, and removed all old optimizes with chars or shorts. - Made normal render and unified render use same code for sky and halo render, giving equal (and better) results for halo render. Old render now also uses PostProcess options (brightness, mul, gamma) - Added option ("FBuf") in F10 Output Panel, this keeps a 4x32 bits buffer after render. Using PostProcess menu you will note an immediate re- display of image too (32 bits RGBA) - Added "Hue" and "Saturation" sliders to PostProcess options - Render module is still not having a "nice" API, but amount of dependencies went down a lot. Next todo: remove abusive "previewrender" code. The last main global in Render (struct Render) now can be re-used for fully controlling a render, to allow multiple "instances" of render to open. - Renderwindow now displays a smal bar on top with the stats, and keeps the stats after render too. Including "spare" page support. Not only easier visible that way, but also to remove the awkward code that was drawing stats in the Info header (extreme slow on some ATIs too) - Cleaned up blendef.h and BKE_utildefines.h, these two had overlapping defines. - I might have forgotten stuff... and will write a nice doc on the architecture!
2004-12-27 19:28:52 +00:00
static int totvert=0, totvlak=0, tothalo=0, totlamp=0;
static float megs_used_memory=0.0;
char str[300], *spos= str;
2002-10-12 11:37:38 +00:00
Biiig commit! Thanks to 2-3 weeks of cvs freeze... Render: - New; support for dual CPU render (SDL thread) Currently only works with alternating scanlines, but gives excellent performance. For both normal render as unified implemented. Note the "mutex" locks on z-transp buffer render and imbuf loads. - This has been made possible by major cleanups in render code, especially getting rid of globals (example Tin Tr Tg Tb Ta for textures) or struct OSA or using Materials or Texture data to write to. - Made normal render fully 4x32 floats too, and removed all old optimizes with chars or shorts. - Made normal render and unified render use same code for sky and halo render, giving equal (and better) results for halo render. Old render now also uses PostProcess options (brightness, mul, gamma) - Added option ("FBuf") in F10 Output Panel, this keeps a 4x32 bits buffer after render. Using PostProcess menu you will note an immediate re- display of image too (32 bits RGBA) - Added "Hue" and "Saturation" sliders to PostProcess options - Render module is still not having a "nice" API, but amount of dependencies went down a lot. Next todo: remove abusive "previewrender" code. The last main global in Render (struct Render) now can be re-used for fully controlling a render, to allow multiple "instances" of render to open. - Renderwindow now displays a smal bar on top with the stats, and keeps the stats after render too. Including "spare" page support. Not only easier visible that way, but also to remove the awkward code that was drawing stats in the Info header (extreme slow on some ATIs too) - Cleaned up blendef.h and BKE_utildefines.h, these two had overlapping defines. - I might have forgotten stuff... and will write a nice doc on the architecture!
2004-12-27 19:28:52 +00:00
if(time==0.0) {
megs_used_memory= mem_in_use/(1024.0*1024.0);
totvert= R.totvert;
totvlak= R.totvlak;
totlamp= R.totlamp;
tothalo= R.tothalo;
}
if(tothalo)
spos+= sprintf(spos, "Fra:%d Ve:%d Fa:%d Ha:%d La:%d Mem:%.2fM", (G.scene->r.cfra), totvert, totvlak, tothalo, totlamp, megs_used_memory);
else
spos+= sprintf(spos, "Fra:%d Ve:%d Fa:%d La:%d Mem:%.2fM", (G.scene->r.cfra), totvert, totvlak, totlamp, megs_used_memory);
if(time==0.0) {
if (R.r.mode & R_FIELDS) {
spos+= sprintf(spos, "Field %c ", (R.flag&R_SEC_FIELD)?'B':'A');
}
if (sample!=-1) {
spos+= sprintf(spos, "Sample: %d ", sample);
}
2002-10-12 11:37:38 +00:00
}
Biiig commit! Thanks to 2-3 weeks of cvs freeze... Render: - New; support for dual CPU render (SDL thread) Currently only works with alternating scanlines, but gives excellent performance. For both normal render as unified implemented. Note the "mutex" locks on z-transp buffer render and imbuf loads. - This has been made possible by major cleanups in render code, especially getting rid of globals (example Tin Tr Tg Tb Ta for textures) or struct OSA or using Materials or Texture data to write to. - Made normal render fully 4x32 floats too, and removed all old optimizes with chars or shorts. - Made normal render and unified render use same code for sky and halo render, giving equal (and better) results for halo render. Old render now also uses PostProcess options (brightness, mul, gamma) - Added option ("FBuf") in F10 Output Panel, this keeps a 4x32 bits buffer after render. Using PostProcess menu you will note an immediate re- display of image too (32 bits RGBA) - Added "Hue" and "Saturation" sliders to PostProcess options - Render module is still not having a "nice" API, but amount of dependencies went down a lot. Next todo: remove abusive "previewrender" code. The last main global in Render (struct Render) now can be re-used for fully controlling a render, to allow multiple "instances" of render to open. - Renderwindow now displays a smal bar on top with the stats, and keeps the stats after render too. Including "spare" page support. Not only easier visible that way, but also to remove the awkward code that was drawing stats in the Info header (extreme slow on some ATIs too) - Cleaned up blendef.h and BKE_utildefines.h, these two had overlapping defines. - I might have forgotten stuff... and will write a nice doc on the architecture!
2004-12-27 19:28:52 +00:00
else {
extern char info_time_str[32]; // header_info.c
timestr(time, info_time_str);
spos+= sprintf(spos, " Time:%s ", info_time_str);
2002-10-12 11:37:38 +00:00
}
Biiig commit! Thanks to 2-3 weeks of cvs freeze... Render: - New; support for dual CPU render (SDL thread) Currently only works with alternating scanlines, but gives excellent performance. For both normal render as unified implemented. Note the "mutex" locks on z-transp buffer render and imbuf loads. - This has been made possible by major cleanups in render code, especially getting rid of globals (example Tin Tr Tg Tb Ta for textures) or struct OSA or using Materials or Texture data to write to. - Made normal render fully 4x32 floats too, and removed all old optimizes with chars or shorts. - Made normal render and unified render use same code for sky and halo render, giving equal (and better) results for halo render. Old render now also uses PostProcess options (brightness, mul, gamma) - Added option ("FBuf") in F10 Output Panel, this keeps a 4x32 bits buffer after render. Using PostProcess menu you will note an immediate re- display of image too (32 bits RGBA) - Added "Hue" and "Saturation" sliders to PostProcess options - Render module is still not having a "nice" API, but amount of dependencies went down a lot. Next todo: remove abusive "previewrender" code. The last main global in Render (struct Render) now can be re-used for fully controlling a render, to allow multiple "instances" of render to open. - Renderwindow now displays a smal bar on top with the stats, and keeps the stats after render too. Including "spare" page support. Not only easier visible that way, but also to remove the awkward code that was drawing stats in the Info header (extreme slow on some ATIs too) - Cleaned up blendef.h and BKE_utildefines.h, these two had overlapping defines. - I might have forgotten stuff... and will write a nice doc on the architecture!
2004-12-27 19:28:52 +00:00
if(render_win) {
if(render_win->render_text) MEM_freeN(render_win->render_text);
render_win->render_text= BLI_strdup(str);
glDrawBuffer(GL_FRONT);
renderwin_draw_render_info(render_win);
glFlush();
glDrawBuffer(GL_BACK);
}
else renderview_draw_render_info(str);
2002-10-12 11:37:38 +00:00
}
/* -------------- callback system to allow ESC from rendering ----------------------- */
/* POSIX & WIN32: this function is called all the time, and should not use cpu or resources */
static int test_break(void)
{
if(G.afbreek==2) { /* code for testing queue */
G.afbreek= 0;
blender_test_break(); /* tests blender interface */
if (G.afbreek==0 && render_win) { /* tests window */
winlay_process_events(0);
// render_win can be closed in winlay_process_events()
if (render_win == 0 || (render_win->flags & RW_FLAGS_ESCAPE)) {
G.afbreek= 1;
}
}
}
if(G.afbreek==1) return 1;
else return 0;
}
#ifdef _WIN32
/* we use the multimedia time here */
static UINT uRenderTimerId;
void CALLBACK interruptESC(UINT uID, UINT uMsg, DWORD dwUser, DWORD dw1, DWORD dw2)
{
if(G.afbreek==0) G.afbreek= 2; /* code for read queue */
}
2003-06-13 13:54:08 +00:00
/* WIN32: init SetTimer callback */
static void init_test_break_callback()
{
timeBeginPeriod(50);
uRenderTimerId = timeSetEvent(250, 1, interruptESC, 0, TIME_PERIODIC);
}
2003-06-13 13:54:08 +00:00
/* WIN32: stop SetTimer callback */
static void end_test_break_callback()
{
timeEndPeriod(50);
timeKillEvent(uRenderTimerId);
}
#else
/* all other OS's support signal(SIGVTALRM) */
2003-06-13 13:54:08 +00:00
/* POSIX: this function goes in the signal() callback */
static void interruptESC(int sig)
{
if(G.afbreek==0) G.afbreek= 2; /* code for read queue */
/* call again, timer was reset */
signal(SIGVTALRM, interruptESC);
}
2003-06-13 13:54:08 +00:00
/* POSIX: initialize timer and signal */
static void init_test_break_callback()
{
struct itimerval tmevalue;
tmevalue.it_interval.tv_sec = 0;
tmevalue.it_interval.tv_usec = 250000;
/* wanneer de eerste ? */
tmevalue.it_value.tv_sec = 0;
tmevalue.it_value.tv_usec = 10000;
signal(SIGVTALRM, interruptESC);
setitimer(ITIMER_VIRTUAL, &tmevalue, 0);
}
2003-06-13 13:54:08 +00:00
/* POSIX: stop timer and callback */
static void end_test_break_callback()
{
struct itimerval tmevalue;
tmevalue.it_value.tv_sec = 0;
tmevalue.it_value.tv_usec = 0;
setitimer(ITIMER_VIRTUAL, &tmevalue, 0);
signal(SIGVTALRM, SIG_IGN);
}
#endif
/* -------------- callbacks for render loop: init & run! ----------------------- */
/* - initialize displays
- both opengl render as blender render
- set callbacks
- cleanup
*/
2002-10-12 11:37:38 +00:00
static void do_render(View3D *ogl_render_view3d, int anim, int force_dispwin)
2002-10-12 11:37:38 +00:00
{
/* we set this flag to prevent renderwindow queue to execute another render */
R.flag= R_RENDERING;
Biiig commit! Thanks to 2-3 weeks of cvs freeze... Render: - New; support for dual CPU render (SDL thread) Currently only works with alternating scanlines, but gives excellent performance. For both normal render as unified implemented. Note the "mutex" locks on z-transp buffer render and imbuf loads. - This has been made possible by major cleanups in render code, especially getting rid of globals (example Tin Tr Tg Tb Ta for textures) or struct OSA or using Materials or Texture data to write to. - Made normal render fully 4x32 floats too, and removed all old optimizes with chars or shorts. - Made normal render and unified render use same code for sky and halo render, giving equal (and better) results for halo render. Old render now also uses PostProcess options (brightness, mul, gamma) - Added option ("FBuf") in F10 Output Panel, this keeps a 4x32 bits buffer after render. Using PostProcess menu you will note an immediate re- display of image too (32 bits RGBA) - Added "Hue" and "Saturation" sliders to PostProcess options - Render module is still not having a "nice" API, but amount of dependencies went down a lot. Next todo: remove abusive "previewrender" code. The last main global in Render (struct Render) now can be re-used for fully controlling a render, to allow multiple "instances" of render to open. - Renderwindow now displays a smal bar on top with the stats, and keeps the stats after render too. Including "spare" page support. Not only easier visible that way, but also to remove the awkward code that was drawing stats in the Info header (extreme slow on some ATIs too) - Cleaned up blendef.h and BKE_utildefines.h, these two had overlapping defines. - I might have forgotten stuff... and will write a nice doc on the architecture!
2004-12-27 19:28:52 +00:00
if (G.displaymode == R_DISPLAYWIN || force_dispwin) {
2002-10-12 11:37:38 +00:00
RE_set_initrenderdisplay_callback(NULL);
RE_set_clearrenderdisplay_callback(renderwin_clear_display_cb);
2002-10-12 11:37:38 +00:00
RE_set_renderdisplay_callback(renderwin_progress_display_cb);
renderwin_init_display_cb();
}
else {
2002-10-12 11:37:38 +00:00
BIF_close_render_display();
RE_set_initrenderdisplay_callback(renderview_init_display_cb);
RE_set_clearrenderdisplay_callback(NULL);
2002-10-12 11:37:38 +00:00
RE_set_renderdisplay_callback(renderview_progress_display_cb);
}
init_test_break_callback();
RE_set_test_break_callback(test_break);
2002-10-12 11:37:38 +00:00
RE_set_timecursor_callback(set_timecursor);
RE_set_printrenderinfo_callback(printrenderinfo_cb);
if (render_win) {
window_set_cursor(render_win->win, CURSOR_WAIT);
// when opening new window... not cross platform identical behaviour, so
// for now call it each time
// if(ogl_render_view3d) init_gl_stuff();
}
2002-10-12 11:37:38 +00:00
waitcursor(1);
G.afbreek= 0;
if(G.obedit && !(G.scene->r.scemode & R_OGL)) {
exit_editmode(0); /* 0 = no free data */
2002-10-12 11:37:38 +00:00
}
if(anim) {
RE_animrender(ogl_render_view3d);
}
else {
RE_initrender(ogl_render_view3d);
}
Commit message and the brunt of the code courtesy of intrr, apologies for the size of this; Finally, the Sequencer audio support and global audio/animation sync stuff! (See http://intrr.org/blender/audiosequencer.html) Stuff that has been done: ./source/blender/blenloader/intern/writefile.c ./source/blender/blenloader/intern/readfile.c Added code to make it handle sounds used by audio strips, and to convert Scene data from older (<2.28) versions to init Scene global audio settings (Scene->audio) to defaults. ./source/blender/include/BSE_seqaudio.h ./source/blender/src/seqaudio.c The main audio routines that start/stop/scrub the audio stream at a certain frame position, provide the frame reference for the current stream position, mix the audio, convert the audio, mixdown the audio into a file. ./source/blender/makesdna/DNA_sound_types.h Introduced new variables in the bSound struct to accomodate the sample data after converted to the scene's global mixing format (stream, streamlen). Also added a new flag SOUND_FLAGS_SEQUENCE that gets set if the Sound belongs to a sequence strip. ./source/blender/makesdna/DNA_scene_types.h Added AudioData struct, which holds scene-global audio settings. ./source/blender/makesdna/DNA_sequence_types.h Added support for audio strips. Some variables to hold Panning/Attenuation information, position information, reference to the sample, and some flags. ./source/blender/makesdna/DNA_userdef_types.h ./source/blender/src/usiblender.c Added a "Mixing buffer size" userpref. Made the versions stuff initialize it to a default for versions <2.28. ./source/blender/makesdna/DNA_space_types.h ./source/blender/src/filesel.c Added a Cyan dot to .WAV files. Any other suggestions on a better color? :) ./source/blender/src/editsound.c Changes (fixes) to the WAV file loader, re-enabled some gameengine code that is needed for dealing with bSounds and bSamples. ./source/blender/src/editipo.c ./source/blender/src/drawseq.c ./source/blender/src/editnla.c ./source/blender/src/space.c ./source/blender/src/drawview.c ./source/blender/src/renderwin.c ./source/blender/src/headerbuttons.c - Created two different wrappers for update_for_newframe(), one which scrubs the audio, one which doesn't. - Replaced some of the occurences of update_for_newframe() with update_for_newframe_muted(), which doesn't scrub the audio. - In drawview.c: Changed the synchronization scheme to get the current audio position from the audio engine, and use that as a reference for setting CFRA. Implements a/v sync and framedrop. - In editipo.c: Changed handling of Fac IPOs to be usable for audio strips as volume envelopes. - In space.c: Added the mixing buffer size Userpref, enabled audio scrubbing (update_for_newframe()) for moving the sequence editor framebar. ./source/blender/src/editseq.c Added support for audio strips and a default directory for WAV files which gets saved from the last Shift-A operation. ./source/blender/src/buttons.c Added Scene-global audio sequencer settings in Sound buttons. ./source/blender/src/sequence.c Various stuff that deals with handling audio strips differently than usual strips.
2003-07-13 20:16:56 +00:00
if(anim) update_for_newframe_muted(); // only when anim, causes redraw event which frustrates dispview
2002-10-12 11:37:38 +00:00
if (render_win) window_set_cursor(render_win->win, CURSOR_STD);
free_filesel_spec(G.scene->r.pic);
G.afbreek= 0;
end_test_break_callback();
/* in dispiew it will destroy the image otherwise
window_make_active() raises window at osx and sends redraws */
Biiig commit! Thanks to 2-3 weeks of cvs freeze... Render: - New; support for dual CPU render (SDL thread) Currently only works with alternating scanlines, but gives excellent performance. For both normal render as unified implemented. Note the "mutex" locks on z-transp buffer render and imbuf loads. - This has been made possible by major cleanups in render code, especially getting rid of globals (example Tin Tr Tg Tb Ta for textures) or struct OSA or using Materials or Texture data to write to. - Made normal render fully 4x32 floats too, and removed all old optimizes with chars or shorts. - Made normal render and unified render use same code for sky and halo render, giving equal (and better) results for halo render. Old render now also uses PostProcess options (brightness, mul, gamma) - Added option ("FBuf") in F10 Output Panel, this keeps a 4x32 bits buffer after render. Using PostProcess menu you will note an immediate re- display of image too (32 bits RGBA) - Added "Hue" and "Saturation" sliders to PostProcess options - Render module is still not having a "nice" API, but amount of dependencies went down a lot. Next todo: remove abusive "previewrender" code. The last main global in Render (struct Render) now can be re-used for fully controlling a render, to allow multiple "instances" of render to open. - Renderwindow now displays a smal bar on top with the stats, and keeps the stats after render too. Including "spare" page support. Not only easier visible that way, but also to remove the awkward code that was drawing stats in the Info header (extreme slow on some ATIs too) - Cleaned up blendef.h and BKE_utildefines.h, these two had overlapping defines. - I might have forgotten stuff... and will write a nice doc on the architecture!
2004-12-27 19:28:52 +00:00
if(G.displaymode==R_DISPLAYWIN) {
mainwindow_make_active();
/* after an envmap creation... */
if(R.flag & R_REDRAW_PRV) {
BIF_all_preview_changed();
}
allqueue(REDRAWBUTSSCENE, 0); // visualize fbuf for example
}
R.flag= 0;
waitcursor(0); // waitcursor checks rendering R.flag...
2002-10-12 11:37:38 +00:00
}
/* finds area with a 'dispview' set */
2002-10-12 11:37:38 +00:00
static ScrArea *find_dispimage_v3d(void)
{
ScrArea *sa;
for (sa= G.curscreen->areabase.first; sa; sa= sa->next) {
if (sa->spacetype==SPACE_VIEW3D) {
View3D *vd= sa->spacedata.first;
if (vd->flag & V3D_DISPIMAGE)
return sa;
}
}
return NULL;
}
/* used for swapping with spare buffer, when images are different size */
2002-10-12 11:37:38 +00:00
static void scalefastrect(unsigned int *recto, unsigned int *rectn, int oldx, int oldy, int newx, int newy)
{
unsigned int *rect, *newrect;
int x, y;
int ofsx, ofsy, stepx, stepy;
stepx = (int)((65536.0 * (oldx - 1.0) / (newx - 1.0)) + 0.5);
stepy = (int)((65536.0 * (oldy - 1.0) / (newy - 1.0)) + 0.5);
ofsy = 32768;
newrect= rectn;
for (y = newy; y > 0 ; y--){
rect = recto;
rect += (ofsy >> 16) * oldx;
ofsy += stepy;
ofsx = 32768;
for (x = newx ; x>0 ; x--){
*newrect++ = rect[ofsx >> 16];
ofsx += stepx;
}
}
}
/* -------------- 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 */
void BIF_do_render(int anim)
{
/* if start render in 3d win, use layer from window (e.g also local view) */
if(curarea && curarea->spacetype==SPACE_VIEW3D) {
int lay= G.scene->lay;
if(G.vd->lay & 0xFF000000) // localview
G.scene->lay |= G.vd->lay;
else G.scene->lay= G.vd->lay;
do_render(NULL, anim, 0);
G.scene->lay= lay;
}
else do_render(NULL, anim, 0);
}
/* set up display, render the current area view in an image */
void BIF_do_ogl_render(View3D *ogl_render_view3d, int anim)
{
G.scene->r.scemode |= R_OGL;
do_render(ogl_render_view3d, anim, 1);
G.scene->r.scemode &= ~R_OGL;
}
Biiig commit! Thanks to 2-3 weeks of cvs freeze... Render: - New; support for dual CPU render (SDL thread) Currently only works with alternating scanlines, but gives excellent performance. For both normal render as unified implemented. Note the "mutex" locks on z-transp buffer render and imbuf loads. - This has been made possible by major cleanups in render code, especially getting rid of globals (example Tin Tr Tg Tb Ta for textures) or struct OSA or using Materials or Texture data to write to. - Made normal render fully 4x32 floats too, and removed all old optimizes with chars or shorts. - Made normal render and unified render use same code for sky and halo render, giving equal (and better) results for halo render. Old render now also uses PostProcess options (brightness, mul, gamma) - Added option ("FBuf") in F10 Output Panel, this keeps a 4x32 bits buffer after render. Using PostProcess menu you will note an immediate re- display of image too (32 bits RGBA) - Added "Hue" and "Saturation" sliders to PostProcess options - Render module is still not having a "nice" API, but amount of dependencies went down a lot. Next todo: remove abusive "previewrender" code. The last main global in Render (struct Render) now can be re-used for fully controlling a render, to allow multiple "instances" of render to open. - Renderwindow now displays a smal bar on top with the stats, and keeps the stats after render too. Including "spare" page support. Not only easier visible that way, but also to remove the awkward code that was drawing stats in the Info header (extreme slow on some ATIs too) - Cleaned up blendef.h and BKE_utildefines.h, these two had overlapping defines. - I might have forgotten stuff... and will write a nice doc on the architecture!
2004-12-27 19:28:52 +00:00
void BIF_redraw_render_rect(void)
{
/* redraw */
if (G.displaymode == R_DISPLAYWIN) {
// don't open render_win if rendering has been
// canceled or the render_win has been actively closed
if (render_win) {
renderwin_queue_redraw(render_win);
}
} else {
renderview_init_display_cb();
renderview_progress_display_cb(0, R.recty-1, R.rectx, R.recty, R.rectot);
}
}
2002-10-12 11:37:38 +00:00
void BIF_swap_render_rects(void)
{
unsigned int *temp;
if(R.rectspare==0) {
R.rectspare= (unsigned int *)MEM_callocN(sizeof(int)*R.rectx*R.recty, "rectot");
R.sparex= R.rectx;
R.sparey= R.recty;
}
else if(R.sparex!=R.rectx || R.sparey!=R.recty) {
temp= (unsigned int *)MEM_callocN(sizeof(int)*R.rectx*R.recty, "rectot");
scalefastrect(R.rectspare, temp, R.sparex, R.sparey, R.rectx, R.recty);
MEM_freeN(R.rectspare);
R.rectspare= temp;
R.sparex= R.rectx;
R.sparey= R.recty;
}
temp= R.rectot;
R.rectot= R.rectspare;
R.rectspare= temp;
Biiig commit! Thanks to 2-3 weeks of cvs freeze... Render: - New; support for dual CPU render (SDL thread) Currently only works with alternating scanlines, but gives excellent performance. For both normal render as unified implemented. Note the "mutex" locks on z-transp buffer render and imbuf loads. - This has been made possible by major cleanups in render code, especially getting rid of globals (example Tin Tr Tg Tb Ta for textures) or struct OSA or using Materials or Texture data to write to. - Made normal render fully 4x32 floats too, and removed all old optimizes with chars or shorts. - Made normal render and unified render use same code for sky and halo render, giving equal (and better) results for halo render. Old render now also uses PostProcess options (brightness, mul, gamma) - Added option ("FBuf") in F10 Output Panel, this keeps a 4x32 bits buffer after render. Using PostProcess menu you will note an immediate re- display of image too (32 bits RGBA) - Added "Hue" and "Saturation" sliders to PostProcess options - Render module is still not having a "nice" API, but amount of dependencies went down a lot. Next todo: remove abusive "previewrender" code. The last main global in Render (struct Render) now can be re-used for fully controlling a render, to allow multiple "instances" of render to open. - Renderwindow now displays a smal bar on top with the stats, and keeps the stats after render too. Including "spare" page support. Not only easier visible that way, but also to remove the awkward code that was drawing stats in the Info header (extreme slow on some ATIs too) - Cleaned up blendef.h and BKE_utildefines.h, these two had overlapping defines. - I might have forgotten stuff... and will write a nice doc on the architecture!
2004-12-27 19:28:52 +00:00
if (G.displaymode == R_DISPLAYWIN) {
if (render_win) {
Biiig commit! Thanks to 2-3 weeks of cvs freeze... Render: - New; support for dual CPU render (SDL thread) Currently only works with alternating scanlines, but gives excellent performance. For both normal render as unified implemented. Note the "mutex" locks on z-transp buffer render and imbuf loads. - This has been made possible by major cleanups in render code, especially getting rid of globals (example Tin Tr Tg Tb Ta for textures) or struct OSA or using Materials or Texture data to write to. - Made normal render fully 4x32 floats too, and removed all old optimizes with chars or shorts. - Made normal render and unified render use same code for sky and halo render, giving equal (and better) results for halo render. Old render now also uses PostProcess options (brightness, mul, gamma) - Added option ("FBuf") in F10 Output Panel, this keeps a 4x32 bits buffer after render. Using PostProcess menu you will note an immediate re- display of image too (32 bits RGBA) - Added "Hue" and "Saturation" sliders to PostProcess options - Render module is still not having a "nice" API, but amount of dependencies went down a lot. Next todo: remove abusive "previewrender" code. The last main global in Render (struct Render) now can be re-used for fully controlling a render, to allow multiple "instances" of render to open. - Renderwindow now displays a smal bar on top with the stats, and keeps the stats after render too. Including "spare" page support. Not only easier visible that way, but also to remove the awkward code that was drawing stats in the Info header (extreme slow on some ATIs too) - Cleaned up blendef.h and BKE_utildefines.h, these two had overlapping defines. - I might have forgotten stuff... and will write a nice doc on the architecture!
2004-12-27 19:28:52 +00:00
char *tmp= render_win->render_text_spare;
render_win->render_text_spare= render_win->render_text;
render_win->render_text= tmp;
window_set_title(render_win->win, renderwin_get_title(1));
Biiig commit! Thanks to 2-3 weeks of cvs freeze... Render: - New; support for dual CPU render (SDL thread) Currently only works with alternating scanlines, but gives excellent performance. For both normal render as unified implemented. Note the "mutex" locks on z-transp buffer render and imbuf loads. - This has been made possible by major cleanups in render code, especially getting rid of globals (example Tin Tr Tg Tb Ta for textures) or struct OSA or using Materials or Texture data to write to. - Made normal render fully 4x32 floats too, and removed all old optimizes with chars or shorts. - Made normal render and unified render use same code for sky and halo render, giving equal (and better) results for halo render. Old render now also uses PostProcess options (brightness, mul, gamma) - Added option ("FBuf") in F10 Output Panel, this keeps a 4x32 bits buffer after render. Using PostProcess menu you will note an immediate re- display of image too (32 bits RGBA) - Added "Hue" and "Saturation" sliders to PostProcess options - Render module is still not having a "nice" API, but amount of dependencies went down a lot. Next todo: remove abusive "previewrender" code. The last main global in Render (struct Render) now can be re-used for fully controlling a render, to allow multiple "instances" of render to open. - Renderwindow now displays a smal bar on top with the stats, and keeps the stats after render too. Including "spare" page support. Not only easier visible that way, but also to remove the awkward code that was drawing stats in the Info header (extreme slow on some ATIs too) - Cleaned up blendef.h and BKE_utildefines.h, these two had overlapping defines. - I might have forgotten stuff... and will write a nice doc on the architecture!
2004-12-27 19:28:52 +00:00
}
}
Biiig commit! Thanks to 2-3 weeks of cvs freeze... Render: - New; support for dual CPU render (SDL thread) Currently only works with alternating scanlines, but gives excellent performance. For both normal render as unified implemented. Note the "mutex" locks on z-transp buffer render and imbuf loads. - This has been made possible by major cleanups in render code, especially getting rid of globals (example Tin Tr Tg Tb Ta for textures) or struct OSA or using Materials or Texture data to write to. - Made normal render fully 4x32 floats too, and removed all old optimizes with chars or shorts. - Made normal render and unified render use same code for sky and halo render, giving equal (and better) results for halo render. Old render now also uses PostProcess options (brightness, mul, gamma) - Added option ("FBuf") in F10 Output Panel, this keeps a 4x32 bits buffer after render. Using PostProcess menu you will note an immediate re- display of image too (32 bits RGBA) - Added "Hue" and "Saturation" sliders to PostProcess options - Render module is still not having a "nice" API, but amount of dependencies went down a lot. Next todo: remove abusive "previewrender" code. The last main global in Render (struct Render) now can be re-used for fully controlling a render, to allow multiple "instances" of render to open. - Renderwindow now displays a smal bar on top with the stats, and keeps the stats after render too. Including "spare" page support. Not only easier visible that way, but also to remove the awkward code that was drawing stats in the Info header (extreme slow on some ATIs too) - Cleaned up blendef.h and BKE_utildefines.h, these two had overlapping defines. - I might have forgotten stuff... and will write a nice doc on the architecture!
2004-12-27 19:28:52 +00:00
/* redraw */
BIF_redraw_render_rect();
2002-10-12 11:37:38 +00:00
}
/* called from usiblender.c too, to free and close renderwin */
void BIF_close_render_display(void)
{
if (render_win) {
if (render_win->info_text) MEM_freeN(render_win->info_text);
Biiig commit! Thanks to 2-3 weeks of cvs freeze... Render: - New; support for dual CPU render (SDL thread) Currently only works with alternating scanlines, but gives excellent performance. For both normal render as unified implemented. Note the "mutex" locks on z-transp buffer render and imbuf loads. - This has been made possible by major cleanups in render code, especially getting rid of globals (example Tin Tr Tg Tb Ta for textures) or struct OSA or using Materials or Texture data to write to. - Made normal render fully 4x32 floats too, and removed all old optimizes with chars or shorts. - Made normal render and unified render use same code for sky and halo render, giving equal (and better) results for halo render. Old render now also uses PostProcess options (brightness, mul, gamma) - Added option ("FBuf") in F10 Output Panel, this keeps a 4x32 bits buffer after render. Using PostProcess menu you will note an immediate re- display of image too (32 bits RGBA) - Added "Hue" and "Saturation" sliders to PostProcess options - Render module is still not having a "nice" API, but amount of dependencies went down a lot. Next todo: remove abusive "previewrender" code. The last main global in Render (struct Render) now can be re-used for fully controlling a render, to allow multiple "instances" of render to open. - Renderwindow now displays a smal bar on top with the stats, and keeps the stats after render too. Including "spare" page support. Not only easier visible that way, but also to remove the awkward code that was drawing stats in the Info header (extreme slow on some ATIs too) - Cleaned up blendef.h and BKE_utildefines.h, these two had overlapping defines. - I might have forgotten stuff... and will write a nice doc on the architecture!
2004-12-27 19:28:52 +00:00
if (render_win->render_text) MEM_freeN(render_win->render_text);
if (render_win->render_text_spare) MEM_freeN(render_win->render_text_spare);
window_destroy(render_win->win); /* ghost close window */
MEM_freeN(render_win);
render_win= NULL;
}
}
/* typical with F11 key, show image or hide/close */
void BIF_toggle_render_display(void)
2002-10-12 11:37:38 +00:00
{
ScrArea *sa= find_dispimage_v3d();
if(R.rectot==NULL); // do nothing
Biiig commit! Thanks to 2-3 weeks of cvs freeze... Render: - New; support for dual CPU render (SDL thread) Currently only works with alternating scanlines, but gives excellent performance. For both normal render as unified implemented. Note the "mutex" locks on z-transp buffer render and imbuf loads. - This has been made possible by major cleanups in render code, especially getting rid of globals (example Tin Tr Tg Tb Ta for textures) or struct OSA or using Materials or Texture data to write to. - Made normal render fully 4x32 floats too, and removed all old optimizes with chars or shorts. - Made normal render and unified render use same code for sky and halo render, giving equal (and better) results for halo render. Old render now also uses PostProcess options (brightness, mul, gamma) - Added option ("FBuf") in F10 Output Panel, this keeps a 4x32 bits buffer after render. Using PostProcess menu you will note an immediate re- display of image too (32 bits RGBA) - Added "Hue" and "Saturation" sliders to PostProcess options - Render module is still not having a "nice" API, but amount of dependencies went down a lot. Next todo: remove abusive "previewrender" code. The last main global in Render (struct Render) now can be re-used for fully controlling a render, to allow multiple "instances" of render to open. - Renderwindow now displays a smal bar on top with the stats, and keeps the stats after render too. Including "spare" page support. Not only easier visible that way, but also to remove the awkward code that was drawing stats in the Info header (extreme slow on some ATIs too) - Cleaned up blendef.h and BKE_utildefines.h, these two had overlapping defines. - I might have forgotten stuff... and will write a nice doc on the architecture!
2004-12-27 19:28:52 +00:00
else if (render_win && G.displaymode==R_DISPLAYWIN) {
if(render_win->active) {
mainwindow_raise();
mainwindow_make_active();
render_win->active= 0;
}
else {
window_raise(render_win->win);
window_make_active(render_win->win);
render_win->active= 1;
2002-10-12 11:37:38 +00:00
}
}
Biiig commit! Thanks to 2-3 weeks of cvs freeze... Render: - New; support for dual CPU render (SDL thread) Currently only works with alternating scanlines, but gives excellent performance. For both normal render as unified implemented. Note the "mutex" locks on z-transp buffer render and imbuf loads. - This has been made possible by major cleanups in render code, especially getting rid of globals (example Tin Tr Tg Tb Ta for textures) or struct OSA or using Materials or Texture data to write to. - Made normal render fully 4x32 floats too, and removed all old optimizes with chars or shorts. - Made normal render and unified render use same code for sky and halo render, giving equal (and better) results for halo render. Old render now also uses PostProcess options (brightness, mul, gamma) - Added option ("FBuf") in F10 Output Panel, this keeps a 4x32 bits buffer after render. Using PostProcess menu you will note an immediate re- display of image too (32 bits RGBA) - Added "Hue" and "Saturation" sliders to PostProcess options - Render module is still not having a "nice" API, but amount of dependencies went down a lot. Next todo: remove abusive "previewrender" code. The last main global in Render (struct Render) now can be re-used for fully controlling a render, to allow multiple "instances" of render to open. - Renderwindow now displays a smal bar on top with the stats, and keeps the stats after render too. Including "spare" page support. Not only easier visible that way, but also to remove the awkward code that was drawing stats in the Info header (extreme slow on some ATIs too) - Cleaned up blendef.h and BKE_utildefines.h, these two had overlapping defines. - I might have forgotten stuff... and will write a nice doc on the architecture!
2004-12-27 19:28:52 +00:00
else if (sa && G.displaymode==R_DISPLAYVIEW) {
2002-10-12 11:37:38 +00:00
View3D *vd= sa->spacedata.first;
vd->flag &= ~V3D_DISPIMAGE;
scrarea_queue_winredraw(sa);
}
else {
Biiig commit! Thanks to 2-3 weeks of cvs freeze... Render: - New; support for dual CPU render (SDL thread) Currently only works with alternating scanlines, but gives excellent performance. For both normal render as unified implemented. Note the "mutex" locks on z-transp buffer render and imbuf loads. - This has been made possible by major cleanups in render code, especially getting rid of globals (example Tin Tr Tg Tb Ta for textures) or struct OSA or using Materials or Texture data to write to. - Made normal render fully 4x32 floats too, and removed all old optimizes with chars or shorts. - Made normal render and unified render use same code for sky and halo render, giving equal (and better) results for halo render. Old render now also uses PostProcess options (brightness, mul, gamma) - Added option ("FBuf") in F10 Output Panel, this keeps a 4x32 bits buffer after render. Using PostProcess menu you will note an immediate re- display of image too (32 bits RGBA) - Added "Hue" and "Saturation" sliders to PostProcess options - Render module is still not having a "nice" API, but amount of dependencies went down a lot. Next todo: remove abusive "previewrender" code. The last main global in Render (struct Render) now can be re-used for fully controlling a render, to allow multiple "instances" of render to open. - Renderwindow now displays a smal bar on top with the stats, and keeps the stats after render too. Including "spare" page support. Not only easier visible that way, but also to remove the awkward code that was drawing stats in the Info header (extreme slow on some ATIs too) - Cleaned up blendef.h and BKE_utildefines.h, these two had overlapping defines. - I might have forgotten stuff... and will write a nice doc on the architecture!
2004-12-27 19:28:52 +00:00
if (G.displaymode == R_DISPLAYWIN) {
2002-10-12 11:37:38 +00:00
renderwin_init_display_cb();
} else {
if (render_win) {
BIF_close_render_display();
}
renderview_init_display_cb();
renderview_progress_display_cb(0, R.recty-1, R.rectx, R.recty, R.rectot);
}
}
}
void BIF_renderwin_set_custom_cursor(unsigned char mask[16][2], unsigned char bitmap[16][2])
2002-10-12 11:37:38 +00:00
{
if (render_win) {
2003-11-12 13:32:11 +00:00
window_set_custom_cursor(render_win->win, mask, bitmap, 7, 7);
}
2002-10-12 11:37:38 +00:00
}