ScummVM API documentation
render_internal.h
1/* ScummVM - Graphic Adventure Engine
2 *
3 * ScummVM is the legal property of its developers, whose names
4 * are too numerous to list here. Please refer to the COPYRIGHT
5 * file distributed with this source distribution.
6 *
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 *
20 * Based on the original sources
21 * https://github.com/Croquetx/thecolony
22 * Copyright (C) 1988, David A. Smith
23 *
24 * Distributed under Apache Version 2.0 License
25 *
26 */
27
28#ifndef COLONY_RENDER_INTERNAL_H
29#define COLONY_RENDER_INTERNAL_H
30
31#include "colony/colony.h"
32#include "colony/renderer.h"
33
34namespace Colony {
35
36// render.cpp; shared with the wall-feature renderer.
37void projectCorridorPointClamped(const Common::Rect &screenR, int look, int lookY,
38 const int *sint, const int *cost, int camX, int camY,
39 float worldX, float worldY, float worldZ,
40 int &screenX, int &screenY);
41
42// DOS MetaWINDOW polygon material setup. setupDOSFill() accepts EGA palette
43// indices directly; setupDOSMaterial() resolves an lsColor material and returns
44// the LINEFILLCOLOR used to frame the filled polygon.
45void setupDOSFill(Renderer *gfx, uint32 fillColor, uint32 backColor, int pattern);
46uint32 setupDOSMaterial(Renderer *gfx, int colorIdx, int level);
47
48// Mac Classic dither patterns (from colorize.c cColor[].pattern).
49// Mac Classic was a 1-bit B&W display. QuickDraw used 8x8 dither patterns
50// to simulate grayscale: WHITE, LTGRAY, GRAY, DKGRAY, BLACK, CLEAR.
51// Rendered via GL_POLYGON_STIPPLE: two-pass fill (white bg + black fg with stipple mask).
52enum MacPattern {
53 kPatternWhite = 0, // Solid white (all background)
54 kPatternLtGray = 1, // 25% foreground (sparse black dots on white)
55 kPatternGray = 2, // 50% foreground (checkerboard)
56 kPatternDkGray = 3, // 75% foreground (dense black, sparse white)
57 kPatternBlack = 4, // Solid black (all foreground)
58 kPatternClear = 5 // Outline only (no fill)
59};
60
61// Internal-only surface color for Mac wall helper objects (FWALL/CWALL).
62// In the original Mac renderer these use c_lwall/c_dwall, which are
63// special corridor-wall colors rather than normal material palette entries.
64const int kColorCorridorWall = 1000;
65
66// GL_POLYGON_STIPPLE patterns: 32x32 bit arrays (128 bytes), tiled from 8x8 Mac patterns.
67// Bit=1 → fragment drawn (black foreground), bit=0 → fragment discarded (white background shows).
68// Mac QuickDraw convention: bit=1 = foreground (BLACK), bit=0 = background (WHITE).
69const byte kStippleLtGray[128] = {
70 // 0x88,0x22 alternating rows = 25% coverage (sparse dots)
71 0x88,0x88,0x88,0x88, 0x22,0x22,0x22,0x22, 0x88,0x88,0x88,0x88, 0x22,0x22,0x22,0x22,
72 0x88,0x88,0x88,0x88, 0x22,0x22,0x22,0x22, 0x88,0x88,0x88,0x88, 0x22,0x22,0x22,0x22,
73 0x88,0x88,0x88,0x88, 0x22,0x22,0x22,0x22, 0x88,0x88,0x88,0x88, 0x22,0x22,0x22,0x22,
74 0x88,0x88,0x88,0x88, 0x22,0x22,0x22,0x22, 0x88,0x88,0x88,0x88, 0x22,0x22,0x22,0x22,
75 0x88,0x88,0x88,0x88, 0x22,0x22,0x22,0x22, 0x88,0x88,0x88,0x88, 0x22,0x22,0x22,0x22,
76 0x88,0x88,0x88,0x88, 0x22,0x22,0x22,0x22, 0x88,0x88,0x88,0x88, 0x22,0x22,0x22,0x22,
77 0x88,0x88,0x88,0x88, 0x22,0x22,0x22,0x22, 0x88,0x88,0x88,0x88, 0x22,0x22,0x22,0x22,
78 0x88,0x88,0x88,0x88, 0x22,0x22,0x22,0x22, 0x88,0x88,0x88,0x88, 0x22,0x22,0x22,0x22,
79};
80
81const byte kStippleGray[128] = {
82 // 0xAA,0x55 alternating rows = 50% coverage (checkerboard)
83 0xAA,0xAA,0xAA,0xAA, 0x55,0x55,0x55,0x55, 0xAA,0xAA,0xAA,0xAA, 0x55,0x55,0x55,0x55,
84 0xAA,0xAA,0xAA,0xAA, 0x55,0x55,0x55,0x55, 0xAA,0xAA,0xAA,0xAA, 0x55,0x55,0x55,0x55,
85 0xAA,0xAA,0xAA,0xAA, 0x55,0x55,0x55,0x55, 0xAA,0xAA,0xAA,0xAA, 0x55,0x55,0x55,0x55,
86 0xAA,0xAA,0xAA,0xAA, 0x55,0x55,0x55,0x55, 0xAA,0xAA,0xAA,0xAA, 0x55,0x55,0x55,0x55,
87 0xAA,0xAA,0xAA,0xAA, 0x55,0x55,0x55,0x55, 0xAA,0xAA,0xAA,0xAA, 0x55,0x55,0x55,0x55,
88 0xAA,0xAA,0xAA,0xAA, 0x55,0x55,0x55,0x55, 0xAA,0xAA,0xAA,0xAA, 0x55,0x55,0x55,0x55,
89 0xAA,0xAA,0xAA,0xAA, 0x55,0x55,0x55,0x55, 0xAA,0xAA,0xAA,0xAA, 0x55,0x55,0x55,0x55,
90 0xAA,0xAA,0xAA,0xAA, 0x55,0x55,0x55,0x55, 0xAA,0xAA,0xAA,0xAA, 0x55,0x55,0x55,0x55,
91};
92
93// DOS FILLPATTERN 5 from METAWNDO.EXE: 12.5% foreground coverage.
94// The driver's 8x8 rows (88 00 22 00 88 00 22 00) are tiled to 32x32.
95const byte kDOSStipplePattern5[128] = {
96 0x88,0x88,0x88,0x88, 0x00,0x00,0x00,0x00, 0x22,0x22,0x22,0x22, 0x00,0x00,0x00,0x00,
97 0x88,0x88,0x88,0x88, 0x00,0x00,0x00,0x00, 0x22,0x22,0x22,0x22, 0x00,0x00,0x00,0x00,
98 0x88,0x88,0x88,0x88, 0x00,0x00,0x00,0x00, 0x22,0x22,0x22,0x22, 0x00,0x00,0x00,0x00,
99 0x88,0x88,0x88,0x88, 0x00,0x00,0x00,0x00, 0x22,0x22,0x22,0x22, 0x00,0x00,0x00,0x00,
100 0x88,0x88,0x88,0x88, 0x00,0x00,0x00,0x00, 0x22,0x22,0x22,0x22, 0x00,0x00,0x00,0x00,
101 0x88,0x88,0x88,0x88, 0x00,0x00,0x00,0x00, 0x22,0x22,0x22,0x22, 0x00,0x00,0x00,0x00,
102 0x88,0x88,0x88,0x88, 0x00,0x00,0x00,0x00, 0x22,0x22,0x22,0x22, 0x00,0x00,0x00,0x00,
103 0x88,0x88,0x88,0x88, 0x00,0x00,0x00,0x00, 0x22,0x22,0x22,0x22, 0x00,0x00,0x00,0x00,
104};
105
106const byte kStippleDkGray[128] = {
107 // 0x77,0xDD alternating rows = 75% coverage (dense dots)
108 0x77,0x77,0x77,0x77, 0xDD,0xDD,0xDD,0xDD, 0x77,0x77,0x77,0x77, 0xDD,0xDD,0xDD,0xDD,
109 0x77,0x77,0x77,0x77, 0xDD,0xDD,0xDD,0xDD, 0x77,0x77,0x77,0x77, 0xDD,0xDD,0xDD,0xDD,
110 0x77,0x77,0x77,0x77, 0xDD,0xDD,0xDD,0xDD, 0x77,0x77,0x77,0x77, 0xDD,0xDD,0xDD,0xDD,
111 0x77,0x77,0x77,0x77, 0xDD,0xDD,0xDD,0xDD, 0x77,0x77,0x77,0x77, 0xDD,0xDD,0xDD,0xDD,
112 0x77,0x77,0x77,0x77, 0xDD,0xDD,0xDD,0xDD, 0x77,0x77,0x77,0x77, 0xDD,0xDD,0xDD,0xDD,
113 0x77,0x77,0x77,0x77, 0xDD,0xDD,0xDD,0xDD, 0x77,0x77,0x77,0x77, 0xDD,0xDD,0xDD,0xDD,
114 0x77,0x77,0x77,0x77, 0xDD,0xDD,0xDD,0xDD, 0x77,0x77,0x77,0x77, 0xDD,0xDD,0xDD,0xDD,
115 0x77,0x77,0x77,0x77, 0xDD,0xDD,0xDD,0xDD, 0x77,0x77,0x77,0x77, 0xDD,0xDD,0xDD,0xDD,
116};
117
118// Lookup: MacPattern enum → GL stipple data pointer (null for solid/clear patterns)
119const byte *const kMacStippleData[] = {
120 nullptr, // kPatternWhite - solid white, no stipple
121 kStippleLtGray, // kPatternLtGray - 25% black dots
122 kStippleGray, // kPatternGray - 50% checkerboard
123 kStippleDkGray, // kPatternDkGray - 75% black
124 nullptr, // kPatternBlack - solid black, no stipple
125 nullptr // kPatternClear - outline only
126};
127
128// Helper: set up Mac color stipple rendering for a given cColor[] pattern.
129// Configures setMacColors/setStippleData/setWireframe for the pattern type.
130// Returns the stipple pointer (null for solid patterns) caller must clear with setStippleData(nullptr).
131inline const byte *setupMacPattern(Renderer *gfx, int pattern, uint32 fg, uint32 bg) {
132 const byte *stipple = (pattern >= 1 && pattern <= 3) ? kMacStippleData[pattern] : nullptr;
133 if (stipple) {
134 gfx->setMacColors(fg, bg);
135 gfx->setStippleData(stipple);
136 gfx->setWireframe(true, bg);
137 } else if (pattern == 4) {
138 // BLACK: solid fg fill
139 gfx->setWireframe(true, fg);
140 } else {
141 // WHITE (0): solid bg fill + fg outline
142 gfx->setWireframe(true, bg);
143 }
144 return stipple;
145}
146
147} // namespace Colony
148
149#endif // COLONY_RENDER_INTERNAL_H
Definition: rect.h:536