Hash :
dbb9c534
Author :
Date :
2018-02-25T19:58:24
GLES1: state: Define / initialize GLES1-specific states Contains definitions of GLES1-specific states such as material / lighting. Tweaked the Color class for easier copying to uniforms / reading as a float array. This CL also adds the GLES1-specific state in GLES1State, which is then part of the State class and is initialized to the spec's values if the context major version is ES 1. + Some clang-format BUG=angleproject:2306 Change-Id: I7fc3bd9a22ebf0ffcd98d931d0176f21e17b1c5c Reviewed-on: https://chromium-review.googlesource.com/936424 Commit-Queue: Lingfeng Yang <lfy@google.com> Reviewed-by: Corentin Wallez <cwallez@chromium.org>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198
//
// Copyright 2018 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// GLES1State.h: Defines the GLES1State class holding the state of
// a GLES1 context.
#ifndef LIBANGLE_GLES1STATE_H_
#define LIBANGLE_GLES1STATE_H_
#include <unordered_set>
#include "common/angleutils.h"
#include "common/matrix_utils.h"
#include "common/vector_utils.h"
#include "libANGLE/angletypes.h"
namespace gl
{
// State types specific to GLES1 contexts, from the OpenGL ES 1.1 spec "State Tables" section
struct TextureCoordF
{
GLfloat s = 0.0f;
GLfloat t = 0.0f;
GLfloat r = 0.0f;
GLfloat q = 0.0f;
};
struct MaterialParameters
{
ColorF ambient;
ColorF diffuse;
ColorF specular;
ColorF emissive;
GLfloat specularExponent;
};
struct LightModelParameters
{
ColorF color;
bool twoSided;
};
struct LightParameters
{
bool enabled = false;
ColorF ambient = {0.0f, 0.0f, 0.0f, 1.0f};
ColorF diffuse = {0.0f, 0.0f, 0.0f, 1.0f};
ColorF specular = {0.0f, 0.0f, 0.0f, 1.0f};
angle::Vector4 position = {0.0f, 0.0f, 1.0f, 0.0f};
angle::Vector3 direction = {0.0f, 0.0f, -1.0f};
GLfloat spotlightExponent = 0.0f;
GLfloat spotlightCutoffAngle = 180.0f;
GLfloat attenuationConst = 1.0f;
GLfloat attenuationLinear = 0.0f;
GLfloat attenuationQuadratic = 0.0f;
};
struct FogParameters
{
FogMode mode;
GLfloat density;
GLfloat start;
GLfloat end;
ColorF color;
};
struct TextureEnvironmentParameters
{
TextureEnvMode envMode = TextureEnvMode::Modulate;
TextureCombine combineRgb = TextureCombine::Modulate;
TextureCombine combineAlpha = TextureCombine::Modulate;
TextureSrc src0rgb = TextureSrc::Texture;
TextureSrc src0alpha = TextureSrc::Texture;
TextureSrc src1rgb = TextureSrc::Previous;
TextureSrc src1alpha = TextureSrc::Previous;
TextureSrc src2rgb = TextureSrc::Constant;
TextureSrc src2alpha = TextureSrc::Constant;
TextureOp op0rgb = TextureOp::SrcColor;
TextureOp op0alpha = TextureOp::SrcAlpha;
TextureOp op1rgb = TextureOp::SrcColor;
TextureOp op1alpha = TextureOp::SrcAlpha;
TextureOp op2rgb = TextureOp::SrcAlpha;
TextureOp op2alpha = TextureOp::SrcAlpha;
ColorF envColor = {0.0f, 0.0f, 0.0f, 0.0f};
GLfloat rgbScale = 1.0f;
GLfloat alphaScale = 1.0f;
bool pointSpriteCoordReplace = false;
};
struct PointParameters
{
GLfloat pointSizeMin;
GLfloat pointSizeMax;
GLfloat pointFadeThresholdSize;
angle::Vector3 pointDistanceAttenuation;
GLfloat pointSize;
};
class Context;
class GLES1State final : angle::NonCopyable
{
public:
GLES1State();
~GLES1State();
void initialize(const Context *context);
private:
// All initial state values come from the
// OpenGL ES 1.1 spec.
struct TextureEnables
{
bool enable2D = false;
bool enableCubeMap = false;
};
std::vector<TextureEnables> mTexUnitEnables;
// Table 6.4, 6.5 (IsEnabled)
bool mVertexArrayEnabled;
bool mNormalArrayEnabled;
bool mColorArrayEnabled;
bool mPointSizeArrayEnabled;
std::vector<bool> mTexCoordArrayEnabled;
// Table 6.7-6.16 (IsEnabled)
std::vector<bool> mClipPlaneEnabled;
bool mLineSmoothEnabled;
bool mPointSmoothEnabled;
bool mPointSpriteEnabled;
bool mAlphaTestEnabled;
bool mLogicOpEnabled;
bool mLightingEnabled;
bool mFogEnabled;
bool mRescaleNormalEnabled;
bool mNormalizeEnabled;
bool mColorMaterialEnabled;
bool mReflectionMapEnabled;
// Table 6.3
ColorF mCurrentColor;
angle::Vector3 mCurrentNormal;
std::vector<TextureCoordF> mCurrentTextureCoords;
// Table 6.7
using MatrixStack = std::vector<angle::Mat4>;
MatrixType mCurrMatrixMode;
MatrixStack mProjMatrices;
MatrixStack mModelviewMatrices;
std::vector<MatrixStack> mTextureMatrices;
// Table 6.15
using TextureEnvironments = std::vector<TextureEnvironmentParameters>;
TextureEnvironments mTextureEnvironments;
// Table 6.9, 2.8
MaterialParameters mMaterial;
LightModelParameters mLightModel;
// Table 6.10
std::vector<LightParameters> mLights;
// Table 6.8
FogParameters mFog;
ShadingModel mShadeModel;
// Table 6.11
PointParameters mPointParameters;
// Table 6.16
AlphaTestFunc mAlphaFunc;
GLfloat mAlphaTestRef;
LogicalOperation mLogicOp;
// Table 6.7
std::vector<angle::Vector4> mClipPlanes;
// Table 6.19
HintSetting mLineSmoothHint;
HintSetting mPointSmoothHint;
HintSetting mPerspectiveCorrectionHint;
HintSetting mFogHint;
};
} // namespace gl
#endif // LIBANGLE_GLES1STATE_H_