mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-03 18:31:55 -04:00
set_pixel_zoom
This commit is contained in:
parent
61c935f04d
commit
0e87f046c5
@ -295,6 +295,10 @@ ConfigVariableInt back_buffers
|
|||||||
("back-buffers", 1,
|
("back-buffers", 1,
|
||||||
PRC_DESC("The default number of back buffers requested."));
|
PRC_DESC("The default number of back buffers requested."));
|
||||||
|
|
||||||
|
ConfigVariableDouble pixel_zoom
|
||||||
|
("pixel-zoom", 1.0,
|
||||||
|
PRC_DESC("The default pixel_zoom factor for new windows."));
|
||||||
|
|
||||||
ConfigVariableDouble background_color
|
ConfigVariableDouble background_color
|
||||||
("background-color", "0.41 0.41 0.41",
|
("background-color", "0.41 0.41 0.41",
|
||||||
PRC_DESC("Specifies the rgb(a) value of the default background color for a "
|
PRC_DESC("Specifies the rgb(a) value of the default background color for a "
|
||||||
|
@ -88,6 +88,8 @@ extern EXPCL_PANDA_DISPLAY ConfigVariableInt stencil_bits;
|
|||||||
extern EXPCL_PANDA_DISPLAY ConfigVariableInt multisamples;
|
extern EXPCL_PANDA_DISPLAY ConfigVariableInt multisamples;
|
||||||
extern EXPCL_PANDA_DISPLAY ConfigVariableInt back_buffers;
|
extern EXPCL_PANDA_DISPLAY ConfigVariableInt back_buffers;
|
||||||
|
|
||||||
|
extern EXPCL_PANDA_DISPLAY ConfigVariableDouble pixel_zoom;
|
||||||
|
|
||||||
extern EXPCL_PANDA_DISPLAY ConfigVariableDouble background_color;
|
extern EXPCL_PANDA_DISPLAY ConfigVariableDouble background_color;
|
||||||
extern EXPCL_PANDA_DISPLAY ConfigVariableBool sync_video;
|
extern EXPCL_PANDA_DISPLAY ConfigVariableBool sync_video;
|
||||||
extern EXPCL_PANDA_DISPLAY ConfigVariableBool basic_shaders_only;
|
extern EXPCL_PANDA_DISPLAY ConfigVariableBool basic_shaders_only;
|
||||||
|
@ -136,7 +136,7 @@ set_dimensions(float l, float r, float b, float t) {
|
|||||||
cdata->_t = t;
|
cdata->_t = t;
|
||||||
|
|
||||||
if (_window != (GraphicsOutput *)NULL && _window->has_size()) {
|
if (_window != (GraphicsOutput *)NULL && _window->has_size()) {
|
||||||
do_compute_pixels(_window->get_x_size(), _window->get_y_size(), cdata);
|
do_compute_pixels(_window->get_fb_x_size(), _window->get_fb_y_size(), cdata);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -296,7 +296,7 @@ compute_pixels() {
|
|||||||
|
|
||||||
if (_window != (GraphicsOutput *)NULL) {
|
if (_window != (GraphicsOutput *)NULL) {
|
||||||
CDWriter cdata(_cycler);
|
CDWriter cdata(_cycler);
|
||||||
do_compute_pixels(_window->get_x_size(), _window->get_y_size(),
|
do_compute_pixels(_window->get_fb_x_size(), _window->get_fb_y_size(),
|
||||||
cdata);
|
cdata);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -316,7 +316,7 @@ compute_pixels_all_stages() {
|
|||||||
if (_window != (GraphicsOutput *)NULL) {
|
if (_window != (GraphicsOutput *)NULL) {
|
||||||
OPEN_ITERATE_ALL_STAGES(_cycler) {
|
OPEN_ITERATE_ALL_STAGES(_cycler) {
|
||||||
CDStageWriter cdata(_cycler, pipeline_stage);
|
CDStageWriter cdata(_cycler, pipeline_stage);
|
||||||
do_compute_pixels(_window->get_x_size(), _window->get_y_size(),
|
do_compute_pixels(_window->get_fb_x_size(), _window->get_fb_y_size(),
|
||||||
cdata);
|
cdata);
|
||||||
}
|
}
|
||||||
CLOSE_ITERATE_ALL_STAGES(_cycler);
|
CLOSE_ITERATE_ALL_STAGES(_cycler);
|
||||||
@ -554,6 +554,30 @@ make_cull_result_graph() {
|
|||||||
return cull_result->make_result_graph();
|
return cull_result->make_result_graph();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: DisplayRegion::supports_pixel_zoom
|
||||||
|
// Access: Published, Virtual
|
||||||
|
// Description: Returns true if a call to set_pixel_zoom() will be
|
||||||
|
// respected, false if it will be ignored. If this
|
||||||
|
// returns false, then get_pixel_factor() will always
|
||||||
|
// return 1.0, regardless of what value you specify for
|
||||||
|
// set_pixel_zoom().
|
||||||
|
//
|
||||||
|
// This may return false if the underlying renderer
|
||||||
|
// doesn't support pixel zooming, or if you have called
|
||||||
|
// this on a DisplayRegion that doesn't have both
|
||||||
|
// set_clear_color() and set_clear_depth() enabled.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
bool DisplayRegion::
|
||||||
|
supports_pixel_zoom() const {
|
||||||
|
if (_window != (GraphicsOutput *)NULL) {
|
||||||
|
if (_window->supports_pixel_zoom()) {
|
||||||
|
return get_clear_color_active() && get_clear_depth_active();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Function: DisplayRegion::win_display_regions_changed
|
// Function: DisplayRegion::win_display_regions_changed
|
||||||
// Access: Private
|
// Access: Private
|
||||||
|
@ -128,6 +128,8 @@ PUBLISHED:
|
|||||||
PT(PandaNode) make_cull_result_graph();
|
PT(PandaNode) make_cull_result_graph();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
virtual bool supports_pixel_zoom() const;
|
||||||
|
|
||||||
INLINE void set_cull_result(CullResult *cull_result, SceneSetup *scene_setup,
|
INLINE void set_cull_result(CullResult *cull_result, SceneSetup *scene_setup,
|
||||||
Thread *current_thread);
|
Thread *current_thread);
|
||||||
INLINE CullResult *get_cull_result(Thread *current_thread) const;
|
INLINE CullResult *get_cull_result(Thread *current_thread) const;
|
||||||
|
@ -32,6 +32,8 @@ DrawableRegion() :
|
|||||||
_clear_value[i] = Colorf(0.0f, 0.0f, 0.0f, 0.0f);
|
_clear_value[i] = Colorf(0.0f, 0.0f, 0.0f, 0.0f);
|
||||||
}
|
}
|
||||||
_clear_value[RTP_depth] = Colorf(1.0f,1.0f,1.0f,1.0f);
|
_clear_value[RTP_depth] = Colorf(1.0f,1.0f,1.0f,1.0f);
|
||||||
|
_pixel_zoom = 1.0f;
|
||||||
|
_pixel_factor = 1.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
@ -42,7 +44,9 @@ DrawableRegion() :
|
|||||||
INLINE DrawableRegion::
|
INLINE DrawableRegion::
|
||||||
DrawableRegion(const DrawableRegion ©) :
|
DrawableRegion(const DrawableRegion ©) :
|
||||||
_screenshot_buffer_type(copy._screenshot_buffer_type),
|
_screenshot_buffer_type(copy._screenshot_buffer_type),
|
||||||
_draw_buffer_type(copy._draw_buffer_type)
|
_draw_buffer_type(copy._draw_buffer_type),
|
||||||
|
_pixel_zoom(copy._pixel_zoom),
|
||||||
|
_pixel_factor(copy._pixel_factor)
|
||||||
{
|
{
|
||||||
for (int i=0; i<RTP_COUNT; i++) {
|
for (int i=0; i<RTP_COUNT; i++) {
|
||||||
_clear_active[i] = copy._clear_active[i];
|
_clear_active[i] = copy._clear_active[i];
|
||||||
@ -63,6 +67,8 @@ operator = (const DrawableRegion ©) {
|
|||||||
_clear_active[i] = copy._clear_active[i];
|
_clear_active[i] = copy._clear_active[i];
|
||||||
_clear_value[i] = copy._clear_value[i];
|
_clear_value[i] = copy._clear_value[i];
|
||||||
}
|
}
|
||||||
|
_pixel_zoom = copy._pixel_zoom;
|
||||||
|
_pixel_factor = copy._pixel_factor;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
@ -77,6 +83,7 @@ copy_clear_settings(const DrawableRegion ©) {
|
|||||||
_clear_active[i] = copy._clear_active[i];
|
_clear_active[i] = copy._clear_active[i];
|
||||||
_clear_value[i] = copy._clear_value[i];
|
_clear_value[i] = copy._clear_value[i];
|
||||||
}
|
}
|
||||||
|
update_pixel_factor();
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
@ -91,6 +98,7 @@ copy_clear_settings(const DrawableRegion ©) {
|
|||||||
INLINE void DrawableRegion::
|
INLINE void DrawableRegion::
|
||||||
set_clear_color_active(bool clear_color_active) {
|
set_clear_color_active(bool clear_color_active) {
|
||||||
_clear_active[RTP_color] = clear_color_active;
|
_clear_active[RTP_color] = clear_color_active;
|
||||||
|
update_pixel_factor();
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
@ -117,6 +125,7 @@ get_clear_color_active() const {
|
|||||||
INLINE void DrawableRegion::
|
INLINE void DrawableRegion::
|
||||||
set_clear_depth_active(bool clear_depth_active) {
|
set_clear_depth_active(bool clear_depth_active) {
|
||||||
_clear_active[RTP_depth] = clear_depth_active;
|
_clear_active[RTP_depth] = clear_depth_active;
|
||||||
|
update_pixel_factor();
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
@ -166,6 +175,7 @@ INLINE void DrawableRegion::
|
|||||||
set_clear_active(int n, bool clear_active) {
|
set_clear_active(int n, bool clear_active) {
|
||||||
nassertv((n >= 0)&&(n < RTP_COUNT));
|
nassertv((n >= 0)&&(n < RTP_COUNT));
|
||||||
_clear_active[n] = clear_active;
|
_clear_active[n] = clear_active;
|
||||||
|
update_pixel_factor();
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
@ -296,6 +306,7 @@ disable_clears() {
|
|||||||
for (int i=0; i<RTP_COUNT; i++) {
|
for (int i=0; i<RTP_COUNT; i++) {
|
||||||
_clear_active[i] = false;
|
_clear_active[i] = false;
|
||||||
}
|
}
|
||||||
|
update_pixel_factor();
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
@ -314,6 +325,66 @@ is_any_clear_active() const {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: DrawableRegion::set_pixel_zoom
|
||||||
|
// Access: Published
|
||||||
|
// Description: Sets the amount by which the pixels of the region are
|
||||||
|
// scaled internally when filling the image interally.
|
||||||
|
// Setting this number larger makes the pixels blockier,
|
||||||
|
// but may make the rendering faster, particularly for
|
||||||
|
// software renderers. Setting this number to 2.0
|
||||||
|
// reduces the number of pixels that have to be filled
|
||||||
|
// by the renderer by a factor of 2.0. It doesn't make
|
||||||
|
// sense to set this lower than 1.0.
|
||||||
|
//
|
||||||
|
// It is possible to set this on either individual
|
||||||
|
// DisplayRegions or on overall GraphicsWindows, but you
|
||||||
|
// will get better performance for setting it on the
|
||||||
|
// window rather than its individual DisplayRegions.
|
||||||
|
// Also, you may not set it on a DisplayRegion that
|
||||||
|
// doesn't have both clear_color() and clear_depth()
|
||||||
|
// enabled.
|
||||||
|
//
|
||||||
|
// This property is only supported on renderers for
|
||||||
|
// which it is particularly useful--currently, this is
|
||||||
|
// the tinydisplay software renderer. Other kinds of
|
||||||
|
// renderers allow you to set this property, but ignore
|
||||||
|
// it.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
INLINE void DrawableRegion::
|
||||||
|
set_pixel_zoom(float pixel_zoom) {
|
||||||
|
_pixel_zoom = pixel_zoom;
|
||||||
|
update_pixel_factor();
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: DrawableRegion::get_pixel_zoom
|
||||||
|
// Access: Published
|
||||||
|
// Description: Returns the value set by set_pixel_zoom(), regardless
|
||||||
|
// of whether it is being respected or not. Also see
|
||||||
|
// get_pixel_factor().
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
INLINE float DrawableRegion::
|
||||||
|
get_pixel_zoom() const {
|
||||||
|
return _pixel_zoom;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: DrawableRegion::get_pixel_factor
|
||||||
|
// Access: Published
|
||||||
|
// Description: Returns the amount by which the height and width of
|
||||||
|
// the region will be scaled internally, based on the
|
||||||
|
// zoom factor set by set_pixel_zoom(). This will
|
||||||
|
// return 1.0 if the pixel_zoom was not set or if it is
|
||||||
|
// not being respected (for instance, because the
|
||||||
|
// underlying renderer doesn't support it--see
|
||||||
|
// supports_pixel_zoom).
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
INLINE float DrawableRegion::
|
||||||
|
get_pixel_factor() const {
|
||||||
|
return _pixel_factor;
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Function: DrawableRegion::get_screenshot_buffer_type
|
// Function: DrawableRegion::get_screenshot_buffer_type
|
||||||
// Access: Public
|
// Access: Public
|
||||||
@ -338,3 +409,23 @@ INLINE int DrawableRegion::
|
|||||||
get_draw_buffer_type() const {
|
get_draw_buffer_type() const {
|
||||||
return _draw_buffer_type;
|
return _draw_buffer_type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: DrawableRegion::update_pixel_factor
|
||||||
|
// Access: Protected
|
||||||
|
// Description: Internal function to reset pixel_factor after it may
|
||||||
|
// have changed.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
INLINE void DrawableRegion::
|
||||||
|
update_pixel_factor() {
|
||||||
|
float new_pixel_factor;
|
||||||
|
if (supports_pixel_zoom()) {
|
||||||
|
new_pixel_factor = 1.0f / sqrt(max(_pixel_zoom, 1.0f));
|
||||||
|
} else {
|
||||||
|
new_pixel_factor = 1.0f;
|
||||||
|
}
|
||||||
|
if (new_pixel_factor != _pixel_factor) {
|
||||||
|
_pixel_factor = new_pixel_factor;
|
||||||
|
pixel_factor_changed();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -28,6 +28,25 @@ DrawableRegion::
|
|||||||
~DrawableRegion() {
|
~DrawableRegion() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: DrawableRegion::supports_pixel_zoom
|
||||||
|
// Access: Published, Virtual
|
||||||
|
// Description: Returns true if a call to set_pixel_zoom() will be
|
||||||
|
// respected, false if it will be ignored. If this
|
||||||
|
// returns false, then get_pixel_factor() will always
|
||||||
|
// return 1.0, regardless of what value you specify for
|
||||||
|
// set_pixel_zoom().
|
||||||
|
//
|
||||||
|
// This may return false if the underlying renderer
|
||||||
|
// doesn't support pixel zooming, or if you have called
|
||||||
|
// this on a DisplayRegion that doesn't have both
|
||||||
|
// set_clear_color() and set_clear_depth() enabled.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
bool DrawableRegion::
|
||||||
|
supports_pixel_zoom() const {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Function: DrawableRegion::get_renderbuffer_type
|
// Function: DrawableRegion::get_renderbuffer_type
|
||||||
// Access: Static, Published
|
// Access: Static, Published
|
||||||
@ -57,3 +76,12 @@ get_renderbuffer_type(int rtp) {
|
|||||||
return 0;
|
return 0;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: DrawableRegion::pixel_factor_changed
|
||||||
|
// Access: Published, Virtual
|
||||||
|
// Description: Called internally when the pixel factor changes.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
void DrawableRegion::
|
||||||
|
pixel_factor_changed() {
|
||||||
|
}
|
||||||
|
@ -95,12 +95,21 @@ PUBLISHED:
|
|||||||
|
|
||||||
INLINE bool is_any_clear_active() const;
|
INLINE bool is_any_clear_active() const;
|
||||||
|
|
||||||
|
INLINE void set_pixel_zoom(float pixel_zoom);
|
||||||
|
INLINE float get_pixel_zoom() const;
|
||||||
|
INLINE float get_pixel_factor() const;
|
||||||
|
virtual bool supports_pixel_zoom() const;
|
||||||
|
|
||||||
static int get_renderbuffer_type(int plane);
|
static int get_renderbuffer_type(int plane);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
INLINE int get_screenshot_buffer_type() const;
|
INLINE int get_screenshot_buffer_type() const;
|
||||||
INLINE int get_draw_buffer_type() const;
|
INLINE int get_draw_buffer_type() const;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
INLINE void update_pixel_factor();
|
||||||
|
virtual void pixel_factor_changed();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
int _screenshot_buffer_type;
|
int _screenshot_buffer_type;
|
||||||
int _draw_buffer_type;
|
int _draw_buffer_type;
|
||||||
@ -108,6 +117,9 @@ protected:
|
|||||||
private:
|
private:
|
||||||
bool _clear_active[RTP_COUNT];
|
bool _clear_active[RTP_COUNT];
|
||||||
Colorf _clear_value[RTP_COUNT];
|
Colorf _clear_value[RTP_COUNT];
|
||||||
|
|
||||||
|
float _pixel_zoom;
|
||||||
|
float _pixel_factor;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -139,8 +139,8 @@ get_rtm_mode(int i) const {
|
|||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Function: GraphicsOutput::get_x_size
|
// Function: GraphicsOutput::get_x_size
|
||||||
// Access: Published
|
// Access: Published
|
||||||
// Description: Returns the width of the graphics frame buffer, if it
|
// Description: Returns the visible width of the window or buffer, if
|
||||||
// is known. In certain cases (e.g. fullscreen
|
// it is known. In certain cases (e.g. fullscreen
|
||||||
// windows), the size may not be known until after the
|
// windows), the size may not be known until after the
|
||||||
// object has been fully created. Check has_size()
|
// object has been fully created. Check has_size()
|
||||||
// first.
|
// first.
|
||||||
@ -158,8 +158,8 @@ get_x_size() const {
|
|||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Function: GraphicsOutput::get_y_size
|
// Function: GraphicsOutput::get_y_size
|
||||||
// Access: Published
|
// Access: Published
|
||||||
// Description: Returns the height of the graphics frame buffer, if it
|
// Description: Returns the visible height of the window or buffer,
|
||||||
// is known. In certain cases (e.g. fullscreen
|
// if it is known. In certain cases (e.g. fullscreen
|
||||||
// windows), the size may not be known until after the
|
// windows), the size may not be known until after the
|
||||||
// object has been fully created. Check has_size()
|
// object has been fully created. Check has_size()
|
||||||
// first.
|
// first.
|
||||||
@ -174,6 +174,32 @@ get_y_size() const {
|
|||||||
return _y_size;
|
return _y_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: GraphicsOutput::get_fb_x_size
|
||||||
|
// Access: Published
|
||||||
|
// Description: Returns the internal width of the window or buffer.
|
||||||
|
// This is almost always the same as get_x_size(),
|
||||||
|
// except when a pixel_zoom is in effect--see
|
||||||
|
// set_pixel_zoom().
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
INLINE int GraphicsOutput::
|
||||||
|
get_fb_x_size() const {
|
||||||
|
return max(int(_x_size * get_pixel_factor()), 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: GraphicsOutput::get_fb_y_size
|
||||||
|
// Access: Published
|
||||||
|
// Description: Returns the internal height of the window or buffer.
|
||||||
|
// This is almost always the same as get_y_size(),
|
||||||
|
// except when a pixel_zoom is in effect--see
|
||||||
|
// set_pixel_zoom().
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
INLINE int GraphicsOutput::
|
||||||
|
get_fb_y_size() const {
|
||||||
|
return max(int(_y_size * get_pixel_factor()), 1);
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Function: GraphicsOutput::has_size
|
// Function: GraphicsOutput::has_size
|
||||||
// Access: Published
|
// Access: Published
|
||||||
|
@ -632,11 +632,14 @@ set_size_and_recalc(int x, int y) {
|
|||||||
_y_size = y;
|
_y_size = y;
|
||||||
_has_size = true;
|
_has_size = true;
|
||||||
|
|
||||||
|
int fb_x_size = get_fb_x_size();
|
||||||
|
int fb_y_size = get_fb_y_size();
|
||||||
|
|
||||||
TotalDisplayRegions::iterator dri;
|
TotalDisplayRegions::iterator dri;
|
||||||
for (dri = _total_display_regions.begin();
|
for (dri = _total_display_regions.begin();
|
||||||
dri != _total_display_regions.end();
|
dri != _total_display_regions.end();
|
||||||
++dri) {
|
++dri) {
|
||||||
(*dri)->compute_pixels_all_stages(x, y);
|
(*dri)->compute_pixels_all_stages(fb_x_size, fb_y_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_texture_card != 0) {
|
if (_texture_card != 0) {
|
||||||
@ -920,6 +923,18 @@ void GraphicsOutput::
|
|||||||
end_frame(FrameMode mode, Thread *current_thread) {
|
end_frame(FrameMode mode, Thread *current_thread) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: GraphicsOutput::pixel_factor_changed
|
||||||
|
// Access: Published, Virtual
|
||||||
|
// Description: Called internally when the pixel factor changes.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
void GraphicsOutput::
|
||||||
|
pixel_factor_changed() {
|
||||||
|
if (_has_size) {
|
||||||
|
set_size_and_recalc(_x_size, _y_size);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Function: GraphicsOutput::prepare_for_deletion
|
// Function: GraphicsOutput::prepare_for_deletion
|
||||||
// Access: Protected
|
// Access: Protected
|
||||||
|
@ -108,6 +108,8 @@ PUBLISHED:
|
|||||||
|
|
||||||
INLINE int get_x_size() const;
|
INLINE int get_x_size() const;
|
||||||
INLINE int get_y_size() const;
|
INLINE int get_y_size() const;
|
||||||
|
INLINE int get_fb_x_size() const;
|
||||||
|
INLINE int get_fb_y_size() const;
|
||||||
INLINE bool has_size() const;
|
INLINE bool has_size() const;
|
||||||
INLINE bool is_valid() const;
|
INLINE bool is_valid() const;
|
||||||
|
|
||||||
@ -214,7 +216,7 @@ public:
|
|||||||
INLINE PStatCollector &get_draw_window_pcollector();
|
INLINE PStatCollector &get_draw_window_pcollector();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
virtual void pixel_factor_changed();
|
||||||
void prepare_for_deletion();
|
void prepare_for_deletion();
|
||||||
void copy_to_textures();
|
void copy_to_textures();
|
||||||
|
|
||||||
|
@ -71,6 +71,7 @@ GraphicsWindow(GraphicsPipe *pipe,
|
|||||||
request_properties(win_prop);
|
request_properties(win_prop);
|
||||||
|
|
||||||
_window_event = "window-event";
|
_window_event = "window-event";
|
||||||
|
set_pixel_zoom(pixel_zoom);
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
|
@ -504,6 +504,8 @@ TinyGraphicsStateGuardian(GraphicsPipe *pipe,
|
|||||||
GraphicsStateGuardian(CS_yup_right, pipe),
|
GraphicsStateGuardian(CS_yup_right, pipe),
|
||||||
_textures_lru("textures_lru", td_texture_ram)
|
_textures_lru("textures_lru", td_texture_ram)
|
||||||
{
|
{
|
||||||
|
_current_frame_buffer = NULL;
|
||||||
|
_aux_frame_buffer = NULL;
|
||||||
_c = NULL;
|
_c = NULL;
|
||||||
_vertices = NULL;
|
_vertices = NULL;
|
||||||
_vertices_size = 0;
|
_vertices_size = 0;
|
||||||
@ -565,6 +567,11 @@ reset() {
|
|||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
void TinyGraphicsStateGuardian::
|
void TinyGraphicsStateGuardian::
|
||||||
free_pointers() {
|
free_pointers() {
|
||||||
|
if (_aux_frame_buffer != (ZBuffer *)NULL) {
|
||||||
|
ZB_close(_aux_frame_buffer);
|
||||||
|
_aux_frame_buffer = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
if (_vertices != (GLVertex *)NULL) {
|
if (_vertices != (GLVertex *)NULL) {
|
||||||
PANDA_FREE_ARRAY(_vertices);
|
PANDA_FREE_ARRAY(_vertices);
|
||||||
_vertices = NULL;
|
_vertices = NULL;
|
||||||
@ -679,6 +686,31 @@ prepare_display_region(DisplayRegionPipelineReader *dr,
|
|||||||
int xmin, ymin, xsize, ysize;
|
int xmin, ymin, xsize, ysize;
|
||||||
dr->get_region_pixels_i(xmin, ymin, xsize, ysize);
|
dr->get_region_pixels_i(xmin, ymin, xsize, ysize);
|
||||||
|
|
||||||
|
float pixel_factor = _current_display_region->get_pixel_factor();
|
||||||
|
if (pixel_factor != 1.0) {
|
||||||
|
// Render into an aux buffer, and zoom it up into the main
|
||||||
|
// frame buffer later.
|
||||||
|
xmin = 0;
|
||||||
|
ymin = 0;
|
||||||
|
xsize = int(xsize * pixel_factor);
|
||||||
|
ysize = int(ysize * pixel_factor);
|
||||||
|
if (_aux_frame_buffer == (ZBuffer *)NULL) {
|
||||||
|
// We add 3 to xsize, since ZB_open may resize the frame buffer
|
||||||
|
// down by up to 3 pixels to make it fit within the
|
||||||
|
// word-alignment rule.
|
||||||
|
_aux_frame_buffer = ZB_open(xsize + 3, ysize, ZB_MODE_RGBA, 0, 0, 0, 0);
|
||||||
|
} else if (_aux_frame_buffer->xsize < xsize || _aux_frame_buffer->ysize < ysize) {
|
||||||
|
ZB_resize(_aux_frame_buffer, NULL,
|
||||||
|
max(_aux_frame_buffer->xsize, xsize) + 3,
|
||||||
|
max(_aux_frame_buffer->ysize, ysize));
|
||||||
|
}
|
||||||
|
_c->zb = _aux_frame_buffer;
|
||||||
|
|
||||||
|
} else {
|
||||||
|
// Render directly into the main frame buffer.
|
||||||
|
_c->zb = _current_frame_buffer;
|
||||||
|
}
|
||||||
|
|
||||||
_c->viewport.xmin = xmin;
|
_c->viewport.xmin = xmin;
|
||||||
_c->viewport.ymin = ymin;
|
_c->viewport.ymin = ymin;
|
||||||
_c->viewport.xsize = xsize;
|
_c->viewport.xsize = xsize;
|
||||||
@ -807,6 +839,39 @@ begin_scene() {
|
|||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
void TinyGraphicsStateGuardian::
|
void TinyGraphicsStateGuardian::
|
||||||
end_scene() {
|
end_scene() {
|
||||||
|
if (_c->zb == _aux_frame_buffer) {
|
||||||
|
// Copy the aux frame buffer into the main scene now, zooming it
|
||||||
|
// up to the appropriate size.
|
||||||
|
int xmin, ymin, xsize, ysize;
|
||||||
|
_current_display_region->get_region_pixels_i(xmin, ymin, xsize, ysize);
|
||||||
|
float pixel_factor = _current_display_region->get_pixel_factor();
|
||||||
|
|
||||||
|
int fb_xsize = int(xsize * pixel_factor);
|
||||||
|
int fb_ysize = int(ysize * pixel_factor);
|
||||||
|
|
||||||
|
int tyinc = _current_frame_buffer->linesize / PSZB;
|
||||||
|
int fyinc = _aux_frame_buffer->linesize / PSZB;
|
||||||
|
|
||||||
|
int fyt = 0;
|
||||||
|
for (int ty = 0; ty < ysize; ++ty) {
|
||||||
|
int fy = fyt / ysize;
|
||||||
|
fyt += fb_ysize;
|
||||||
|
|
||||||
|
PIXEL *tp = _current_frame_buffer->pbuf + xmin + (ymin + ty) * tyinc;
|
||||||
|
PIXEL *fp = _aux_frame_buffer->pbuf + fy * fyinc;
|
||||||
|
ZPOINT *tz = _current_frame_buffer->zbuf + xmin + (ymin + ty) * _current_frame_buffer->xsize;
|
||||||
|
ZPOINT *fz = _aux_frame_buffer->zbuf + fy * _aux_frame_buffer->xsize;
|
||||||
|
int fxt = 0;
|
||||||
|
for (int tx = 0; tx < xsize; ++tx) {
|
||||||
|
int fx = fxt / xsize;
|
||||||
|
fxt += fb_xsize;
|
||||||
|
|
||||||
|
tp[tx] = fp[fx];
|
||||||
|
tz[tx] = fz[fx];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_c->zb = _current_frame_buffer;
|
||||||
|
}
|
||||||
GraphicsStateGuardian::end_scene();
|
GraphicsStateGuardian::end_scene();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -124,6 +124,10 @@ public:
|
|||||||
ZBuffer *_current_frame_buffer;
|
ZBuffer *_current_frame_buffer;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
// Allocated by prepare_display_region when necessary for a zoomed
|
||||||
|
// display region.
|
||||||
|
ZBuffer *_aux_frame_buffer;
|
||||||
|
|
||||||
GLContext *_c;
|
GLContext *_c;
|
||||||
|
|
||||||
enum ColorMaterialFlags {
|
enum ColorMaterialFlags {
|
||||||
|
@ -48,6 +48,7 @@ TinyWinGraphicsWindow(GraphicsPipe *pipe,
|
|||||||
{
|
{
|
||||||
_frame_buffer = NULL;
|
_frame_buffer = NULL;
|
||||||
_hdc = (HDC)0;
|
_hdc = (HDC)0;
|
||||||
|
update_pixel_factor();
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
@ -133,17 +134,46 @@ begin_flip() {
|
|||||||
HDC bmdc = CreateCompatibleDC(_hdc);
|
HDC bmdc = CreateCompatibleDC(_hdc);
|
||||||
SelectObject(bmdc, bm);
|
SelectObject(bmdc, bm);
|
||||||
|
|
||||||
SetDIBits(_hdc, bm, 0, _frame_buffer->ysize, _frame_buffer->pbuf,
|
int fb_xsize = get_fb_x_size();
|
||||||
|
int fb_ysize = get_fb_y_size();
|
||||||
|
int fb_ytop = _frame_buffer->ysize - fb_ysize;
|
||||||
|
|
||||||
|
SetDIBits(_hdc, bm, fb_ytop, fb_ysize, _frame_buffer->pbuf,
|
||||||
&_bitmap_info, DIB_RGB_COLORS);
|
&_bitmap_info, DIB_RGB_COLORS);
|
||||||
|
|
||||||
BitBlt(_hdc, 0, 0, _frame_buffer->xsize, _frame_buffer->ysize,
|
if (fb_xsize == _frame_buffer->xsize) {
|
||||||
|
BitBlt(_hdc, 0, 0, fb_xsize, fb_ysize,
|
||||||
bmdc, 0, 0, SRCCOPY);
|
bmdc, 0, 0, SRCCOPY);
|
||||||
|
} else {
|
||||||
|
StretchBlt(_hdc, 0, 0, _frame_buffer->xsize, _frame_buffer->ysize,
|
||||||
|
bmdc, 0, 0,fb_xsize, fb_ysize,
|
||||||
|
SRCCOPY);
|
||||||
|
}
|
||||||
|
|
||||||
DeleteDC(bmdc);
|
DeleteDC(bmdc);
|
||||||
DeleteObject(bm);
|
DeleteObject(bm);
|
||||||
GdiFlush();
|
GdiFlush();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: TinyWinGraphicsWindow::supports_pixel_zoom
|
||||||
|
// Access: Published, Virtual
|
||||||
|
// Description: Returns true if a call to set_pixel_zoom() will be
|
||||||
|
// respected, false if it will be ignored. If this
|
||||||
|
// returns false, then get_pixel_factor() will always
|
||||||
|
// return 1.0, regardless of what value you specify for
|
||||||
|
// set_pixel_zoom().
|
||||||
|
//
|
||||||
|
// This may return false if the underlying renderer
|
||||||
|
// doesn't support pixel zooming, or if you have called
|
||||||
|
// this on a DisplayRegion that doesn't have both
|
||||||
|
// set_clear_color() and set_clear_depth() enabled.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
bool TinyWinGraphicsWindow::
|
||||||
|
supports_pixel_zoom() const {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Function: TinyWinGraphicsWindow::close_window
|
// Function: TinyWinGraphicsWindow::close_window
|
||||||
// Access: Protected, Virtual
|
// Access: Protected, Virtual
|
||||||
|
@ -46,6 +46,7 @@ public:
|
|||||||
virtual void end_frame(FrameMode mode, Thread *current_thread);
|
virtual void end_frame(FrameMode mode, Thread *current_thread);
|
||||||
|
|
||||||
virtual void begin_flip();
|
virtual void begin_flip();
|
||||||
|
virtual bool supports_pixel_zoom() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void close_window();
|
virtual void close_window();
|
||||||
|
@ -4,13 +4,13 @@
|
|||||||
void gl_eval_viewport(GLContext * c)
|
void gl_eval_viewport(GLContext * c)
|
||||||
{
|
{
|
||||||
GLViewport *v;
|
GLViewport *v;
|
||||||
float zsize = (1 << (ZB_Z_BITS + ZB_POINT_Z_FRAC_BITS));
|
float zsize = ((long long)1 << (ZB_Z_BITS + ZB_POINT_Z_FRAC_BITS));
|
||||||
|
|
||||||
v = &c->viewport;
|
v = &c->viewport;
|
||||||
|
|
||||||
v->trans.X = ((v->xsize - 0.5f) / 2.0f) + v->xmin;
|
v->trans.X = ((v->xsize - 0.5f) / 2.0f) + v->xmin;
|
||||||
v->trans.Y = ((v->ysize - 0.5f) / 2.0f) + v->ymin;
|
v->trans.Y = ((v->ysize - 0.5f) / 2.0f) + v->ymin;
|
||||||
v->trans.Z = ((zsize - 0.5f) / 2.0f) + ((1 << ZB_POINT_Z_FRAC_BITS)) / 2;
|
v->trans.Z = ((zsize - 0.5f) / 2.0f);
|
||||||
|
|
||||||
v->scale.X = (v->xsize - 0.5f) / 2.0f;
|
v->scale.X = (v->xsize - 0.5f) / 2.0f;
|
||||||
v->scale.Y = -(v->ysize - 0.5f) / 2.0f;
|
v->scale.Y = -(v->ysize - 0.5f) / 2.0f;
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
ZBuffer *ZB_open(int xsize, int ysize, int mode,
|
ZBuffer *ZB_open(int xsize, int ysize, int mode,
|
||||||
int nb_colors,
|
int nb_colors,
|
||||||
unsigned char *color_indexes,
|
unsigned char *color_indexes,
|
||||||
int *color_table,
|
unsigned int *color_table,
|
||||||
void *frame_buffer)
|
void *frame_buffer)
|
||||||
{
|
{
|
||||||
ZBuffer *zb;
|
ZBuffer *zb;
|
||||||
@ -49,9 +49,9 @@ ZBuffer *ZB_open(int xsize, int ysize, int mode,
|
|||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
size = zb->xsize * zb->ysize * sizeof(unsigned short);
|
size = zb->xsize * zb->ysize * sizeof(ZPOINT);
|
||||||
|
|
||||||
zb->zbuf = (unsigned short *)gl_malloc(size);
|
zb->zbuf = (ZPOINT *)gl_malloc(size);
|
||||||
if (zb->zbuf == NULL)
|
if (zb->zbuf == NULL)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
@ -100,9 +100,9 @@ void ZB_resize(ZBuffer * zb, void *frame_buffer, int xsize, int ysize)
|
|||||||
zb->ysize = ysize;
|
zb->ysize = ysize;
|
||||||
zb->linesize = (xsize * PSZB + 3) & ~3;
|
zb->linesize = (xsize * PSZB + 3) & ~3;
|
||||||
|
|
||||||
size = zb->xsize * zb->ysize * sizeof(unsigned short);
|
size = zb->xsize * zb->ysize * sizeof(ZPOINT);
|
||||||
gl_free(zb->zbuf);
|
gl_free(zb->zbuf);
|
||||||
zb->zbuf = (unsigned short *)gl_malloc(size);
|
zb->zbuf = (ZPOINT *)gl_malloc(size);
|
||||||
|
|
||||||
if (zb->frame_buffer_allocated)
|
if (zb->frame_buffer_allocated)
|
||||||
gl_free(zb->pbuf);
|
gl_free(zb->pbuf);
|
||||||
@ -142,11 +142,11 @@ static void ZB_copyFrameBuffer5R6G5B(ZBuffer * zb,
|
|||||||
void *buf, int linesize)
|
void *buf, int linesize)
|
||||||
{
|
{
|
||||||
PIXEL *q;
|
PIXEL *q;
|
||||||
unsigned short *p, *p1;
|
unsigned char *p, *p1;
|
||||||
int y, n;
|
int y, n;
|
||||||
|
|
||||||
q = zb->pbuf;
|
q = zb->pbuf;
|
||||||
p1 = (unsigned short *) buf;
|
p1 = (unsigned char *) buf;
|
||||||
|
|
||||||
for (y = 0; y < zb->ysize; y++) {
|
for (y = 0; y < zb->ysize; y++) {
|
||||||
p = p1;
|
p = p1;
|
||||||
@ -159,7 +159,7 @@ static void ZB_copyFrameBuffer5R6G5B(ZBuffer * zb,
|
|||||||
q += 4;
|
q += 4;
|
||||||
p += 4;
|
p += 4;
|
||||||
} while (--n > 0);
|
} while (--n > 0);
|
||||||
p1 = (unsigned short *)((char *)p1 + linesize);
|
p1 = (unsigned char *)((char *)p1 + linesize);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -222,7 +222,7 @@ void memset_s(void *adr, int val, int count)
|
|||||||
{
|
{
|
||||||
int i, n, v;
|
int i, n, v;
|
||||||
unsigned int *p;
|
unsigned int *p;
|
||||||
unsigned short *q;
|
unsigned char *q;
|
||||||
|
|
||||||
p = (unsigned int *)adr;
|
p = (unsigned int *)adr;
|
||||||
v = val | (val << 16);
|
v = val | (val << 16);
|
||||||
@ -236,7 +236,7 @@ void memset_s(void *adr, int val, int count)
|
|||||||
p += 4;
|
p += 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
q = (unsigned short *) p;
|
q = (unsigned char *) p;
|
||||||
n = count & 7;
|
n = count & 7;
|
||||||
for (i = 0; i < n; i++)
|
for (i = 0; i < n; i++)
|
||||||
*q++ = val;
|
*q++ = val;
|
||||||
@ -294,15 +294,15 @@ void memset_RGB24(void *adr,int r, int v, int b,long count)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ZB_clear(ZBuffer * zb, int clear_z, int z,
|
void ZB_clear(ZBuffer * zb, int clear_z, ZPOINT z,
|
||||||
int clear_color, int r, int g, int b, int a)
|
int clear_color, unsigned int r, unsigned int g, unsigned int b, unsigned int a)
|
||||||
{
|
{
|
||||||
int color;
|
unsigned int color;
|
||||||
int y;
|
int y;
|
||||||
PIXEL *pp;
|
PIXEL *pp;
|
||||||
|
|
||||||
if (clear_z) {
|
if (clear_z) {
|
||||||
memset_s(zb->zbuf, z, zb->xsize * zb->ysize);
|
memset(zb->zbuf, 0, zb->xsize * zb->ysize * sizeof(ZPOINT));
|
||||||
}
|
}
|
||||||
if (clear_color) {
|
if (clear_color) {
|
||||||
color = RGBA_TO_PIXEL(r, g, b, a);
|
color = RGBA_TO_PIXEL(r, g, b, a);
|
||||||
@ -314,20 +314,19 @@ void ZB_clear(ZBuffer * zb, int clear_z, int z,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ZB_clear_viewport(ZBuffer * zb, int clear_z, int z,
|
void ZB_clear_viewport(ZBuffer * zb, int clear_z, ZPOINT z,
|
||||||
int clear_color, int r, int g, int b, int a,
|
int clear_color, unsigned int r, unsigned int g, unsigned int b, unsigned int a,
|
||||||
int xmin, int ymin, int xsize, int ysize)
|
int xmin, int ymin, int xsize, int ysize)
|
||||||
{
|
{
|
||||||
int color;
|
unsigned int color;
|
||||||
int y;
|
int y;
|
||||||
PIXEL *pp;
|
PIXEL *pp;
|
||||||
unsigned short *zz;
|
ZPOINT *zz;
|
||||||
int ytop;
|
|
||||||
|
|
||||||
if (clear_z) {
|
if (clear_z) {
|
||||||
zz = zb->zbuf + xmin + ymin * zb->xsize;
|
zz = zb->zbuf + xmin + ymin * zb->xsize;
|
||||||
for (y = 0; y < ysize; ++y) {
|
for (y = 0; y < ysize; ++y) {
|
||||||
memset_s(zz, z, xsize);
|
memset(zz, 0, xsize * sizeof(ZPOINT));
|
||||||
zz += zb->xsize;
|
zz += zb->xsize;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -344,11 +343,11 @@ void ZB_clear_viewport(ZBuffer * zb, int clear_z, int z,
|
|||||||
#define ZB_ST_FRAC_HIGH (1 << ZB_POINT_ST_FRAC_BITS)
|
#define ZB_ST_FRAC_HIGH (1 << ZB_POINT_ST_FRAC_BITS)
|
||||||
#define ZB_ST_FRAC_MASK (ZB_ST_FRAC_HIGH - 1)
|
#define ZB_ST_FRAC_MASK (ZB_ST_FRAC_HIGH - 1)
|
||||||
|
|
||||||
PIXEL lookup_texture_bilinear(ZTexture *texture, int s, int t)
|
PIXEL lookup_texture_bilinear(ZTexture *texture, unsigned int s, unsigned int t)
|
||||||
{
|
{
|
||||||
PIXEL p1, p2, p3, p4;
|
PIXEL p1, p2, p3, p4;
|
||||||
int sf, tf;
|
unsigned int sf, tf;
|
||||||
int r, g, b, a;
|
unsigned int r, g, b, a;
|
||||||
|
|
||||||
p1 = ZB_LOOKUP_TEXTURE_NEAREST(texture, s, t);
|
p1 = ZB_LOOKUP_TEXTURE_NEAREST(texture, s, t);
|
||||||
p2 = ZB_LOOKUP_TEXTURE_NEAREST(texture, s + ZB_ST_FRAC_HIGH, t);
|
p2 = ZB_LOOKUP_TEXTURE_NEAREST(texture, s + ZB_ST_FRAC_HIGH, t);
|
||||||
|
@ -7,14 +7,10 @@
|
|||||||
|
|
||||||
#include "zfeatures.h"
|
#include "zfeatures.h"
|
||||||
|
|
||||||
|
typedef unsigned int ZPOINT;
|
||||||
#define ZB_Z_BITS 16
|
#define ZB_Z_BITS 16
|
||||||
|
|
||||||
#define ZB_POINT_Z_FRAC_BITS 14
|
#define ZB_POINT_Z_FRAC_BITS 14
|
||||||
|
|
||||||
/* The number of bits for lookup for S and T texture coords. This is
|
|
||||||
based on a fixed texture size of 256x256. */
|
|
||||||
#define ZB_POINT_ST_BITS 8
|
|
||||||
|
|
||||||
/* The number of fractional bits below the S and T texture coords.
|
/* The number of fractional bits below the S and T texture coords.
|
||||||
The more we have, the more precise the texel calculation will be
|
The more we have, the more precise the texel calculation will be
|
||||||
when we zoom into small details of a texture; but the greater
|
when we zoom into small details of a texture; but the greater
|
||||||
@ -88,7 +84,7 @@ typedef unsigned int PIXEL;
|
|||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
PIXEL *pixmap;
|
PIXEL *pixmap;
|
||||||
int s_mask, t_mask, t_shift;
|
unsigned int s_mask, t_mask, t_shift;
|
||||||
} ZTexture;
|
} ZTexture;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
@ -96,7 +92,7 @@ typedef struct {
|
|||||||
int linesize; /* line size, in bytes */
|
int linesize; /* line size, in bytes */
|
||||||
int mode;
|
int mode;
|
||||||
|
|
||||||
unsigned short *zbuf;
|
ZPOINT *zbuf;
|
||||||
PIXEL *pbuf;
|
PIXEL *pbuf;
|
||||||
int frame_buffer_allocated;
|
int frame_buffer_allocated;
|
||||||
|
|
||||||
@ -120,20 +116,20 @@ typedef struct {
|
|||||||
ZBuffer *ZB_open(int xsize,int ysize,int mode,
|
ZBuffer *ZB_open(int xsize,int ysize,int mode,
|
||||||
int nb_colors,
|
int nb_colors,
|
||||||
unsigned char *color_indexes,
|
unsigned char *color_indexes,
|
||||||
int *color_table,
|
unsigned int *color_table,
|
||||||
void *frame_buffer);
|
void *frame_buffer);
|
||||||
|
|
||||||
|
|
||||||
void ZB_close(ZBuffer *zb);
|
void ZB_close(ZBuffer *zb);
|
||||||
|
|
||||||
void ZB_resize(ZBuffer *zb,void *frame_buffer,int xsize,int ysize);
|
void ZB_resize(ZBuffer *zb,void *frame_buffer,int xsize,int ysize);
|
||||||
void ZB_clear(ZBuffer *zb,int clear_z,int z,
|
void ZB_clear(ZBuffer *zb, int clear_z, ZPOINT z,
|
||||||
int clear_color,int r,int g,int b,int a);
|
int clear_color, unsigned int r, unsigned int g, unsigned int b, unsigned int a);
|
||||||
void ZB_clear_viewport(ZBuffer * zb, int clear_z, int z,
|
void ZB_clear_viewport(ZBuffer * zb, int clear_z, ZPOINT z,
|
||||||
int clear_color, int r, int g, int b, int a,
|
int clear_color, unsigned int r, unsigned int g, unsigned int b, unsigned int a,
|
||||||
int xmin, int ymin, int xsize, int ysize);
|
int xmin, int ymin, int xsize, int ysize);
|
||||||
|
|
||||||
PIXEL lookup_texture_bilinear(ZTexture *texture, int s, int t);
|
PIXEL lookup_texture_bilinear(ZTexture *texture, unsigned int s, unsigned int t);
|
||||||
|
|
||||||
/* linesize is in BYTES */
|
/* linesize is in BYTES */
|
||||||
void ZB_copyFrameBuffer(ZBuffer *zb,void *buf,int linesize);
|
void ZB_copyFrameBuffer(ZBuffer *zb,void *buf,int linesize);
|
||||||
|
@ -207,7 +207,7 @@ void gl_eval_viewport(GLContext *c);
|
|||||||
void gl_vertex_transform(GLContext * c, GLVertex * v);
|
void gl_vertex_transform(GLContext * c, GLVertex * v);
|
||||||
|
|
||||||
/* image_util.c */
|
/* image_util.c */
|
||||||
void gl_convertRGB_to_5R6G5B(unsigned short *pixmap,unsigned char *rgb,
|
void gl_convertRGB_to_5R6G5B(unsigned char *pixmap,unsigned char *rgb,
|
||||||
int xsize,int ysize);
|
int xsize,int ysize);
|
||||||
void gl_convertRGB_to_8A8R8G8B(unsigned int *pixmap, unsigned char *rgb,
|
void gl_convertRGB_to_8A8R8G8B(unsigned int *pixmap, unsigned char *rgb,
|
||||||
int xsize, int ysize);
|
int xsize, int ysize);
|
||||||
|
@ -2,13 +2,13 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include "zbuffer.h"
|
#include "zbuffer.h"
|
||||||
|
|
||||||
#define ZCMP(z,zpix) ((z) >= (zpix))
|
#define ZCMP(z,zpix) ((ZPOINT)(z) >= (ZPOINT)(zpix))
|
||||||
|
|
||||||
void ZB_plot(ZBuffer * zb, ZBufferPoint * p)
|
void ZB_plot(ZBuffer * zb, ZBufferPoint * p)
|
||||||
{
|
{
|
||||||
unsigned short *pz;
|
ZPOINT *pz;
|
||||||
PIXEL *pp;
|
PIXEL *pp;
|
||||||
int zz;
|
unsigned int zz;
|
||||||
|
|
||||||
pz = zb->zbuf + (p->y * zb->xsize + p->x);
|
pz = zb->zbuf + (p->y * zb->xsize + p->x);
|
||||||
pp = (PIXEL *) ((char *) zb->pbuf + zb->linesize * p->y + p->x * PSZB);
|
pp = (PIXEL *) ((char *) zb->pbuf + zb->linesize * p->y + p->x * PSZB);
|
||||||
@ -21,7 +21,7 @@ void ZB_plot(ZBuffer * zb, ZBufferPoint * p)
|
|||||||
|
|
||||||
#define INTERP_Z
|
#define INTERP_Z
|
||||||
static void ZB_line_flat_z(ZBuffer * zb, ZBufferPoint * p1, ZBufferPoint * p2,
|
static void ZB_line_flat_z(ZBuffer * zb, ZBufferPoint * p1, ZBufferPoint * p2,
|
||||||
int color)
|
unsigned int color)
|
||||||
{
|
{
|
||||||
#include "zline.h"
|
#include "zline.h"
|
||||||
}
|
}
|
||||||
@ -37,7 +37,7 @@ static void ZB_line_interp_z(ZBuffer * zb, ZBufferPoint * p1, ZBufferPoint * p2)
|
|||||||
/* no Z interpolation */
|
/* no Z interpolation */
|
||||||
|
|
||||||
static void ZB_line_flat(ZBuffer * zb, ZBufferPoint * p1, ZBufferPoint * p2,
|
static void ZB_line_flat(ZBuffer * zb, ZBufferPoint * p1, ZBufferPoint * p2,
|
||||||
int color)
|
unsigned int color)
|
||||||
{
|
{
|
||||||
#include "zline.h"
|
#include "zline.h"
|
||||||
}
|
}
|
||||||
@ -50,7 +50,7 @@ static void ZB_line_interp(ZBuffer * zb, ZBufferPoint * p1, ZBufferPoint * p2)
|
|||||||
|
|
||||||
void ZB_line_z(ZBuffer * zb, ZBufferPoint * p1, ZBufferPoint * p2)
|
void ZB_line_z(ZBuffer * zb, ZBufferPoint * p1, ZBufferPoint * p2)
|
||||||
{
|
{
|
||||||
int color1, color2;
|
unsigned int color1, color2;
|
||||||
|
|
||||||
color1 = RGBA_TO_PIXEL(p1->r, p1->g, p1->b, p1->a);
|
color1 = RGBA_TO_PIXEL(p1->r, p1->g, p1->b, p1->a);
|
||||||
color2 = RGBA_TO_PIXEL(p2->r, p2->g, p2->b, p2->a);
|
color2 = RGBA_TO_PIXEL(p2->r, p2->g, p2->b, p2->a);
|
||||||
@ -65,7 +65,7 @@ void ZB_line_z(ZBuffer * zb, ZBufferPoint * p1, ZBufferPoint * p2)
|
|||||||
|
|
||||||
void ZB_line(ZBuffer * zb, ZBufferPoint * p1, ZBufferPoint * p2)
|
void ZB_line(ZBuffer * zb, ZBufferPoint * p1, ZBufferPoint * p2)
|
||||||
{
|
{
|
||||||
int color1, color2;
|
unsigned int color1, color2;
|
||||||
|
|
||||||
color1 = RGB_TO_PIXEL(p1->r, p1->g, p1->b);
|
color1 = RGB_TO_PIXEL(p1->r, p1->g, p1->b);
|
||||||
color2 = RGB_TO_PIXEL(p2->r, p2->g, p2->b);
|
color2 = RGB_TO_PIXEL(p2->r, p2->g, p2->b);
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
register unsigned int rinc, ginc, binc;
|
register unsigned int rinc, ginc, binc;
|
||||||
#endif
|
#endif
|
||||||
#ifdef INTERP_Z
|
#ifdef INTERP_Z
|
||||||
register unsigned short *pz;
|
register ZPOINT *pz;
|
||||||
int zinc;
|
int zinc;
|
||||||
register int z, zz;
|
register int z, zz;
|
||||||
#endif
|
#endif
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
#define STORE_Z(zpix, z) (zpix) = (z)
|
#define STORE_Z(zpix, z) (zpix) = (z)
|
||||||
#define STORE_PIX(pix, rgb, r, g, b, a) (pix) = (rgb)
|
#define STORE_PIX(pix, rgb, r, g, b, a) (pix) = (rgb)
|
||||||
#define ACMP(zb,a) 1
|
#define ACMP(zb,a) 1
|
||||||
#define ZCMP(zpix, z) ((zpix) < (z))
|
#define ZCMP(zpix, z) ((ZPOINT)(zpix) < (ZPOINT)(z))
|
||||||
#define FNAME(name) name ## _xx_zon_noblend_anone_zless
|
#define FNAME(name) name ## _xx_zon_noblend_anone_zless
|
||||||
#include "ztriangle_two.h"
|
#include "ztriangle_two.h"
|
||||||
|
|
||||||
@ -26,7 +26,7 @@
|
|||||||
#define STORE_Z(zpix, z) (zpix) = (z)
|
#define STORE_Z(zpix, z) (zpix) = (z)
|
||||||
#define STORE_PIX(pix, rgb, r, g, b, a) (pix) = (rgb)
|
#define STORE_PIX(pix, rgb, r, g, b, a) (pix) = (rgb)
|
||||||
#define ACMP(zb,a) (((unsigned int)(a)) < (zb)->reference_alpha)
|
#define ACMP(zb,a) (((unsigned int)(a)) < (zb)->reference_alpha)
|
||||||
#define ZCMP(zpix, z) ((zpix) < (z))
|
#define ZCMP(zpix, z) ((ZPOINT)(zpix) < (ZPOINT)(z))
|
||||||
#define FNAME(name) name ## _xx_zon_noblend_aless_zless
|
#define FNAME(name) name ## _xx_zon_noblend_aless_zless
|
||||||
#include "ztriangle_two.h"
|
#include "ztriangle_two.h"
|
||||||
|
|
||||||
@ -40,7 +40,7 @@
|
|||||||
#define STORE_Z(zpix, z) (zpix) = (z)
|
#define STORE_Z(zpix, z) (zpix) = (z)
|
||||||
#define STORE_PIX(pix, rgb, r, g, b, a) (pix) = (rgb)
|
#define STORE_PIX(pix, rgb, r, g, b, a) (pix) = (rgb)
|
||||||
#define ACMP(zb,a) (((unsigned int)(a)) > (zb)->reference_alpha)
|
#define ACMP(zb,a) (((unsigned int)(a)) > (zb)->reference_alpha)
|
||||||
#define ZCMP(zpix, z) ((zpix) < (z))
|
#define ZCMP(zpix, z) ((ZPOINT)(zpix) < (ZPOINT)(z))
|
||||||
#define FNAME(name) name ## _xx_zon_noblend_amore_zless
|
#define FNAME(name) name ## _xx_zon_noblend_amore_zless
|
||||||
#include "ztriangle_two.h"
|
#include "ztriangle_two.h"
|
||||||
|
|
||||||
@ -54,7 +54,7 @@
|
|||||||
#define STORE_Z(zpix, z) (zpix) = (z)
|
#define STORE_Z(zpix, z) (zpix) = (z)
|
||||||
#define STORE_PIX(pix, rgb, r, g, b, a) (pix) = PIXEL_BLEND_RGB(pix, r, g, b, a)
|
#define STORE_PIX(pix, rgb, r, g, b, a) (pix) = PIXEL_BLEND_RGB(pix, r, g, b, a)
|
||||||
#define ACMP(zb,a) 1
|
#define ACMP(zb,a) 1
|
||||||
#define ZCMP(zpix, z) ((zpix) < (z))
|
#define ZCMP(zpix, z) ((ZPOINT)(zpix) < (ZPOINT)(z))
|
||||||
#define FNAME(name) name ## _xx_zon_blend_anone_zless
|
#define FNAME(name) name ## _xx_zon_blend_anone_zless
|
||||||
#include "ztriangle_two.h"
|
#include "ztriangle_two.h"
|
||||||
|
|
||||||
@ -68,7 +68,7 @@
|
|||||||
#define STORE_Z(zpix, z) (zpix) = (z)
|
#define STORE_Z(zpix, z) (zpix) = (z)
|
||||||
#define STORE_PIX(pix, rgb, r, g, b, a) (pix) = PIXEL_BLEND_RGB(pix, r, g, b, a)
|
#define STORE_PIX(pix, rgb, r, g, b, a) (pix) = PIXEL_BLEND_RGB(pix, r, g, b, a)
|
||||||
#define ACMP(zb,a) (((unsigned int)(a)) < (zb)->reference_alpha)
|
#define ACMP(zb,a) (((unsigned int)(a)) < (zb)->reference_alpha)
|
||||||
#define ZCMP(zpix, z) ((zpix) < (z))
|
#define ZCMP(zpix, z) ((ZPOINT)(zpix) < (ZPOINT)(z))
|
||||||
#define FNAME(name) name ## _xx_zon_blend_aless_zless
|
#define FNAME(name) name ## _xx_zon_blend_aless_zless
|
||||||
#include "ztriangle_two.h"
|
#include "ztriangle_two.h"
|
||||||
|
|
||||||
@ -82,7 +82,7 @@
|
|||||||
#define STORE_Z(zpix, z) (zpix) = (z)
|
#define STORE_Z(zpix, z) (zpix) = (z)
|
||||||
#define STORE_PIX(pix, rgb, r, g, b, a) (pix) = PIXEL_BLEND_RGB(pix, r, g, b, a)
|
#define STORE_PIX(pix, rgb, r, g, b, a) (pix) = PIXEL_BLEND_RGB(pix, r, g, b, a)
|
||||||
#define ACMP(zb,a) (((unsigned int)(a)) > (zb)->reference_alpha)
|
#define ACMP(zb,a) (((unsigned int)(a)) > (zb)->reference_alpha)
|
||||||
#define ZCMP(zpix, z) ((zpix) < (z))
|
#define ZCMP(zpix, z) ((ZPOINT)(zpix) < (ZPOINT)(z))
|
||||||
#define FNAME(name) name ## _xx_zon_blend_amore_zless
|
#define FNAME(name) name ## _xx_zon_blend_amore_zless
|
||||||
#include "ztriangle_two.h"
|
#include "ztriangle_two.h"
|
||||||
|
|
||||||
@ -96,7 +96,7 @@
|
|||||||
#define STORE_Z(zpix, z) (zpix) = (z)
|
#define STORE_Z(zpix, z) (zpix) = (z)
|
||||||
#define STORE_PIX(pix, rgb, r, g, b, a)
|
#define STORE_PIX(pix, rgb, r, g, b, a)
|
||||||
#define ACMP(zb,a) 1
|
#define ACMP(zb,a) 1
|
||||||
#define ZCMP(zpix, z) ((zpix) < (z))
|
#define ZCMP(zpix, z) ((ZPOINT)(zpix) < (ZPOINT)(z))
|
||||||
#define FNAME(name) name ## _xx_zon_nocolor_anone_zless
|
#define FNAME(name) name ## _xx_zon_nocolor_anone_zless
|
||||||
#include "ztriangle_two.h"
|
#include "ztriangle_two.h"
|
||||||
|
|
||||||
@ -110,7 +110,7 @@
|
|||||||
#define STORE_Z(zpix, z) (zpix) = (z)
|
#define STORE_Z(zpix, z) (zpix) = (z)
|
||||||
#define STORE_PIX(pix, rgb, r, g, b, a)
|
#define STORE_PIX(pix, rgb, r, g, b, a)
|
||||||
#define ACMP(zb,a) (((unsigned int)(a)) < (zb)->reference_alpha)
|
#define ACMP(zb,a) (((unsigned int)(a)) < (zb)->reference_alpha)
|
||||||
#define ZCMP(zpix, z) ((zpix) < (z))
|
#define ZCMP(zpix, z) ((ZPOINT)(zpix) < (ZPOINT)(z))
|
||||||
#define FNAME(name) name ## _xx_zon_nocolor_aless_zless
|
#define FNAME(name) name ## _xx_zon_nocolor_aless_zless
|
||||||
#include "ztriangle_two.h"
|
#include "ztriangle_two.h"
|
||||||
|
|
||||||
@ -124,7 +124,7 @@
|
|||||||
#define STORE_Z(zpix, z) (zpix) = (z)
|
#define STORE_Z(zpix, z) (zpix) = (z)
|
||||||
#define STORE_PIX(pix, rgb, r, g, b, a)
|
#define STORE_PIX(pix, rgb, r, g, b, a)
|
||||||
#define ACMP(zb,a) (((unsigned int)(a)) > (zb)->reference_alpha)
|
#define ACMP(zb,a) (((unsigned int)(a)) > (zb)->reference_alpha)
|
||||||
#define ZCMP(zpix, z) ((zpix) < (z))
|
#define ZCMP(zpix, z) ((ZPOINT)(zpix) < (ZPOINT)(z))
|
||||||
#define FNAME(name) name ## _xx_zon_nocolor_amore_zless
|
#define FNAME(name) name ## _xx_zon_nocolor_amore_zless
|
||||||
#include "ztriangle_two.h"
|
#include "ztriangle_two.h"
|
||||||
|
|
||||||
@ -138,7 +138,7 @@
|
|||||||
#define STORE_Z(zpix, z)
|
#define STORE_Z(zpix, z)
|
||||||
#define STORE_PIX(pix, rgb, r, g, b, a) (pix) = (rgb)
|
#define STORE_PIX(pix, rgb, r, g, b, a) (pix) = (rgb)
|
||||||
#define ACMP(zb,a) 1
|
#define ACMP(zb,a) 1
|
||||||
#define ZCMP(zpix, z) ((zpix) < (z))
|
#define ZCMP(zpix, z) ((ZPOINT)(zpix) < (ZPOINT)(z))
|
||||||
#define FNAME(name) name ## _xx_zoff_noblend_anone_zless
|
#define FNAME(name) name ## _xx_zoff_noblend_anone_zless
|
||||||
#include "ztriangle_two.h"
|
#include "ztriangle_two.h"
|
||||||
|
|
||||||
@ -152,7 +152,7 @@
|
|||||||
#define STORE_Z(zpix, z)
|
#define STORE_Z(zpix, z)
|
||||||
#define STORE_PIX(pix, rgb, r, g, b, a) (pix) = (rgb)
|
#define STORE_PIX(pix, rgb, r, g, b, a) (pix) = (rgb)
|
||||||
#define ACMP(zb,a) (((unsigned int)(a)) < (zb)->reference_alpha)
|
#define ACMP(zb,a) (((unsigned int)(a)) < (zb)->reference_alpha)
|
||||||
#define ZCMP(zpix, z) ((zpix) < (z))
|
#define ZCMP(zpix, z) ((ZPOINT)(zpix) < (ZPOINT)(z))
|
||||||
#define FNAME(name) name ## _xx_zoff_noblend_aless_zless
|
#define FNAME(name) name ## _xx_zoff_noblend_aless_zless
|
||||||
#include "ztriangle_two.h"
|
#include "ztriangle_two.h"
|
||||||
|
|
||||||
@ -166,7 +166,7 @@
|
|||||||
#define STORE_Z(zpix, z)
|
#define STORE_Z(zpix, z)
|
||||||
#define STORE_PIX(pix, rgb, r, g, b, a) (pix) = (rgb)
|
#define STORE_PIX(pix, rgb, r, g, b, a) (pix) = (rgb)
|
||||||
#define ACMP(zb,a) (((unsigned int)(a)) > (zb)->reference_alpha)
|
#define ACMP(zb,a) (((unsigned int)(a)) > (zb)->reference_alpha)
|
||||||
#define ZCMP(zpix, z) ((zpix) < (z))
|
#define ZCMP(zpix, z) ((ZPOINT)(zpix) < (ZPOINT)(z))
|
||||||
#define FNAME(name) name ## _xx_zoff_noblend_amore_zless
|
#define FNAME(name) name ## _xx_zoff_noblend_amore_zless
|
||||||
#include "ztriangle_two.h"
|
#include "ztriangle_two.h"
|
||||||
|
|
||||||
@ -180,7 +180,7 @@
|
|||||||
#define STORE_Z(zpix, z)
|
#define STORE_Z(zpix, z)
|
||||||
#define STORE_PIX(pix, rgb, r, g, b, a) (pix) = PIXEL_BLEND_RGB(pix, r, g, b, a)
|
#define STORE_PIX(pix, rgb, r, g, b, a) (pix) = PIXEL_BLEND_RGB(pix, r, g, b, a)
|
||||||
#define ACMP(zb,a) 1
|
#define ACMP(zb,a) 1
|
||||||
#define ZCMP(zpix, z) ((zpix) < (z))
|
#define ZCMP(zpix, z) ((ZPOINT)(zpix) < (ZPOINT)(z))
|
||||||
#define FNAME(name) name ## _xx_zoff_blend_anone_zless
|
#define FNAME(name) name ## _xx_zoff_blend_anone_zless
|
||||||
#include "ztriangle_two.h"
|
#include "ztriangle_two.h"
|
||||||
|
|
||||||
@ -194,7 +194,7 @@
|
|||||||
#define STORE_Z(zpix, z)
|
#define STORE_Z(zpix, z)
|
||||||
#define STORE_PIX(pix, rgb, r, g, b, a) (pix) = PIXEL_BLEND_RGB(pix, r, g, b, a)
|
#define STORE_PIX(pix, rgb, r, g, b, a) (pix) = PIXEL_BLEND_RGB(pix, r, g, b, a)
|
||||||
#define ACMP(zb,a) (((unsigned int)(a)) < (zb)->reference_alpha)
|
#define ACMP(zb,a) (((unsigned int)(a)) < (zb)->reference_alpha)
|
||||||
#define ZCMP(zpix, z) ((zpix) < (z))
|
#define ZCMP(zpix, z) ((ZPOINT)(zpix) < (ZPOINT)(z))
|
||||||
#define FNAME(name) name ## _xx_zoff_blend_aless_zless
|
#define FNAME(name) name ## _xx_zoff_blend_aless_zless
|
||||||
#include "ztriangle_two.h"
|
#include "ztriangle_two.h"
|
||||||
|
|
||||||
@ -208,7 +208,7 @@
|
|||||||
#define STORE_Z(zpix, z)
|
#define STORE_Z(zpix, z)
|
||||||
#define STORE_PIX(pix, rgb, r, g, b, a) (pix) = PIXEL_BLEND_RGB(pix, r, g, b, a)
|
#define STORE_PIX(pix, rgb, r, g, b, a) (pix) = PIXEL_BLEND_RGB(pix, r, g, b, a)
|
||||||
#define ACMP(zb,a) (((unsigned int)(a)) > (zb)->reference_alpha)
|
#define ACMP(zb,a) (((unsigned int)(a)) > (zb)->reference_alpha)
|
||||||
#define ZCMP(zpix, z) ((zpix) < (z))
|
#define ZCMP(zpix, z) ((ZPOINT)(zpix) < (ZPOINT)(z))
|
||||||
#define FNAME(name) name ## _xx_zoff_blend_amore_zless
|
#define FNAME(name) name ## _xx_zoff_blend_amore_zless
|
||||||
#include "ztriangle_two.h"
|
#include "ztriangle_two.h"
|
||||||
|
|
||||||
@ -222,7 +222,7 @@
|
|||||||
#define STORE_Z(zpix, z)
|
#define STORE_Z(zpix, z)
|
||||||
#define STORE_PIX(pix, rgb, r, g, b, a)
|
#define STORE_PIX(pix, rgb, r, g, b, a)
|
||||||
#define ACMP(zb,a) 1
|
#define ACMP(zb,a) 1
|
||||||
#define ZCMP(zpix, z) ((zpix) < (z))
|
#define ZCMP(zpix, z) ((ZPOINT)(zpix) < (ZPOINT)(z))
|
||||||
#define FNAME(name) name ## _xx_zoff_nocolor_anone_zless
|
#define FNAME(name) name ## _xx_zoff_nocolor_anone_zless
|
||||||
#include "ztriangle_two.h"
|
#include "ztriangle_two.h"
|
||||||
|
|
||||||
@ -236,7 +236,7 @@
|
|||||||
#define STORE_Z(zpix, z)
|
#define STORE_Z(zpix, z)
|
||||||
#define STORE_PIX(pix, rgb, r, g, b, a)
|
#define STORE_PIX(pix, rgb, r, g, b, a)
|
||||||
#define ACMP(zb,a) (((unsigned int)(a)) < (zb)->reference_alpha)
|
#define ACMP(zb,a) (((unsigned int)(a)) < (zb)->reference_alpha)
|
||||||
#define ZCMP(zpix, z) ((zpix) < (z))
|
#define ZCMP(zpix, z) ((ZPOINT)(zpix) < (ZPOINT)(z))
|
||||||
#define FNAME(name) name ## _xx_zoff_nocolor_aless_zless
|
#define FNAME(name) name ## _xx_zoff_nocolor_aless_zless
|
||||||
#include "ztriangle_two.h"
|
#include "ztriangle_two.h"
|
||||||
|
|
||||||
@ -250,6 +250,6 @@
|
|||||||
#define STORE_Z(zpix, z)
|
#define STORE_Z(zpix, z)
|
||||||
#define STORE_PIX(pix, rgb, r, g, b, a)
|
#define STORE_PIX(pix, rgb, r, g, b, a)
|
||||||
#define ACMP(zb,a) (((unsigned int)(a)) > (zb)->reference_alpha)
|
#define ACMP(zb,a) (((unsigned int)(a)) > (zb)->reference_alpha)
|
||||||
#define ZCMP(zpix, z) ((zpix) < (z))
|
#define ZCMP(zpix, z) ((ZPOINT)(zpix) < (ZPOINT)(z))
|
||||||
#define FNAME(name) name ## _xx_zoff_nocolor_amore_zless
|
#define FNAME(name) name ## _xx_zoff_nocolor_amore_zless
|
||||||
#include "ztriangle_two.h"
|
#include "ztriangle_two.h"
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
{
|
{
|
||||||
ZBufferPoint *t,*pr1,*pr2,*l1,*l2;
|
ZBufferPoint *t,*pr1,*pr2,*l1,*l2;
|
||||||
float fdx1, fdx2, fdy1, fdy2, fz, d1, d2;
|
float fdx1, fdx2, fdy1, fdy2, fz, d1, d2;
|
||||||
unsigned short *pz1;
|
ZPOINT *pz1;
|
||||||
PIXEL *pp1;
|
PIXEL *pp1;
|
||||||
int part,update_left,update_right;
|
int part,update_left,update_right;
|
||||||
|
|
||||||
@ -258,7 +258,7 @@
|
|||||||
register PIXEL *pp;
|
register PIXEL *pp;
|
||||||
register int n;
|
register int n;
|
||||||
#ifdef INTERP_Z
|
#ifdef INTERP_Z
|
||||||
register unsigned short *pz;
|
register ZPOINT *pz;
|
||||||
register unsigned int z,zz;
|
register unsigned int z,zz;
|
||||||
#endif
|
#endif
|
||||||
#ifdef INTERP_RGB
|
#ifdef INTERP_RGB
|
||||||
|
@ -276,7 +276,7 @@ void FNAME(ZB_fillTriangleMappingPerspective) (ZBuffer *zb,
|
|||||||
|
|
||||||
#define DRAW_LINE() \
|
#define DRAW_LINE() \
|
||||||
{ \
|
{ \
|
||||||
register unsigned short *pz; \
|
register ZPOINT *pz; \
|
||||||
register PIXEL *pp; \
|
register PIXEL *pp; \
|
||||||
register unsigned int s,t,z,zz; \
|
register unsigned int s,t,z,zz; \
|
||||||
register int n,dsdx,dtdx; \
|
register int n,dsdx,dtdx; \
|
||||||
@ -294,8 +294,8 @@ void FNAME(ZB_fillTriangleMappingPerspective) (ZBuffer *zb,
|
|||||||
float ss,tt; \
|
float ss,tt; \
|
||||||
ss=(sz * zinv); \
|
ss=(sz * zinv); \
|
||||||
tt=(tz * zinv); \
|
tt=(tz * zinv); \
|
||||||
s=(int) ss; \
|
s=(unsigned int) ss; \
|
||||||
t=(int) tt; \
|
t=(unsigned int) tt; \
|
||||||
dsdx= (int)( (dszdx - ss*fdzdx)*zinv ); \
|
dsdx= (int)( (dszdx - ss*fdzdx)*zinv ); \
|
||||||
dtdx= (int)( (dtzdx - tt*fdzdx)*zinv ); \
|
dtdx= (int)( (dtzdx - tt*fdzdx)*zinv ); \
|
||||||
fz+=fndzdx; \
|
fz+=fndzdx; \
|
||||||
@ -319,8 +319,8 @@ void FNAME(ZB_fillTriangleMappingPerspective) (ZBuffer *zb,
|
|||||||
float ss,tt; \
|
float ss,tt; \
|
||||||
ss=(sz * zinv); \
|
ss=(sz * zinv); \
|
||||||
tt=(tz * zinv); \
|
tt=(tz * zinv); \
|
||||||
s=(int) ss; \
|
s=(unsigned int) ss; \
|
||||||
t=(int) tt; \
|
t=(unsigned int) tt; \
|
||||||
dsdx= (int)( (dszdx - ss*fdzdx)*zinv ); \
|
dsdx= (int)( (dszdx - ss*fdzdx)*zinv ); \
|
||||||
dtdx= (int)( (dtzdx - tt*fdzdx)*zinv ); \
|
dtdx= (int)( (dtzdx - tt*fdzdx)*zinv ); \
|
||||||
} \
|
} \
|
||||||
@ -394,7 +394,7 @@ void FNAME(ZB_fillTriangleMappingPerspectiveFlat) (ZBuffer *zb,
|
|||||||
|
|
||||||
#define DRAW_LINE() \
|
#define DRAW_LINE() \
|
||||||
{ \
|
{ \
|
||||||
register unsigned short *pz; \
|
register ZPOINT *pz; \
|
||||||
register PIXEL *pp; \
|
register PIXEL *pp; \
|
||||||
register unsigned int s,t,z,zz; \
|
register unsigned int s,t,z,zz; \
|
||||||
register int n,dsdx,dtdx; \
|
register int n,dsdx,dtdx; \
|
||||||
@ -417,8 +417,8 @@ void FNAME(ZB_fillTriangleMappingPerspectiveFlat) (ZBuffer *zb,
|
|||||||
float ss,tt; \
|
float ss,tt; \
|
||||||
ss=(sz * zinv); \
|
ss=(sz * zinv); \
|
||||||
tt=(tz * zinv); \
|
tt=(tz * zinv); \
|
||||||
s=(int) ss; \
|
s=(unsigned int) ss; \
|
||||||
t=(int) tt; \
|
t=(unsigned int) tt; \
|
||||||
dsdx= (int)( (dszdx - ss*fdzdx)*zinv ); \
|
dsdx= (int)( (dszdx - ss*fdzdx)*zinv ); \
|
||||||
dtdx= (int)( (dtzdx - tt*fdzdx)*zinv ); \
|
dtdx= (int)( (dtzdx - tt*fdzdx)*zinv ); \
|
||||||
fz+=fndzdx; \
|
fz+=fndzdx; \
|
||||||
@ -442,8 +442,8 @@ void FNAME(ZB_fillTriangleMappingPerspectiveFlat) (ZBuffer *zb,
|
|||||||
float ss,tt; \
|
float ss,tt; \
|
||||||
ss=(sz * zinv); \
|
ss=(sz * zinv); \
|
||||||
tt=(tz * zinv); \
|
tt=(tz * zinv); \
|
||||||
s=(int) ss; \
|
s=(unsigned int) ss; \
|
||||||
t=(int) tt; \
|
t=(unsigned int) tt; \
|
||||||
dsdx= (int)( (dszdx - ss*fdzdx)*zinv ); \
|
dsdx= (int)( (dszdx - ss*fdzdx)*zinv ); \
|
||||||
dtdx= (int)( (dtzdx - tt*fdzdx)*zinv ); \
|
dtdx= (int)( (dtzdx - tt*fdzdx)*zinv ); \
|
||||||
} \
|
} \
|
||||||
@ -529,7 +529,7 @@ void FNAME(ZB_fillTriangleMappingPerspectiveSmooth) (ZBuffer *zb,
|
|||||||
|
|
||||||
#define DRAW_LINE() \
|
#define DRAW_LINE() \
|
||||||
{ \
|
{ \
|
||||||
register unsigned short *pz; \
|
register ZPOINT *pz; \
|
||||||
register PIXEL *pp; \
|
register PIXEL *pp; \
|
||||||
register unsigned int s,t,z,zz; \
|
register unsigned int s,t,z,zz; \
|
||||||
register int n,dsdx,dtdx; \
|
register int n,dsdx,dtdx; \
|
||||||
@ -552,8 +552,8 @@ void FNAME(ZB_fillTriangleMappingPerspectiveSmooth) (ZBuffer *zb,
|
|||||||
float ss,tt; \
|
float ss,tt; \
|
||||||
ss=(sz * zinv); \
|
ss=(sz * zinv); \
|
||||||
tt=(tz * zinv); \
|
tt=(tz * zinv); \
|
||||||
s=(int) ss; \
|
s=(unsigned int) ss; \
|
||||||
t=(int) tt; \
|
t=(unsigned int) tt; \
|
||||||
dsdx= (int)( (dszdx - ss*fdzdx)*zinv ); \
|
dsdx= (int)( (dszdx - ss*fdzdx)*zinv ); \
|
||||||
dtdx= (int)( (dtzdx - tt*fdzdx)*zinv ); \
|
dtdx= (int)( (dtzdx - tt*fdzdx)*zinv ); \
|
||||||
fz+=fndzdx; \
|
fz+=fndzdx; \
|
||||||
@ -577,8 +577,8 @@ void FNAME(ZB_fillTriangleMappingPerspectiveSmooth) (ZBuffer *zb,
|
|||||||
float ss,tt; \
|
float ss,tt; \
|
||||||
ss=(sz * zinv); \
|
ss=(sz * zinv); \
|
||||||
tt=(tz * zinv); \
|
tt=(tz * zinv); \
|
||||||
s=(int) ss; \
|
s=(unsigned int) ss; \
|
||||||
t=(int) tt; \
|
t=(unsigned int) tt; \
|
||||||
dsdx= (int)( (dszdx - ss*fdzdx)*zinv ); \
|
dsdx= (int)( (dszdx - ss*fdzdx)*zinv ); \
|
||||||
dtdx= (int)( (dtzdx - tt*fdzdx)*zinv ); \
|
dtdx= (int)( (dtzdx - tt*fdzdx)*zinv ); \
|
||||||
} \
|
} \
|
||||||
|
Loading…
x
Reference in New Issue
Block a user