dxx-rebirth/common/2d/pixel.cpp

80 lines
1.9 KiB
C++
Raw Normal View History

2006-03-20 16:43:15 +00:00
/*
2014-06-01 17:55:23 +00:00
* Portions of this file are copyright Rebirth contributors and licensed as
* described in COPYING.txt.
* Portions of this file are copyright Parallax Software and licensed
* according to the Parallax license below.
* See COPYING.txt for license details.
2006-03-20 16:43:15 +00:00
THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO
END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A
ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS
IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS
SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE
FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE
CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS
AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE.
2006-03-20 16:43:15 +00:00
COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
*/
2006-03-20 16:43:15 +00:00
/*
*
* Graphical routines for setting a pixel.
*
*/
#include "u_mem.h"
#include "gr.h"
#include "grdef.h"
#ifdef OGL
#include "ogl_init.h"
#endif
2015-12-13 18:00:49 +00:00
namespace dcx {
2015-12-05 22:57:23 +00:00
2016-02-12 04:02:28 +00:00
void gr_upixel(unsigned x, unsigned y, const uint8_t color)
2006-03-20 16:43:15 +00:00
{
switch (TYPE)
{
#ifdef OGL
case BM_OGL:
2016-02-12 04:02:28 +00:00
ogl_upixelc(x, y, color);
return;
2006-03-20 16:43:15 +00:00
#endif
case BM_LINEAR:
2016-02-12 04:02:28 +00:00
DATA[ROWSIZE * y + x] = color;
2006-03-20 16:43:15 +00:00
return;
}
2006-03-20 16:43:15 +00:00
}
2016-02-12 04:02:28 +00:00
void gr_pixel(unsigned x, unsigned y, const uint8_t color)
2006-03-20 16:43:15 +00:00
{
2015-05-09 17:39:00 +00:00
if (unlikely(x >= GWIDTH || y >= GHEIGHT))
return;
2016-02-12 04:02:28 +00:00
gr_upixel(x, y, color);
2006-03-20 16:43:15 +00:00
}
2014-11-30 22:09:22 +00:00
static inline void gr_bm_upixel(grs_bitmap &bm, uint_fast32_t x, uint_fast32_t y, uint8_t color )
2006-03-20 16:43:15 +00:00
{
2015-07-25 23:10:47 +00:00
switch (bm.get_type())
2006-03-20 16:43:15 +00:00
{
#ifdef OGL
case BM_OGL:
2014-11-30 22:09:22 +00:00
ogl_upixelc(bm.bm_x+x,bm.bm_y+y,color);
return;
2006-03-20 16:43:15 +00:00
#endif
case BM_LINEAR:
2014-12-02 03:24:38 +00:00
bm.get_bitmap_data()[bm.bm_rowsize*y+x] = color;
2006-03-20 16:43:15 +00:00
return;
}
2006-03-20 16:43:15 +00:00
}
2014-11-30 22:09:22 +00:00
void gr_bm_pixel(grs_bitmap &bm, uint_fast32_t x, uint_fast32_t y, uint8_t color )
2006-03-20 16:43:15 +00:00
{
2015-05-09 17:39:00 +00:00
if (unlikely(x >= bm.bm_w || y >= bm.bm_h))
return;
2006-03-20 16:43:15 +00:00
gr_bm_upixel (bm, x, y, color);
}
2015-12-05 22:57:23 +00:00
}