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 *****
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include <math.h>
|
|
|
|
|
|
|
|
|
|
#include "MEM_guardedalloc.h"
|
|
|
|
|
|
|
|
|
|
#include "DNA_vec_types.h"
|
2006-06-17 17:07:49 +00:00
|
|
|
#include "DNA_listBase.h"
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2005-03-08 19:31:16 +00:00
|
|
|
#include "BKE_utildefines.h"
|
|
|
|
|
|
2005-03-19 21:08:13 +00:00
|
|
|
#include "BLI_arithb.h"
|
2006-06-17 17:07:49 +00:00
|
|
|
#include "BLI_threads.h"
|
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
#include "BIF_gl.h"
|
|
|
|
|
#include "BIF_glutil.h"
|
|
|
|
|
|
|
|
|
|
/* Invert line handling */
|
|
|
|
|
|
|
|
|
|
#define glToggle(mode, onoff) (((onoff)?glEnable:glDisable)(mode))
|
|
|
|
|
|
2005-06-17 21:04:27 +00:00
|
|
|
void set_inverted_drawing(int enable)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
|
|
|
|
glLogicOp(enable?GL_INVERT:GL_COPY);
|
|
|
|
|
|
|
|
|
|
/* Use GL_BLEND_EQUATION_EXT on sgi (if we have it),
|
|
|
|
|
* apparently GL_COLOR_LOGIC_OP doesn't work on O2?
|
|
|
|
|
* Is this an sgi bug or our bug?
|
|
|
|
|
*/
|
|
|
|
|
#if defined(__sgi) && defined(GL_BLEND_EQUATION_EXT)
|
|
|
|
|
glBlendEquationEXT(enable?GL_LOGIC_OP:GL_FUNC_ADD_EXT);
|
|
|
|
|
glToggle(GL_BLEND, enable);
|
|
|
|
|
#else
|
|
|
|
|
glToggle(GL_COLOR_LOGIC_OP, enable);
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
glToggle(GL_DITHER, !enable);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void sdrawXORline(int x0, int y0, int x1, int y1)
|
|
|
|
|
{
|
|
|
|
|
if(x0==x1 && y0==y1) return;
|
|
|
|
|
|
|
|
|
|
set_inverted_drawing(1);
|
|
|
|
|
|
|
|
|
|
glBegin(GL_LINES);
|
|
|
|
|
glVertex2i(x0, y0);
|
|
|
|
|
glVertex2i(x1, y1);
|
|
|
|
|
glEnd();
|
|
|
|
|
|
|
|
|
|
set_inverted_drawing(0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void glutil_draw_front_xor_line(int x0, int y0, int x1, int y1)
|
|
|
|
|
{
|
2004-06-26 18:18:11 +00:00
|
|
|
glReadBuffer(GL_FRONT);
|
2002-10-12 11:37:38 +00:00
|
|
|
glDrawBuffer(GL_FRONT);
|
|
|
|
|
sdrawXORline(x0, y0, x1, y1);
|
2004-06-16 11:34:45 +00:00
|
|
|
glFlush();
|
2004-06-26 18:18:11 +00:00
|
|
|
glReadBuffer(GL_BACK);
|
2002-10-12 11:37:38 +00:00
|
|
|
glDrawBuffer(GL_BACK);
|
2004-06-26 18:18:11 +00:00
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void sdrawXORline4(int nr, int x0, int y0, int x1, int y1)
|
|
|
|
|
{
|
|
|
|
|
static short old[4][2][2];
|
|
|
|
|
static char flags[4]= {0, 0, 0, 0};
|
|
|
|
|
|
2003-04-30 13:22:26 +00:00
|
|
|
/* with builtin memory, max 4 lines */
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
|
set_inverted_drawing(1);
|
|
|
|
|
|
|
|
|
|
glBegin(GL_LINES);
|
|
|
|
|
if(nr== -1) { /* flush */
|
|
|
|
|
for (nr=0; nr<4; nr++) {
|
|
|
|
|
if (flags[nr]) {
|
|
|
|
|
glVertex2sv(old[nr][0]);
|
|
|
|
|
glVertex2sv(old[nr][1]);
|
|
|
|
|
flags[nr]= 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
if(nr>=0 && nr<4) {
|
|
|
|
|
if(flags[nr]) {
|
|
|
|
|
glVertex2sv(old[nr][0]);
|
|
|
|
|
glVertex2sv(old[nr][1]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
old[nr][0][0]= x0;
|
|
|
|
|
old[nr][0][1]= y0;
|
|
|
|
|
old[nr][1][0]= x1;
|
|
|
|
|
old[nr][1][1]= y1;
|
|
|
|
|
|
|
|
|
|
flags[nr]= 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
glVertex2i(x0, y0);
|
|
|
|
|
glVertex2i(x1, y1);
|
|
|
|
|
}
|
|
|
|
|
glEnd();
|
|
|
|
|
|
|
|
|
|
set_inverted_drawing(0);
|
|
|
|
|
}
|
|
|
|
|
|
2004-07-05 10:22:00 +00:00
|
|
|
void fdrawXORcirc(float xofs, float yofs, float rad)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
|
|
|
|
set_inverted_drawing(1);
|
|
|
|
|
|
|
|
|
|
glPushMatrix();
|
|
|
|
|
glTranslatef(xofs, yofs, 0.0);
|
2004-07-29 13:57:59 +00:00
|
|
|
glutil_draw_lined_arc(0.0, M_PI*2.0, rad, 20);
|
2002-10-12 11:37:38 +00:00
|
|
|
glPopMatrix();
|
|
|
|
|
|
|
|
|
|
set_inverted_drawing(0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void glutil_draw_filled_arc(float start, float angle, float radius, int nsegments) {
|
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
glBegin(GL_TRIANGLE_FAN);
|
|
|
|
|
glVertex2f(0.0, 0.0);
|
|
|
|
|
for (i=0; i<nsegments; i++) {
|
|
|
|
|
float t= (float) i/(nsegments-1);
|
|
|
|
|
float cur= start + t*angle;
|
|
|
|
|
|
|
|
|
|
glVertex2f(cos(cur)*radius, sin(cur)*radius);
|
|
|
|
|
}
|
|
|
|
|
glEnd();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void glutil_draw_lined_arc(float start, float angle, float radius, int nsegments) {
|
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
glBegin(GL_LINE_STRIP);
|
|
|
|
|
for (i=0; i<nsegments; i++) {
|
|
|
|
|
float t= (float) i/(nsegments-1);
|
|
|
|
|
float cur= start + t*angle;
|
|
|
|
|
|
|
|
|
|
glVertex2f(cos(cur)*radius, sin(cur)*radius);
|
|
|
|
|
}
|
|
|
|
|
glEnd();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int glaGetOneInteger(int param)
|
|
|
|
|
{
|
2004-07-05 10:22:00 +00:00
|
|
|
GLint i;
|
2002-10-12 11:37:38 +00:00
|
|
|
glGetIntegerv(param, &i);
|
|
|
|
|
return i;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
float glaGetOneFloat(int param)
|
|
|
|
|
{
|
2004-07-05 10:22:00 +00:00
|
|
|
GLfloat v;
|
2002-10-12 11:37:38 +00:00
|
|
|
glGetFloatv(param, &v);
|
|
|
|
|
return v;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void glaRasterPosSafe2f(float x, float y, float known_good_x, float known_good_y)
|
|
|
|
|
{
|
|
|
|
|
GLubyte dummy= 0;
|
|
|
|
|
|
|
|
|
|
/* As long as known good coordinates are correct
|
|
|
|
|
* this is guarenteed to generate an ok raster
|
|
|
|
|
* position (ignoring potential (real) overflow
|
|
|
|
|
* issues).
|
|
|
|
|
*/
|
|
|
|
|
glRasterPos2f(known_good_x, known_good_y);
|
|
|
|
|
|
|
|
|
|
/* Now shift the raster position to where we wanted
|
|
|
|
|
* it in the first place using the glBitmap trick.
|
|
|
|
|
*/
|
2003-05-02 10:44:14 +00:00
|
|
|
glBitmap(0, 0, 0, 0, x - known_good_x, y - known_good_y, &dummy);
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int get_cached_work_texture(int *w_r, int *h_r)
|
|
|
|
|
{
|
2004-07-05 10:22:00 +00:00
|
|
|
static GLint texid= -1;
|
2002-10-12 11:37:38 +00:00
|
|
|
static int tex_w= 256;
|
|
|
|
|
static int tex_h= 256;
|
|
|
|
|
|
|
|
|
|
if (texid==-1) {
|
|
|
|
|
GLint ltexid= glaGetOneInteger(GL_TEXTURE_2D);
|
|
|
|
|
unsigned char *tbuf;
|
|
|
|
|
|
|
|
|
|
glGenTextures(1, &texid);
|
|
|
|
|
|
|
|
|
|
glBindTexture(GL_TEXTURE_2D, texid);
|
|
|
|
|
|
Christmas coding work!
********* Node editor work:
- To enable Nodes for Materials, you have to set the "Use Nodes"
button, in the new Material buttons "Nodes" Panel or in header
of the Node editor. Doing this will disable Material-Layers.
- Nodes now execute materials ("shaders"), but still only using the
previewrender code.
- Nodes have (optional) previews for rendered images.
- Node headers allow to hide buttons and/or preview image
- Nodes can be dragged larger/smaller (right-bottom corner)
- Nodes can be hidden (minimized) with hotkey H
- CTRL+click on an Input Socket gives a popup with default values.
- Changing Material/Texture or Mix node will adjust Node title.
- Click-drag outside of a Node changes cursor to "Knife' and allows to
draw a rect where to cut Links.
- Added new node types RGBtoBW, Texture, In/Output, ColorRamp
- Material Nodes have options to ouput diffuse or specular, or to use
a negative normal. The input socket 'Normal' will force the material
to use that normal, otherwise it uses the normal from the Material
that has the node tree.
- When drawing a link between two not-matching sockets, Blender inserts
a converting node (now only for value/rgb combos)
- When drawing a link to an input socket that's already in use, the
old link will either disappear or flip to another unused socket.
- A click on a Material Node will activate it, and show all its settings
in the Material Buttons. Active Material Nodes draw the material icon
in red.
- A click on any node will show its options in the Node Panel in the
Material buttons.
- Multiple Output Nodes can be used, to sample contents of a tree, but
only one Output is the real one, which is indicated in a different
color and red material icon.
- Added ThemeColors for node types
- ALT+C will convert existing Material-Layers to Node... this currently
only adds the material/mix nodes and connects them. Dunno if this is
worth a lot of coding work to make perfect?
- Press C to call another "Solve order", which will show all possible
cyclic conflicts (if there are).
- Technical: nodes now use "Type" structs which define the
structure of nodes and in/output sockets. The Type structs store all
fixed info, callbacks, and allow to reconstruct saved Nodes to match
what is required by Blender.
- Defining (new) nodes now is as simple as filling in a fixed
Type struct, plus code some callbacks. A doc will be made!
- Node preview images are by default float
********* Icon drawing:
- Cleanup of how old icons were implemented in new system, making
them 16x16 too, correctly centered *and* scaled.
- Made drawing Icons use float coordinates
- Moved BIF_calcpreview_image() into interface_icons.c, renamed it
icon_from_image(). Removed a lot of unneeded Imbuf magic here! :)
- Skipped scaling and imbuf copying when icons are OK size
********* Preview render:
- Huge cleanup of code....
- renaming BIF_xxx calls that only were used internally
- BIF_previewrender() now accepts an argument for rendering method,
so it supports icons, buttonwindow previewrender and node editor
- Only a single BIF_preview_changed() call now exists, supporting all
signals as needed for buttos and node editor
********* More stuff:
- glutil.c, glaDrawPixelsSafe() and glaDrawPixelsTex() now accept format
argument for GL_FLOAT rects
- Made the ColorBand become a built-in button for interface.c
Was a load of cleanup work in buttons_shading.c...
- removed a load of unneeded glBlendFunc() calls
- Fixed bug in calculating text length for buttons (ancient!)
2005-12-28 15:42:51 +00:00
|
|
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
|
|
|
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
|
|
|
|
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
|
tbuf= MEM_callocN(tex_w*tex_h*4, "tbuf");
|
|
|
|
|
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, tex_w, tex_h, 0, GL_RGBA, GL_UNSIGNED_BYTE, tbuf);
|
|
|
|
|
MEM_freeN(tbuf);
|
|
|
|
|
|
|
|
|
|
glBindTexture(GL_TEXTURE_2D, ltexid);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
*w_r= tex_w;
|
|
|
|
|
*h_r= tex_h;
|
|
|
|
|
return texid;
|
|
|
|
|
}
|
|
|
|
|
|
Christmas coding work!
********* Node editor work:
- To enable Nodes for Materials, you have to set the "Use Nodes"
button, in the new Material buttons "Nodes" Panel or in header
of the Node editor. Doing this will disable Material-Layers.
- Nodes now execute materials ("shaders"), but still only using the
previewrender code.
- Nodes have (optional) previews for rendered images.
- Node headers allow to hide buttons and/or preview image
- Nodes can be dragged larger/smaller (right-bottom corner)
- Nodes can be hidden (minimized) with hotkey H
- CTRL+click on an Input Socket gives a popup with default values.
- Changing Material/Texture or Mix node will adjust Node title.
- Click-drag outside of a Node changes cursor to "Knife' and allows to
draw a rect where to cut Links.
- Added new node types RGBtoBW, Texture, In/Output, ColorRamp
- Material Nodes have options to ouput diffuse or specular, or to use
a negative normal. The input socket 'Normal' will force the material
to use that normal, otherwise it uses the normal from the Material
that has the node tree.
- When drawing a link between two not-matching sockets, Blender inserts
a converting node (now only for value/rgb combos)
- When drawing a link to an input socket that's already in use, the
old link will either disappear or flip to another unused socket.
- A click on a Material Node will activate it, and show all its settings
in the Material Buttons. Active Material Nodes draw the material icon
in red.
- A click on any node will show its options in the Node Panel in the
Material buttons.
- Multiple Output Nodes can be used, to sample contents of a tree, but
only one Output is the real one, which is indicated in a different
color and red material icon.
- Added ThemeColors for node types
- ALT+C will convert existing Material-Layers to Node... this currently
only adds the material/mix nodes and connects them. Dunno if this is
worth a lot of coding work to make perfect?
- Press C to call another "Solve order", which will show all possible
cyclic conflicts (if there are).
- Technical: nodes now use "Type" structs which define the
structure of nodes and in/output sockets. The Type structs store all
fixed info, callbacks, and allow to reconstruct saved Nodes to match
what is required by Blender.
- Defining (new) nodes now is as simple as filling in a fixed
Type struct, plus code some callbacks. A doc will be made!
- Node preview images are by default float
********* Icon drawing:
- Cleanup of how old icons were implemented in new system, making
them 16x16 too, correctly centered *and* scaled.
- Made drawing Icons use float coordinates
- Moved BIF_calcpreview_image() into interface_icons.c, renamed it
icon_from_image(). Removed a lot of unneeded Imbuf magic here! :)
- Skipped scaling and imbuf copying when icons are OK size
********* Preview render:
- Huge cleanup of code....
- renaming BIF_xxx calls that only were used internally
- BIF_previewrender() now accepts an argument for rendering method,
so it supports icons, buttonwindow previewrender and node editor
- Only a single BIF_preview_changed() call now exists, supporting all
signals as needed for buttos and node editor
********* More stuff:
- glutil.c, glaDrawPixelsSafe() and glaDrawPixelsTex() now accept format
argument for GL_FLOAT rects
- Made the ColorBand become a built-in button for interface.c
Was a load of cleanup work in buttons_shading.c...
- removed a load of unneeded glBlendFunc() calls
- Fixed bug in calculating text length for buttons (ancient!)
2005-12-28 15:42:51 +00:00
|
|
|
void glaDrawPixelsTex(float x, float y, int img_w, int img_h, int format, void *rect)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
|
|
|
|
unsigned char *uc_rect= (unsigned char*) rect;
|
Christmas coding work!
********* Node editor work:
- To enable Nodes for Materials, you have to set the "Use Nodes"
button, in the new Material buttons "Nodes" Panel or in header
of the Node editor. Doing this will disable Material-Layers.
- Nodes now execute materials ("shaders"), but still only using the
previewrender code.
- Nodes have (optional) previews for rendered images.
- Node headers allow to hide buttons and/or preview image
- Nodes can be dragged larger/smaller (right-bottom corner)
- Nodes can be hidden (minimized) with hotkey H
- CTRL+click on an Input Socket gives a popup with default values.
- Changing Material/Texture or Mix node will adjust Node title.
- Click-drag outside of a Node changes cursor to "Knife' and allows to
draw a rect where to cut Links.
- Added new node types RGBtoBW, Texture, In/Output, ColorRamp
- Material Nodes have options to ouput diffuse or specular, or to use
a negative normal. The input socket 'Normal' will force the material
to use that normal, otherwise it uses the normal from the Material
that has the node tree.
- When drawing a link between two not-matching sockets, Blender inserts
a converting node (now only for value/rgb combos)
- When drawing a link to an input socket that's already in use, the
old link will either disappear or flip to another unused socket.
- A click on a Material Node will activate it, and show all its settings
in the Material Buttons. Active Material Nodes draw the material icon
in red.
- A click on any node will show its options in the Node Panel in the
Material buttons.
- Multiple Output Nodes can be used, to sample contents of a tree, but
only one Output is the real one, which is indicated in a different
color and red material icon.
- Added ThemeColors for node types
- ALT+C will convert existing Material-Layers to Node... this currently
only adds the material/mix nodes and connects them. Dunno if this is
worth a lot of coding work to make perfect?
- Press C to call another "Solve order", which will show all possible
cyclic conflicts (if there are).
- Technical: nodes now use "Type" structs which define the
structure of nodes and in/output sockets. The Type structs store all
fixed info, callbacks, and allow to reconstruct saved Nodes to match
what is required by Blender.
- Defining (new) nodes now is as simple as filling in a fixed
Type struct, plus code some callbacks. A doc will be made!
- Node preview images are by default float
********* Icon drawing:
- Cleanup of how old icons were implemented in new system, making
them 16x16 too, correctly centered *and* scaled.
- Made drawing Icons use float coordinates
- Moved BIF_calcpreview_image() into interface_icons.c, renamed it
icon_from_image(). Removed a lot of unneeded Imbuf magic here! :)
- Skipped scaling and imbuf copying when icons are OK size
********* Preview render:
- Huge cleanup of code....
- renaming BIF_xxx calls that only were used internally
- BIF_previewrender() now accepts an argument for rendering method,
so it supports icons, buttonwindow previewrender and node editor
- Only a single BIF_preview_changed() call now exists, supporting all
signals as needed for buttos and node editor
********* More stuff:
- glutil.c, glaDrawPixelsSafe() and glaDrawPixelsTex() now accept format
argument for GL_FLOAT rects
- Made the ColorBand become a built-in button for interface.c
Was a load of cleanup work in buttons_shading.c...
- removed a load of unneeded glBlendFunc() calls
- Fixed bug in calculating text length for buttons (ancient!)
2005-12-28 15:42:51 +00:00
|
|
|
float *f_rect= (float *)rect;
|
2002-10-12 11:37:38 +00:00
|
|
|
float xzoom= glaGetOneFloat(GL_ZOOM_X), yzoom= glaGetOneFloat(GL_ZOOM_Y);
|
|
|
|
|
int ltexid= glaGetOneInteger(GL_TEXTURE_2D);
|
|
|
|
|
int lrowlength= glaGetOneInteger(GL_UNPACK_ROW_LENGTH);
|
|
|
|
|
int subpart_x, subpart_y, tex_w, tex_h;
|
|
|
|
|
int texid= get_cached_work_texture(&tex_w, &tex_h);
|
|
|
|
|
int nsubparts_x= (img_w+(tex_w-1))/tex_w;
|
|
|
|
|
int nsubparts_y= (img_h+(tex_h-1))/tex_h;
|
|
|
|
|
|
|
|
|
|
glPixelStorei(GL_UNPACK_ROW_LENGTH, img_w);
|
|
|
|
|
glBindTexture(GL_TEXTURE_2D, texid);
|
|
|
|
|
|
|
|
|
|
for (subpart_y=0; subpart_y<nsubparts_y; subpart_y++) {
|
|
|
|
|
for (subpart_x=0; subpart_x<nsubparts_x; subpart_x++) {
|
|
|
|
|
int subpart_w= (subpart_x==nsubparts_x-1)?(img_w-subpart_x*tex_w):tex_w;
|
|
|
|
|
int subpart_h= (subpart_y==nsubparts_y-1)?(img_h-subpart_y*tex_h):tex_h;
|
|
|
|
|
float rast_x= x+subpart_x*tex_w*xzoom;
|
|
|
|
|
float rast_y= y+subpart_y*tex_h*yzoom;
|
Christmas coding work!
********* Node editor work:
- To enable Nodes for Materials, you have to set the "Use Nodes"
button, in the new Material buttons "Nodes" Panel or in header
of the Node editor. Doing this will disable Material-Layers.
- Nodes now execute materials ("shaders"), but still only using the
previewrender code.
- Nodes have (optional) previews for rendered images.
- Node headers allow to hide buttons and/or preview image
- Nodes can be dragged larger/smaller (right-bottom corner)
- Nodes can be hidden (minimized) with hotkey H
- CTRL+click on an Input Socket gives a popup with default values.
- Changing Material/Texture or Mix node will adjust Node title.
- Click-drag outside of a Node changes cursor to "Knife' and allows to
draw a rect where to cut Links.
- Added new node types RGBtoBW, Texture, In/Output, ColorRamp
- Material Nodes have options to ouput diffuse or specular, or to use
a negative normal. The input socket 'Normal' will force the material
to use that normal, otherwise it uses the normal from the Material
that has the node tree.
- When drawing a link between two not-matching sockets, Blender inserts
a converting node (now only for value/rgb combos)
- When drawing a link to an input socket that's already in use, the
old link will either disappear or flip to another unused socket.
- A click on a Material Node will activate it, and show all its settings
in the Material Buttons. Active Material Nodes draw the material icon
in red.
- A click on any node will show its options in the Node Panel in the
Material buttons.
- Multiple Output Nodes can be used, to sample contents of a tree, but
only one Output is the real one, which is indicated in a different
color and red material icon.
- Added ThemeColors for node types
- ALT+C will convert existing Material-Layers to Node... this currently
only adds the material/mix nodes and connects them. Dunno if this is
worth a lot of coding work to make perfect?
- Press C to call another "Solve order", which will show all possible
cyclic conflicts (if there are).
- Technical: nodes now use "Type" structs which define the
structure of nodes and in/output sockets. The Type structs store all
fixed info, callbacks, and allow to reconstruct saved Nodes to match
what is required by Blender.
- Defining (new) nodes now is as simple as filling in a fixed
Type struct, plus code some callbacks. A doc will be made!
- Node preview images are by default float
********* Icon drawing:
- Cleanup of how old icons were implemented in new system, making
them 16x16 too, correctly centered *and* scaled.
- Made drawing Icons use float coordinates
- Moved BIF_calcpreview_image() into interface_icons.c, renamed it
icon_from_image(). Removed a lot of unneeded Imbuf magic here! :)
- Skipped scaling and imbuf copying when icons are OK size
********* Preview render:
- Huge cleanup of code....
- renaming BIF_xxx calls that only were used internally
- BIF_previewrender() now accepts an argument for rendering method,
so it supports icons, buttonwindow previewrender and node editor
- Only a single BIF_preview_changed() call now exists, supporting all
signals as needed for buttos and node editor
********* More stuff:
- glutil.c, glaDrawPixelsSafe() and glaDrawPixelsTex() now accept format
argument for GL_FLOAT rects
- Made the ColorBand become a built-in button for interface.c
Was a load of cleanup work in buttons_shading.c...
- removed a load of unneeded glBlendFunc() calls
- Fixed bug in calculating text length for buttons (ancient!)
2005-12-28 15:42:51 +00:00
|
|
|
|
|
|
|
|
if(format==GL_FLOAT)
|
|
|
|
|
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, subpart_w, subpart_h, GL_RGBA, GL_FLOAT, &f_rect[(subpart_y*tex_w)*img_w*4 + (subpart_x*tex_w)*4]);
|
|
|
|
|
else
|
|
|
|
|
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, subpart_w, subpart_h, GL_RGBA, GL_UNSIGNED_BYTE, &uc_rect[(subpart_y*tex_w)*img_w*4 + (subpart_x*tex_w)*4]);
|
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
glColor3ub(255, 255, 255);
|
|
|
|
|
glEnable(GL_TEXTURE_2D);
|
|
|
|
|
glBegin(GL_QUADS);
|
|
|
|
|
glTexCoord2f(0, 0);
|
|
|
|
|
glVertex2f(rast_x, rast_y);
|
|
|
|
|
|
|
|
|
|
glTexCoord2f((float) subpart_w/tex_w, 0);
|
|
|
|
|
glVertex2f(rast_x+subpart_w*xzoom, rast_y);
|
|
|
|
|
|
|
|
|
|
glTexCoord2f((float) subpart_w/tex_w, (float) subpart_h/tex_h);
|
|
|
|
|
glVertex2f(rast_x+subpart_w*xzoom, rast_y+subpart_h*yzoom);
|
|
|
|
|
|
|
|
|
|
glTexCoord2f(0, (float) subpart_h/tex_h);
|
|
|
|
|
glVertex2f(rast_x, rast_y+subpart_h*yzoom);
|
|
|
|
|
glEnd();
|
|
|
|
|
glDisable(GL_TEXTURE_2D);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
glBindTexture(GL_TEXTURE_2D, ltexid);
|
|
|
|
|
glPixelStorei(GL_UNPACK_ROW_LENGTH, lrowlength);
|
|
|
|
|
}
|
|
|
|
|
|
2006-06-17 17:07:49 +00:00
|
|
|
#define FTOCHAR(val) val<=0.0f?0: (val>=1.0f?255: (char)(255.0f*val))
|
|
|
|
|
void glaDrawPixelsSafe_to32(float fx, float fy, int img_w, int img_h, int row_w, float *rectf)
|
|
|
|
|
{
|
|
|
|
|
float *rf;
|
|
|
|
|
int x, y;
|
|
|
|
|
char *rect32, *rc;
|
|
|
|
|
|
|
|
|
|
/* copy imgw-imgh to a temporal 32 bits rect */
|
|
|
|
|
if(img_w<1 || img_h<1) return;
|
|
|
|
|
|
|
|
|
|
/* happens during threaded render... */
|
|
|
|
|
rc= rect32= MEM_mallocT(img_w*img_h*sizeof(int), "temp 32 bits");
|
|
|
|
|
|
|
|
|
|
for(y=0; y<img_h; y++) {
|
|
|
|
|
rf= rectf;
|
|
|
|
|
for(x=0; x<img_w; x++, rf+=4, rc+=4) {
|
|
|
|
|
rc[0]= FTOCHAR(rf[0]);
|
|
|
|
|
rc[1]= FTOCHAR(rf[1]);
|
|
|
|
|
rc[2]= FTOCHAR(rf[2]);
|
|
|
|
|
rc[3]= FTOCHAR(rf[3]);
|
|
|
|
|
}
|
|
|
|
|
rectf+= 4*row_w;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
glaDrawPixelsSafe(fx, fy, img_w, img_h, img_w, GL_RGBA, GL_UNSIGNED_BYTE, rect32);
|
|
|
|
|
|
|
|
|
|
MEM_freeT(rect32);
|
|
|
|
|
}
|
|
|
|
|
|
Giant commit!
A full detailed description of this will be done later... is several days
of work. Here's a summary:
Render:
- Full cleanup of render code, removing *all* globals and bad level calls
all over blender. Render module is now not called abusive anymore
- API-fied calls to rendering
- Full recode of internal render pipeline. Is now rendering tiles by
default, prepared for much smarter 'bucket' render later.
- Each thread now can render a full part
- Renders were tested with 4 threads, goes fine, apart from some lookup
tables in softshadow and AO still
- Rendering is prepared to do multiple layers and passes
- No single 32 bits trick in render code anymore, all 100% floats now.
Writing images/movies
- moved writing images to blender kernel (bye bye 'schrijfplaatje'!)
- made a new Movie handle system, also in kernel. This will enable much
easier use of movies in Blender
PreviewRender:
- Using new render API, previewrender (in buttons) now uses regular render
code to generate images.
- new datafile 'preview.blend.c' has the preview scenes in it
- previews get rendered in exact displayed size (1 pixel = 1 pixel)
3D Preview render
- new; press Pkey in 3d window, for a panel that continuously renders
(pkey is for games, i know... but we dont do that in orange now!)
- this render works nearly identical to buttons-preview render, so it stops
rendering on any event (mouse, keyboard, etc)
- on moving/scaling the panel, the render code doesn't recreate all geometry
- same for shifting/panning view
- all other operations (now) regenerate the full render database still.
- this is WIP... but big fun, especially for simple scenes!
Compositor
- Using same node system as now in use for shaders, you can composit images
- works pretty straightforward... needs much more options/tools and integration
with rendering still
- is not threaded yet, nor is so smart to only recalculate changes... will be
done soon!
- the "Render Result" node will get all layers/passes as output sockets
- The "Output" node renders to a builtin image, which you can view in the Image
window. (yes, output nodes to render-result, and to files, is on the list!)
The Bad News
- "Unified Render" is removed. It might come back in some stage, but this
system should be built from scratch. I can't really understand this code...
I expect it is not much needed, especially with advanced layer/passes
control
- Panorama render, Field render, Motion blur, is not coded yet... (I had to
recode every single feature in render, so...!)
- Lens Flare is also not back... needs total revision, might become composit
effect though (using zbuffer for visibility)
- Part render is gone! (well, thats obvious, its default now).
- The render window is only restored with limited functionality... I am going
to check first the option to render to a Image window, so Blender can become
a true single-window application. :)
For example, the 'Spare render buffer' (jkey) doesnt work.
- Render with border, now default creates a smaller image
- No zbuffers are written yet... on the todo!
- Scons files and MSVC will need work to get compiling again
OK... thats what I can quickly recall. Now go compiling!
2006-01-23 22:05:47 +00:00
|
|
|
void glaDrawPixelsSafe(float x, float y, int img_w, int img_h, int row_w, int format, int type, void *rect)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
2005-03-08 19:27:58 +00:00
|
|
|
float xzoom= glaGetOneFloat(GL_ZOOM_X);
|
|
|
|
|
float yzoom= glaGetOneFloat(GL_ZOOM_Y);
|
2005-01-08 13:15:43 +00:00
|
|
|
|
2005-03-08 19:27:58 +00:00
|
|
|
/* The pixel space coordinate of the intersection of
|
|
|
|
|
* the [zoomed] image with the origin.
|
|
|
|
|
*/
|
|
|
|
|
float ix= -x/xzoom;
|
|
|
|
|
float iy= -y/yzoom;
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2005-03-08 19:27:58 +00:00
|
|
|
/* The maximum pixel amounts the image can be cropped
|
|
|
|
|
* at the lower left without exceeding the origin.
|
|
|
|
|
*/
|
2005-03-08 19:31:16 +00:00
|
|
|
int off_x= floor(MAX2(ix, 0));
|
|
|
|
|
int off_y= floor(MAX2(iy, 0));
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2005-03-08 19:27:58 +00:00
|
|
|
/* The zoomed space coordinate of the raster position
|
|
|
|
|
* (starting at the lower left most unclipped pixel).
|
|
|
|
|
*/
|
|
|
|
|
float rast_x= x + off_x*xzoom;
|
|
|
|
|
float rast_y= y + off_y*yzoom;
|
|
|
|
|
|
|
|
|
|
GLfloat scissor[4];
|
|
|
|
|
int draw_w, draw_h;
|
|
|
|
|
|
|
|
|
|
/* Determine the smallest number of pixels we need to draw
|
|
|
|
|
* before the image would go off the upper right corner.
|
|
|
|
|
*
|
|
|
|
|
* It may seem this is just an optimization but some graphics
|
|
|
|
|
* cards (ATI) freak out if there is a large zoom factor and
|
|
|
|
|
* a large number of pixels off the screen (probably at some
|
|
|
|
|
* level the number of image pixels to draw is getting multiplied
|
|
|
|
|
* by the zoom and then clamped). Making sure we draw the
|
|
|
|
|
* fewest pixels possible keeps everyone mostly happy (still
|
|
|
|
|
* fails if we zoom in on one really huge pixel so that it
|
|
|
|
|
* covers the entire screen).
|
|
|
|
|
*/
|
|
|
|
|
glGetFloatv(GL_SCISSOR_BOX, scissor);
|
2005-03-08 19:31:16 +00:00
|
|
|
draw_w = MIN2(img_w-off_x, ceil((scissor[2]-rast_x)/xzoom));
|
|
|
|
|
draw_h = MIN2(img_h-off_y, ceil((scissor[3]-rast_y)/yzoom));
|
2005-03-08 19:27:58 +00:00
|
|
|
|
|
|
|
|
if (draw_w>0 && draw_h>0) {
|
|
|
|
|
int old_row_length = glaGetOneInteger(GL_UNPACK_ROW_LENGTH);
|
|
|
|
|
|
|
|
|
|
/* Don't use safe RasterPos (slower) if we can avoid it. */
|
|
|
|
|
if (rast_x>=0 && rast_y>=0) {
|
|
|
|
|
glRasterPos2f(rast_x, rast_y);
|
|
|
|
|
} else {
|
|
|
|
|
glaRasterPosSafe2f(rast_x, rast_y, 0, 0);
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
2005-03-08 19:27:58 +00:00
|
|
|
|
Giant commit!
A full detailed description of this will be done later... is several days
of work. Here's a summary:
Render:
- Full cleanup of render code, removing *all* globals and bad level calls
all over blender. Render module is now not called abusive anymore
- API-fied calls to rendering
- Full recode of internal render pipeline. Is now rendering tiles by
default, prepared for much smarter 'bucket' render later.
- Each thread now can render a full part
- Renders were tested with 4 threads, goes fine, apart from some lookup
tables in softshadow and AO still
- Rendering is prepared to do multiple layers and passes
- No single 32 bits trick in render code anymore, all 100% floats now.
Writing images/movies
- moved writing images to blender kernel (bye bye 'schrijfplaatje'!)
- made a new Movie handle system, also in kernel. This will enable much
easier use of movies in Blender
PreviewRender:
- Using new render API, previewrender (in buttons) now uses regular render
code to generate images.
- new datafile 'preview.blend.c' has the preview scenes in it
- previews get rendered in exact displayed size (1 pixel = 1 pixel)
3D Preview render
- new; press Pkey in 3d window, for a panel that continuously renders
(pkey is for games, i know... but we dont do that in orange now!)
- this render works nearly identical to buttons-preview render, so it stops
rendering on any event (mouse, keyboard, etc)
- on moving/scaling the panel, the render code doesn't recreate all geometry
- same for shifting/panning view
- all other operations (now) regenerate the full render database still.
- this is WIP... but big fun, especially for simple scenes!
Compositor
- Using same node system as now in use for shaders, you can composit images
- works pretty straightforward... needs much more options/tools and integration
with rendering still
- is not threaded yet, nor is so smart to only recalculate changes... will be
done soon!
- the "Render Result" node will get all layers/passes as output sockets
- The "Output" node renders to a builtin image, which you can view in the Image
window. (yes, output nodes to render-result, and to files, is on the list!)
The Bad News
- "Unified Render" is removed. It might come back in some stage, but this
system should be built from scratch. I can't really understand this code...
I expect it is not much needed, especially with advanced layer/passes
control
- Panorama render, Field render, Motion blur, is not coded yet... (I had to
recode every single feature in render, so...!)
- Lens Flare is also not back... needs total revision, might become composit
effect though (using zbuffer for visibility)
- Part render is gone! (well, thats obvious, its default now).
- The render window is only restored with limited functionality... I am going
to check first the option to render to a Image window, so Blender can become
a true single-window application. :)
For example, the 'Spare render buffer' (jkey) doesnt work.
- Render with border, now default creates a smaller image
- No zbuffers are written yet... on the todo!
- Scons files and MSVC will need work to get compiling again
OK... thats what I can quickly recall. Now go compiling!
2006-01-23 22:05:47 +00:00
|
|
|
glPixelStorei(GL_UNPACK_ROW_LENGTH, row_w);
|
2006-01-11 22:36:31 +00:00
|
|
|
if(format==GL_LUMINANCE || format==GL_RED) {
|
|
|
|
|
if(type==GL_FLOAT) {
|
|
|
|
|
float *f_rect= (float *)rect;
|
Giant commit!
A full detailed description of this will be done later... is several days
of work. Here's a summary:
Render:
- Full cleanup of render code, removing *all* globals and bad level calls
all over blender. Render module is now not called abusive anymore
- API-fied calls to rendering
- Full recode of internal render pipeline. Is now rendering tiles by
default, prepared for much smarter 'bucket' render later.
- Each thread now can render a full part
- Renders were tested with 4 threads, goes fine, apart from some lookup
tables in softshadow and AO still
- Rendering is prepared to do multiple layers and passes
- No single 32 bits trick in render code anymore, all 100% floats now.
Writing images/movies
- moved writing images to blender kernel (bye bye 'schrijfplaatje'!)
- made a new Movie handle system, also in kernel. This will enable much
easier use of movies in Blender
PreviewRender:
- Using new render API, previewrender (in buttons) now uses regular render
code to generate images.
- new datafile 'preview.blend.c' has the preview scenes in it
- previews get rendered in exact displayed size (1 pixel = 1 pixel)
3D Preview render
- new; press Pkey in 3d window, for a panel that continuously renders
(pkey is for games, i know... but we dont do that in orange now!)
- this render works nearly identical to buttons-preview render, so it stops
rendering on any event (mouse, keyboard, etc)
- on moving/scaling the panel, the render code doesn't recreate all geometry
- same for shifting/panning view
- all other operations (now) regenerate the full render database still.
- this is WIP... but big fun, especially for simple scenes!
Compositor
- Using same node system as now in use for shaders, you can composit images
- works pretty straightforward... needs much more options/tools and integration
with rendering still
- is not threaded yet, nor is so smart to only recalculate changes... will be
done soon!
- the "Render Result" node will get all layers/passes as output sockets
- The "Output" node renders to a builtin image, which you can view in the Image
window. (yes, output nodes to render-result, and to files, is on the list!)
The Bad News
- "Unified Render" is removed. It might come back in some stage, but this
system should be built from scratch. I can't really understand this code...
I expect it is not much needed, especially with advanced layer/passes
control
- Panorama render, Field render, Motion blur, is not coded yet... (I had to
recode every single feature in render, so...!)
- Lens Flare is also not back... needs total revision, might become composit
effect though (using zbuffer for visibility)
- Part render is gone! (well, thats obvious, its default now).
- The render window is only restored with limited functionality... I am going
to check first the option to render to a Image window, so Blender can become
a true single-window application. :)
For example, the 'Spare render buffer' (jkey) doesnt work.
- Render with border, now default creates a smaller image
- No zbuffers are written yet... on the todo!
- Scons files and MSVC will need work to get compiling again
OK... thats what I can quickly recall. Now go compiling!
2006-01-23 22:05:47 +00:00
|
|
|
glDrawPixels(draw_w, draw_h, format, type, f_rect + (off_y*row_w + off_x));
|
2006-01-11 22:36:31 +00:00
|
|
|
}
|
|
|
|
|
else if(type==GL_INT || type==GL_UNSIGNED_INT) {
|
|
|
|
|
int *i_rect= (int *)rect;
|
Giant commit!
A full detailed description of this will be done later... is several days
of work. Here's a summary:
Render:
- Full cleanup of render code, removing *all* globals and bad level calls
all over blender. Render module is now not called abusive anymore
- API-fied calls to rendering
- Full recode of internal render pipeline. Is now rendering tiles by
default, prepared for much smarter 'bucket' render later.
- Each thread now can render a full part
- Renders were tested with 4 threads, goes fine, apart from some lookup
tables in softshadow and AO still
- Rendering is prepared to do multiple layers and passes
- No single 32 bits trick in render code anymore, all 100% floats now.
Writing images/movies
- moved writing images to blender kernel (bye bye 'schrijfplaatje'!)
- made a new Movie handle system, also in kernel. This will enable much
easier use of movies in Blender
PreviewRender:
- Using new render API, previewrender (in buttons) now uses regular render
code to generate images.
- new datafile 'preview.blend.c' has the preview scenes in it
- previews get rendered in exact displayed size (1 pixel = 1 pixel)
3D Preview render
- new; press Pkey in 3d window, for a panel that continuously renders
(pkey is for games, i know... but we dont do that in orange now!)
- this render works nearly identical to buttons-preview render, so it stops
rendering on any event (mouse, keyboard, etc)
- on moving/scaling the panel, the render code doesn't recreate all geometry
- same for shifting/panning view
- all other operations (now) regenerate the full render database still.
- this is WIP... but big fun, especially for simple scenes!
Compositor
- Using same node system as now in use for shaders, you can composit images
- works pretty straightforward... needs much more options/tools and integration
with rendering still
- is not threaded yet, nor is so smart to only recalculate changes... will be
done soon!
- the "Render Result" node will get all layers/passes as output sockets
- The "Output" node renders to a builtin image, which you can view in the Image
window. (yes, output nodes to render-result, and to files, is on the list!)
The Bad News
- "Unified Render" is removed. It might come back in some stage, but this
system should be built from scratch. I can't really understand this code...
I expect it is not much needed, especially with advanced layer/passes
control
- Panorama render, Field render, Motion blur, is not coded yet... (I had to
recode every single feature in render, so...!)
- Lens Flare is also not back... needs total revision, might become composit
effect though (using zbuffer for visibility)
- Part render is gone! (well, thats obvious, its default now).
- The render window is only restored with limited functionality... I am going
to check first the option to render to a Image window, so Blender can become
a true single-window application. :)
For example, the 'Spare render buffer' (jkey) doesnt work.
- Render with border, now default creates a smaller image
- No zbuffers are written yet... on the todo!
- Scons files and MSVC will need work to get compiling again
OK... thats what I can quickly recall. Now go compiling!
2006-01-23 22:05:47 +00:00
|
|
|
glDrawPixels(draw_w, draw_h, format, type, i_rect + (off_y*row_w + off_x));
|
2006-01-11 22:36:31 +00:00
|
|
|
}
|
2006-01-11 14:20:35 +00:00
|
|
|
}
|
2006-01-11 22:36:31 +00:00
|
|
|
else { /* RGBA */
|
|
|
|
|
if(type==GL_FLOAT) {
|
|
|
|
|
float *f_rect= (float *)rect;
|
Giant commit!
A full detailed description of this will be done later... is several days
of work. Here's a summary:
Render:
- Full cleanup of render code, removing *all* globals and bad level calls
all over blender. Render module is now not called abusive anymore
- API-fied calls to rendering
- Full recode of internal render pipeline. Is now rendering tiles by
default, prepared for much smarter 'bucket' render later.
- Each thread now can render a full part
- Renders were tested with 4 threads, goes fine, apart from some lookup
tables in softshadow and AO still
- Rendering is prepared to do multiple layers and passes
- No single 32 bits trick in render code anymore, all 100% floats now.
Writing images/movies
- moved writing images to blender kernel (bye bye 'schrijfplaatje'!)
- made a new Movie handle system, also in kernel. This will enable much
easier use of movies in Blender
PreviewRender:
- Using new render API, previewrender (in buttons) now uses regular render
code to generate images.
- new datafile 'preview.blend.c' has the preview scenes in it
- previews get rendered in exact displayed size (1 pixel = 1 pixel)
3D Preview render
- new; press Pkey in 3d window, for a panel that continuously renders
(pkey is for games, i know... but we dont do that in orange now!)
- this render works nearly identical to buttons-preview render, so it stops
rendering on any event (mouse, keyboard, etc)
- on moving/scaling the panel, the render code doesn't recreate all geometry
- same for shifting/panning view
- all other operations (now) regenerate the full render database still.
- this is WIP... but big fun, especially for simple scenes!
Compositor
- Using same node system as now in use for shaders, you can composit images
- works pretty straightforward... needs much more options/tools and integration
with rendering still
- is not threaded yet, nor is so smart to only recalculate changes... will be
done soon!
- the "Render Result" node will get all layers/passes as output sockets
- The "Output" node renders to a builtin image, which you can view in the Image
window. (yes, output nodes to render-result, and to files, is on the list!)
The Bad News
- "Unified Render" is removed. It might come back in some stage, but this
system should be built from scratch. I can't really understand this code...
I expect it is not much needed, especially with advanced layer/passes
control
- Panorama render, Field render, Motion blur, is not coded yet... (I had to
recode every single feature in render, so...!)
- Lens Flare is also not back... needs total revision, might become composit
effect though (using zbuffer for visibility)
- Part render is gone! (well, thats obvious, its default now).
- The render window is only restored with limited functionality... I am going
to check first the option to render to a Image window, so Blender can become
a true single-window application. :)
For example, the 'Spare render buffer' (jkey) doesnt work.
- Render with border, now default creates a smaller image
- No zbuffers are written yet... on the todo!
- Scons files and MSVC will need work to get compiling again
OK... thats what I can quickly recall. Now go compiling!
2006-01-23 22:05:47 +00:00
|
|
|
glDrawPixels(draw_w, draw_h, format, type, f_rect + (off_y*row_w + off_x)*4);
|
2006-01-11 22:36:31 +00:00
|
|
|
}
|
|
|
|
|
else if(type==GL_UNSIGNED_BYTE) {
|
|
|
|
|
unsigned char *uc_rect= (unsigned char *) rect;
|
Giant commit!
A full detailed description of this will be done later... is several days
of work. Here's a summary:
Render:
- Full cleanup of render code, removing *all* globals and bad level calls
all over blender. Render module is now not called abusive anymore
- API-fied calls to rendering
- Full recode of internal render pipeline. Is now rendering tiles by
default, prepared for much smarter 'bucket' render later.
- Each thread now can render a full part
- Renders were tested with 4 threads, goes fine, apart from some lookup
tables in softshadow and AO still
- Rendering is prepared to do multiple layers and passes
- No single 32 bits trick in render code anymore, all 100% floats now.
Writing images/movies
- moved writing images to blender kernel (bye bye 'schrijfplaatje'!)
- made a new Movie handle system, also in kernel. This will enable much
easier use of movies in Blender
PreviewRender:
- Using new render API, previewrender (in buttons) now uses regular render
code to generate images.
- new datafile 'preview.blend.c' has the preview scenes in it
- previews get rendered in exact displayed size (1 pixel = 1 pixel)
3D Preview render
- new; press Pkey in 3d window, for a panel that continuously renders
(pkey is for games, i know... but we dont do that in orange now!)
- this render works nearly identical to buttons-preview render, so it stops
rendering on any event (mouse, keyboard, etc)
- on moving/scaling the panel, the render code doesn't recreate all geometry
- same for shifting/panning view
- all other operations (now) regenerate the full render database still.
- this is WIP... but big fun, especially for simple scenes!
Compositor
- Using same node system as now in use for shaders, you can composit images
- works pretty straightforward... needs much more options/tools and integration
with rendering still
- is not threaded yet, nor is so smart to only recalculate changes... will be
done soon!
- the "Render Result" node will get all layers/passes as output sockets
- The "Output" node renders to a builtin image, which you can view in the Image
window. (yes, output nodes to render-result, and to files, is on the list!)
The Bad News
- "Unified Render" is removed. It might come back in some stage, but this
system should be built from scratch. I can't really understand this code...
I expect it is not much needed, especially with advanced layer/passes
control
- Panorama render, Field render, Motion blur, is not coded yet... (I had to
recode every single feature in render, so...!)
- Lens Flare is also not back... needs total revision, might become composit
effect though (using zbuffer for visibility)
- Part render is gone! (well, thats obvious, its default now).
- The render window is only restored with limited functionality... I am going
to check first the option to render to a Image window, so Blender can become
a true single-window application. :)
For example, the 'Spare render buffer' (jkey) doesnt work.
- Render with border, now default creates a smaller image
- No zbuffers are written yet... on the todo!
- Scons files and MSVC will need work to get compiling again
OK... thats what I can quickly recall. Now go compiling!
2006-01-23 22:05:47 +00:00
|
|
|
glDrawPixels(draw_w, draw_h, format, type, uc_rect + (off_y*row_w + off_x)*4);
|
2006-01-11 22:36:31 +00:00
|
|
|
}
|
Christmas coding work!
********* Node editor work:
- To enable Nodes for Materials, you have to set the "Use Nodes"
button, in the new Material buttons "Nodes" Panel or in header
of the Node editor. Doing this will disable Material-Layers.
- Nodes now execute materials ("shaders"), but still only using the
previewrender code.
- Nodes have (optional) previews for rendered images.
- Node headers allow to hide buttons and/or preview image
- Nodes can be dragged larger/smaller (right-bottom corner)
- Nodes can be hidden (minimized) with hotkey H
- CTRL+click on an Input Socket gives a popup with default values.
- Changing Material/Texture or Mix node will adjust Node title.
- Click-drag outside of a Node changes cursor to "Knife' and allows to
draw a rect where to cut Links.
- Added new node types RGBtoBW, Texture, In/Output, ColorRamp
- Material Nodes have options to ouput diffuse or specular, or to use
a negative normal. The input socket 'Normal' will force the material
to use that normal, otherwise it uses the normal from the Material
that has the node tree.
- When drawing a link between two not-matching sockets, Blender inserts
a converting node (now only for value/rgb combos)
- When drawing a link to an input socket that's already in use, the
old link will either disappear or flip to another unused socket.
- A click on a Material Node will activate it, and show all its settings
in the Material Buttons. Active Material Nodes draw the material icon
in red.
- A click on any node will show its options in the Node Panel in the
Material buttons.
- Multiple Output Nodes can be used, to sample contents of a tree, but
only one Output is the real one, which is indicated in a different
color and red material icon.
- Added ThemeColors for node types
- ALT+C will convert existing Material-Layers to Node... this currently
only adds the material/mix nodes and connects them. Dunno if this is
worth a lot of coding work to make perfect?
- Press C to call another "Solve order", which will show all possible
cyclic conflicts (if there are).
- Technical: nodes now use "Type" structs which define the
structure of nodes and in/output sockets. The Type structs store all
fixed info, callbacks, and allow to reconstruct saved Nodes to match
what is required by Blender.
- Defining (new) nodes now is as simple as filling in a fixed
Type struct, plus code some callbacks. A doc will be made!
- Node preview images are by default float
********* Icon drawing:
- Cleanup of how old icons were implemented in new system, making
them 16x16 too, correctly centered *and* scaled.
- Made drawing Icons use float coordinates
- Moved BIF_calcpreview_image() into interface_icons.c, renamed it
icon_from_image(). Removed a lot of unneeded Imbuf magic here! :)
- Skipped scaling and imbuf copying when icons are OK size
********* Preview render:
- Huge cleanup of code....
- renaming BIF_xxx calls that only were used internally
- BIF_previewrender() now accepts an argument for rendering method,
so it supports icons, buttonwindow previewrender and node editor
- Only a single BIF_preview_changed() call now exists, supporting all
signals as needed for buttos and node editor
********* More stuff:
- glutil.c, glaDrawPixelsSafe() and glaDrawPixelsTex() now accept format
argument for GL_FLOAT rects
- Made the ColorBand become a built-in button for interface.c
Was a load of cleanup work in buttons_shading.c...
- removed a load of unneeded glBlendFunc() calls
- Fixed bug in calculating text length for buttons (ancient!)
2005-12-28 15:42:51 +00:00
|
|
|
}
|
|
|
|
|
|
2005-03-08 19:27:58 +00:00
|
|
|
glPixelStorei(GL_UNPACK_ROW_LENGTH, old_row_length);
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* 2D Drawing Assistance */
|
|
|
|
|
|
|
|
|
|
void glaDefine2DArea(rcti *screen_rect)
|
|
|
|
|
{
|
|
|
|
|
int sc_w= screen_rect->xmax - screen_rect->xmin;
|
|
|
|
|
int sc_h= screen_rect->ymax - screen_rect->ymin;
|
|
|
|
|
|
|
|
|
|
glViewport(screen_rect->xmin, screen_rect->ymin, sc_w, sc_h);
|
|
|
|
|
glScissor(screen_rect->xmin, screen_rect->ymin, sc_w, sc_h);
|
|
|
|
|
|
|
|
|
|
/* The 0.375 magic number is to shift the matrix so that
|
|
|
|
|
* both raster and vertex integer coordinates fall at pixel
|
|
|
|
|
* centers properly. For a longer discussion see the OpenGL
|
|
|
|
|
* Programming Guide, Appendix H, Correctness Tips.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
glMatrixMode(GL_PROJECTION);
|
|
|
|
|
glLoadIdentity();
|
|
|
|
|
glOrtho(0.0, sc_w, 0.0, sc_h, -1, 1);
|
|
|
|
|
glTranslatef(0.375, 0.375, 0.0);
|
|
|
|
|
|
|
|
|
|
glMatrixMode(GL_MODELVIEW);
|
|
|
|
|
glLoadIdentity();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
struct gla2DDrawInfo {
|
|
|
|
|
int orig_vp[4], orig_sc[4];
|
|
|
|
|
float orig_projmat[16], orig_viewmat[16];
|
|
|
|
|
|
|
|
|
|
rcti screen_rect;
|
|
|
|
|
rctf world_rect;
|
|
|
|
|
|
|
|
|
|
float wo_to_sc[2];
|
|
|
|
|
};
|
|
|
|
|
|
2005-10-10 17:42:48 +00:00
|
|
|
void gla2DGetMap(gla2DDrawInfo *di, rctf *rect)
|
|
|
|
|
{
|
|
|
|
|
*rect= di->world_rect;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void gla2DSetMap(gla2DDrawInfo *di, rctf *rect)
|
|
|
|
|
{
|
|
|
|
|
int sc_w, sc_h;
|
|
|
|
|
float wo_w, wo_h;
|
|
|
|
|
|
|
|
|
|
di->world_rect= *rect;
|
|
|
|
|
|
|
|
|
|
sc_w= (di->screen_rect.xmax-di->screen_rect.xmin);
|
|
|
|
|
sc_h= (di->screen_rect.ymax-di->screen_rect.ymin);
|
|
|
|
|
wo_w= (di->world_rect.xmax-di->world_rect.xmin);
|
|
|
|
|
wo_h= (di->world_rect.ymax-di->world_rect.ymin);
|
|
|
|
|
|
|
|
|
|
di->wo_to_sc[0]= sc_w/wo_w;
|
|
|
|
|
di->wo_to_sc[1]= sc_h/wo_h;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
gla2DDrawInfo *glaBegin2DDraw(rcti *screen_rect, rctf *world_rect)
|
|
|
|
|
{
|
|
|
|
|
gla2DDrawInfo *di= MEM_mallocN(sizeof(*di), "gla2DDrawInfo");
|
|
|
|
|
int sc_w, sc_h;
|
|
|
|
|
float wo_w, wo_h;
|
|
|
|
|
|
2004-07-05 10:22:00 +00:00
|
|
|
glGetIntegerv(GL_VIEWPORT, (GLint *)di->orig_vp);
|
|
|
|
|
glGetIntegerv(GL_SCISSOR_BOX, (GLint *)di->orig_sc);
|
|
|
|
|
glGetFloatv(GL_PROJECTION_MATRIX, (GLfloat *)di->orig_projmat);
|
|
|
|
|
glGetFloatv(GL_MODELVIEW_MATRIX, (GLfloat *)di->orig_viewmat);
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
|
di->screen_rect= *screen_rect;
|
|
|
|
|
if (world_rect) {
|
|
|
|
|
di->world_rect= *world_rect;
|
|
|
|
|
} else {
|
|
|
|
|
di->world_rect.xmin= di->screen_rect.xmin;
|
|
|
|
|
di->world_rect.ymin= di->screen_rect.ymin;
|
|
|
|
|
di->world_rect.xmax= di->screen_rect.xmax;
|
|
|
|
|
di->world_rect.ymax= di->screen_rect.ymax;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
sc_w= (di->screen_rect.xmax-di->screen_rect.xmin);
|
|
|
|
|
sc_h= (di->screen_rect.ymax-di->screen_rect.ymin);
|
|
|
|
|
wo_w= (di->world_rect.xmax-di->world_rect.xmin);
|
|
|
|
|
wo_h= (di->world_rect.ymax-di->world_rect.ymin);
|
|
|
|
|
|
|
|
|
|
di->wo_to_sc[0]= sc_w/wo_w;
|
|
|
|
|
di->wo_to_sc[1]= sc_h/wo_h;
|
|
|
|
|
|
|
|
|
|
glaDefine2DArea(&di->screen_rect);
|
|
|
|
|
|
|
|
|
|
return di;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void gla2DDrawTranslatePt(gla2DDrawInfo *di, float wo_x, float wo_y, int *sc_x_r, int *sc_y_r)
|
|
|
|
|
{
|
|
|
|
|
*sc_x_r= (wo_x - di->world_rect.xmin)*di->wo_to_sc[0];
|
|
|
|
|
*sc_y_r= (wo_y - di->world_rect.ymin)*di->wo_to_sc[1];
|
|
|
|
|
}
|
|
|
|
|
void gla2DDrawTranslatePtv(gla2DDrawInfo *di, float world[2], int screen_r[2])
|
|
|
|
|
{
|
|
|
|
|
screen_r[0]= (world[0] - di->world_rect.xmin)*di->wo_to_sc[0];
|
|
|
|
|
screen_r[1]= (world[1] - di->world_rect.ymin)*di->wo_to_sc[1];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void glaEnd2DDraw(gla2DDrawInfo *di)
|
|
|
|
|
{
|
|
|
|
|
glViewport(di->orig_vp[0], di->orig_vp[1], di->orig_vp[2], di->orig_vp[3]);
|
|
|
|
|
glScissor(di->orig_vp[0], di->orig_vp[1], di->orig_vp[2], di->orig_vp[3]);
|
|
|
|
|
glMatrixMode(GL_PROJECTION);
|
|
|
|
|
glLoadMatrixf(di->orig_projmat);
|
|
|
|
|
glMatrixMode(GL_MODELVIEW);
|
|
|
|
|
glLoadMatrixf(di->orig_viewmat);
|
|
|
|
|
|
|
|
|
|
MEM_freeN(di);
|
|
|
|
|
}
|
2004-07-10 21:35:17 +00:00
|
|
|
|
|
|
|
|
/* **************** glPoint hack ************************ */
|
|
|
|
|
|
|
|
|
|
static int curmode=0;
|
|
|
|
|
static int pointhack=0;
|
|
|
|
|
static GLubyte Squaredot[16] = { 0xff,0xff,0xff,0xff,
|
|
|
|
|
0xff,0xff,0xff,0xff,
|
|
|
|
|
0xff,0xff,0xff,0xff,
|
|
|
|
|
0xff,0xff,0xff,0xff};
|
|
|
|
|
|
|
|
|
|
void bglBegin(int mode)
|
|
|
|
|
{
|
|
|
|
|
curmode= mode;
|
|
|
|
|
|
|
|
|
|
if(mode==GL_POINTS) {
|
|
|
|
|
float value[4];
|
|
|
|
|
glGetFloatv(GL_POINT_SIZE_RANGE, value);
|
|
|
|
|
if(value[1]<2.0) {
|
|
|
|
|
glGetFloatv(GL_POINT_SIZE, value);
|
|
|
|
|
pointhack= floor(value[0]+0.5);
|
|
|
|
|
if(pointhack>4) pointhack= 4;
|
|
|
|
|
}
|
|
|
|
|
else glBegin(mode);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void bglVertex3fv(float *vec)
|
|
|
|
|
{
|
|
|
|
|
switch(curmode) {
|
|
|
|
|
case GL_POINTS:
|
|
|
|
|
if(pointhack) {
|
|
|
|
|
glRasterPos3fv(vec);
|
2004-07-11 08:46:26 +00:00
|
|
|
glBitmap(pointhack, pointhack, (float)pointhack/2.0, (float)pointhack/2.0, 0.0, 0.0, Squaredot);
|
2004-07-10 21:35:17 +00:00
|
|
|
}
|
|
|
|
|
else glVertex3fv(vec);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2005-07-11 17:06:03 +00:00
|
|
|
void bglVertex3f(float x, float y, float z)
|
|
|
|
|
{
|
|
|
|
|
switch(curmode) {
|
|
|
|
|
case GL_POINTS:
|
|
|
|
|
if(pointhack) {
|
|
|
|
|
glRasterPos3f(x, y, z);
|
|
|
|
|
glBitmap(pointhack, pointhack, (float)pointhack/2.0, (float)pointhack/2.0, 0.0, 0.0, Squaredot);
|
|
|
|
|
}
|
|
|
|
|
else glVertex3f(x, y, z);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2004-07-10 21:35:17 +00:00
|
|
|
void bglVertex2fv(float *vec)
|
|
|
|
|
{
|
|
|
|
|
switch(curmode) {
|
|
|
|
|
case GL_POINTS:
|
|
|
|
|
if(pointhack) {
|
|
|
|
|
glRasterPos2fv(vec);
|
|
|
|
|
glBitmap(pointhack, pointhack, (float)pointhack/2, pointhack/2, 0.0, 0.0, Squaredot);
|
|
|
|
|
}
|
|
|
|
|
else glVertex2fv(vec);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void bglEnd(void)
|
|
|
|
|
{
|
|
|
|
|
if(pointhack) pointhack= 0;
|
|
|
|
|
else glEnd();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2004-09-25 13:42:31 +00:00
|
|
|
/* *************** glPolygonOffset hack ************* */
|
|
|
|
|
|
2004-09-27 10:12:45 +00:00
|
|
|
// both temporal, so here for now (ton)
|
|
|
|
|
#include "BKE_global.h"
|
|
|
|
|
#include "DNA_view3d_types.h"
|
|
|
|
|
|
2004-09-25 13:42:31 +00:00
|
|
|
/* dist is only for ortho now... */
|
|
|
|
|
void bglPolygonOffset(float dist)
|
|
|
|
|
{
|
|
|
|
|
static float winmat[16], offset=0.0;
|
|
|
|
|
|
|
|
|
|
if(dist!=0.0) {
|
|
|
|
|
float offs;
|
|
|
|
|
|
|
|
|
|
// glEnable(GL_POLYGON_OFFSET_FILL);
|
|
|
|
|
// glPolygonOffset(-1.0, -1.0);
|
|
|
|
|
|
|
|
|
|
/* hack below is to mimic polygon offset */
|
|
|
|
|
glMatrixMode(GL_PROJECTION);
|
|
|
|
|
glGetFloatv(GL_PROJECTION_MATRIX, (float *)winmat);
|
|
|
|
|
|
2004-09-27 10:12:45 +00:00
|
|
|
/* dist is from camera to center point */
|
|
|
|
|
|
2004-09-29 21:11:13 +00:00
|
|
|
if(winmat[15]>0.5) offs= 0.00001*dist*G.vd->dist; // ortho tweaking
|
|
|
|
|
else offs= 0.0005*dist; // should be clipping value or so...
|
2004-09-25 13:42:31 +00:00
|
|
|
|
|
|
|
|
winmat[14]-= offs;
|
|
|
|
|
offset+= offs;
|
|
|
|
|
|
|
|
|
|
glLoadMatrixf(winmat);
|
|
|
|
|
glMatrixMode(GL_MODELVIEW);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
|
|
|
|
|
glMatrixMode(GL_PROJECTION);
|
|
|
|
|
winmat[14]+= offset;
|
|
|
|
|
offset= 0.0;
|
|
|
|
|
glLoadMatrixf(winmat);
|
|
|
|
|
glMatrixMode(GL_MODELVIEW);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2004-07-10 21:35:17 +00:00
|
|
|
|