Subversion Repositories Games.Descent

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
1 pmbaty 1
/*
2
 * Portions of this file are copyright Rebirth contributors and licensed as
3
 * described in COPYING.txt.
4
 * Portions of this file are copyright Parallax Software and licensed
5
 * according to the Parallax license below.
6
 * See COPYING.txt for license details.
7
 
8
THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
9
SOFTWARE CORPORATION ("PARALLAX").  PARALLAX, IN DISTRIBUTING THE CODE TO
10
END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A
11
ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS
12
IN USING, DISPLAYING,  AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS
13
SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE
14
FREE PURPOSES.  IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE
15
CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES.  THE END-USER UNDERSTANDS
16
AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE.
17
COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION.  ALL RIGHTS RESERVED.
18
*/
19
 
20
/*
21
 *
22
 * Graphical routines for setting a pixel.
23
 *
24
 */
25
 
26
#include "u_mem.h"
27
#include "gr.h"
28
#include "grdef.h"
29
#if DXX_USE_OGL
30
#include "ogl_init.h"
31
#endif
32
 
33
namespace dcx {
34
 
35
void gr_upixel(grs_bitmap &cv_bitmap, const unsigned x, const unsigned y, const color_palette_index color)
36
{
37
        switch (cv_bitmap.get_type())
38
        {
39
#if DXX_USE_OGL
40
        case bm_mode::ogl:
41
                ogl_upixelc(cv_bitmap, x, y, color);
42
                return;
43
#endif
44
        case bm_mode::linear:
45
                cv_bitmap.get_bitmap_data()[cv_bitmap.bm_rowsize * y + x] = color;
46
                return;
47
        }
48
}
49
 
50
void gr_pixel(grs_bitmap &cv_bitmap, const unsigned x, const unsigned y, const color_palette_index color)
51
{
52
        if (unlikely(x >= cv_bitmap.bm_w || y >= cv_bitmap.bm_h))
53
                return;
54
        gr_upixel(cv_bitmap, x, y, color);
55
}
56
 
57
#if !DXX_USE_OGL
58
#define gr_bm_upixel(C,B,X,Y,C2) gr_bm_upixel(B,X,Y,C2)
59
#endif
60
static inline void gr_bm_upixel(grs_canvas &canvas, grs_bitmap &bm, const uint_fast32_t x, const uint_fast32_t y, const color_palette_index color)
61
{
62
        switch (bm.get_type())
63
        {
64
#if DXX_USE_OGL
65
        case bm_mode::ogl:
66
                ogl_upixelc(canvas.cv_bitmap, bm.bm_x + x, bm.bm_y + y, color);
67
                return;
68
#endif
69
        case bm_mode::linear:
70
                bm.get_bitmap_data()[bm.bm_rowsize*y+x] = color;
71
                return;
72
        }
73
}
74
 
75
void gr_bm_pixel(grs_canvas &canvas, grs_bitmap &bm, const uint_fast32_t x, const uint_fast32_t y, const color_palette_index color)
76
{
77
        if (unlikely(x >= bm.bm_w || y >= bm.bm_h))
78
                return;
79
        gr_bm_upixel(canvas, bm, x, y, color);
80
}
81
 
82
}