wavelength 1.0.0
Loading...
Searching...
No Matches
psmat.h
Go to the documentation of this file.
1#pragma once
2
3#include <cstddef>
4
5#include "math/color.h"
6#include "math/transform.h"
7#include "math/vector3.h"
8#include "os/mem.h"
9#include "rnd/rndmat.h"
10
19class PsMat : public RndMat {
20public:
28 explicit PsMat(const char *pszName) : RndMat(pszName) {
29 }
30
35 ~PsMat() override {
36 }
37
44 void *operator new(size_t nSize) {
45 return PoolAlloc(static_cast<int>(nSize), sizeof(PsMat), "PsMat", 0);
46 }
47
53 void operator delete(void *pBlock) {
54 PoolFree(sizeof(PsMat), pBlock);
55 }
56
69 int Select(int nPass);
70
81 void SelectBlendMode(int nPass);
82
92 void SelectStageClamp(const Stage &stage);
93
104 int TexFunction(int nBlend);
105
115 void BindStageTexture(int nPass);
116
126 void SetupUvXfm(int nPass);
127
134 static void SelectDefault();
135
143 static void SelectAlphaBlend();
144
153 static void Init();
154
163 static RndObject *New(const char *pszName) {
164 return new PsMat(pszName);
165 }
166
174};
175
182extern int g_nSelectedGenMode;
183
190extern int g_nSelectedFlat;
191
198extern int g_nTextured;
199
206extern int g_nAlphaBlendEnabled;
207
214extern int g_nLightingEnabled;
215
223extern int g_nReselectBlend;
224
231extern Color g_colorScale;
232
238extern Transform g_uvXfm;
239
245extern Vector3 g_stageXfm[3];
void SetupUvXfm(int nPass)
Build the texture coordinate transform of a pass's stage into g_uvXfm and g_stageXfm.
int Select(int nPass)
Select one pass of the material for drawing.
~PsMat() override
Definition psmat.h:35
static void SelectAlphaBlend()
Blend by the source alpha, and make the next Select() of the selected material select its blend again...
void SelectBlendMode(int nPass)
Program the GS blend, dither, alpha test, and alpha correction for a pass.
int TexFunction(int nBlend)
Report the GS texture function a blend draws its texture with.
void BindStageTexture(int nPass)
Bind the texture of a pass's stage and set the colour scale for its texture function.
static RndObject * New(const char *pszName)
Create a material.
Definition psmat.h:163
static void SelectDefault()
Forget the selected material and return the GS to opaque drawing with the default dither.
void SelectStageClamp(const Stage &stage)
Clamp the texture coordinates of a stage, or let them repeat.
static void Init()
Install the material factory for the class Mat of a .rnd file.
PsMat(const char *pszName)
Construct a material.
Definition psmat.h:28
static PsMat * sCurrent
The material Select() last selected, or null.
Definition psmat.h:173
One texture stage.
Definition rndmat.h:61
RndMat(const char *pszName)
Construct an enabled material that blends by source alpha, with a black base colour,...
RndObject(const char *pszName)
Construct an object and register it under a name.
void * PoolAlloc(int nSize, int nBlockSize, const char *pszTag, int nUnused)
Allocate a block from the small-block pool and bill it to a tag.
void PoolFree(int nSize, void *pBlock)
Return a block to the small-block pool.
Transform g_uvXfm
Transform of the texture coordinates of the selected stage.
int g_nSelectedFlat
Flat shading flag of the selected material.
Vector3 g_stageXfm[3]
Basis rows of the stage transform a sphere-mapped stage applies before its sphere map.
Color g_colorScale
Scale from a vertex colour component to the GS range, 128 for a modulated texture and 255 otherwise,...
int g_nSelectedGenMode
Texture coordinate generation mode of the stage PsMat::SetupUvXfm() last processed.
int g_nAlphaBlendEnabled
Non-zero once ALPHA_1 is a blending equation rather than an opaque copy.
int g_nTextured
Non-zero while a stage texture is bound.
int g_nLightingEnabled
Lighting flag of the selected material, cleared when the stage texture is applied as a decal.
int g_nReselectBlend
Non-zero after PsMat::SelectAlphaBlend(), until the next PsMat::Select() of the selected material sel...
Linear colour with four float components.
Definition color.h:12
Affine transform stored as three basis rows and a translation row.
Definition transform.h:18
Three-component vector, padded to a PlayStation 2 quadword.
Definition vector3.h:14