1 // Copyright 2016 The SwiftShader Authors. All Rights Reserved. 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 // Context.h: Defines the Context class, managing all GL state and performing 16 // rendering operations. It is the GLES2 specific implementation of EGLContext. 17 18 #ifndef LIBGLES_CM_CONTEXT_H_ 19 #define LIBGLES_CM_CONTEXT_H_ 20 21 #include "libEGL/Context.hpp" 22 #include "ResourceManager.h" 23 #include "common/NameSpace.hpp" 24 #include "common/Object.hpp" 25 #include "common/Image.hpp" 26 #include "Renderer/Sampler.hpp" 27 #include "common/MatrixStack.hpp" 28 29 #include <GLES/gl.h> 30 #include <GLES/glext.h> 31 #include <EGL/egl.h> 32 33 #include <map> 34 #include <string> 35 36 namespace gl { class Surface; } 37 38 namespace egl 39 { 40 class Display; 41 class Config; 42 } 43 44 namespace es1 45 { 46 struct TranslatedAttribute; 47 struct TranslatedIndexData; 48 49 class Device; 50 class Buffer; 51 class Texture; 52 class Texture2D; 53 class TextureExternal; 54 class Framebuffer; 55 class Renderbuffer; 56 class RenderbufferStorage; 57 class Colorbuffer; 58 class Depthbuffer; 59 class StreamingIndexBuffer; 60 class Stencilbuffer; 61 class DepthStencilbuffer; 62 class VertexDataManager; 63 class IndexDataManager; 64 65 enum 66 { 67 MAX_VERTEX_ATTRIBS = sw::MAX_VERTEX_INPUTS, 68 MAX_VARYING_VECTORS = 10, 69 MAX_TEXTURE_UNITS = 2, 70 MAX_DRAW_BUFFERS = 1, 71 MAX_LIGHTS = 8, 72 MAX_CLIP_PLANES = sw::MAX_CLIP_PLANES, 73 74 MAX_MODELVIEW_STACK_DEPTH = 32, 75 MAX_PROJECTION_STACK_DEPTH = 2, 76 MAX_TEXTURE_STACK_DEPTH = 2, 77 }; 78 79 const GLenum compressedTextureFormats[] = 80 { 81 GL_ETC1_RGB8_OES, 82 #if (S3TC_SUPPORT) 83 GL_COMPRESSED_RGB_S3TC_DXT1_EXT, 84 GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, 85 #endif 86 }; 87 88 const GLint NUM_COMPRESSED_TEXTURE_FORMATS = sizeof(compressedTextureFormats) / sizeof(compressedTextureFormats[0]); 89 90 const GLint multisampleCount[] = {4, 2, 1}; 91 const GLint NUM_MULTISAMPLE_COUNTS = sizeof(multisampleCount) / sizeof(multisampleCount[0]); 92 const GLint IMPLEMENTATION_MAX_SAMPLES = multisampleCount[0]; 93 94 const float ALIASED_LINE_WIDTH_RANGE_MIN = 1.0f; 95 const float ALIASED_LINE_WIDTH_RANGE_MAX = 1.0f; 96 const float ALIASED_POINT_SIZE_RANGE_MIN = 0.125f; 97 const float ALIASED_POINT_SIZE_RANGE_MAX = 8192.0f; 98 const float SMOOTH_LINE_WIDTH_RANGE_MIN = 1.0f; 99 const float SMOOTH_LINE_WIDTH_RANGE_MAX = 1.0f; 100 const float SMOOTH_POINT_SIZE_RANGE_MIN = 0.125f; 101 const float SMOOTH_POINT_SIZE_RANGE_MAX = 8192.0f; 102 const float MAX_TEXTURE_MAX_ANISOTROPY = 16.0f; 103 104 struct Color 105 { 106 float red; 107 float green; 108 float blue; 109 float alpha; 110 }; 111 112 struct Point 113 { 114 float x; 115 float y; 116 float z; 117 float w; 118 }; 119 120 struct Vector 121 { 122 float x; 123 float y; 124 float z; 125 }; 126 127 struct Attenuation 128 { 129 float constant; 130 float linear; 131 float quadratic; 132 }; 133 134 struct Light 135 { 136 bool enabled; 137 Color ambient; 138 Color diffuse; 139 Color specular; 140 Point position; 141 Vector direction; 142 Attenuation attenuation; 143 float spotExponent; 144 float spotCutoffAngle; 145 }; 146 147 // Helper structure describing a single vertex attribute 148 class VertexAttribute 149 { 150 public: VertexAttribute()151 VertexAttribute() : mType(GL_FLOAT), mSize(4), mNormalized(false), mStride(0), mPointer(nullptr), mArrayEnabled(false) 152 { 153 mCurrentValue[0] = 0.0f; 154 mCurrentValue[1] = 0.0f; 155 mCurrentValue[2] = 0.0f; 156 mCurrentValue[3] = 1.0f; 157 } 158 typeSize()159 int typeSize() const 160 { 161 switch(mType) 162 { 163 case GL_BYTE: return mSize * sizeof(GLbyte); 164 case GL_UNSIGNED_BYTE: return mSize * sizeof(GLubyte); 165 case GL_SHORT: return mSize * sizeof(GLshort); 166 case GL_UNSIGNED_SHORT: return mSize * sizeof(GLushort); 167 case GL_FIXED: return mSize * sizeof(GLfixed); 168 case GL_FLOAT: return mSize * sizeof(GLfloat); 169 default: UNREACHABLE(mType); return mSize * sizeof(GLfloat); 170 } 171 } 172 stride()173 GLsizei stride() const 174 { 175 return mStride ? mStride : typeSize(); 176 } 177 178 // From glVertexAttribPointer 179 GLenum mType; 180 GLint mSize; 181 bool mNormalized; 182 GLsizei mStride; // 0 means natural stride 183 184 union 185 { 186 const void *mPointer; 187 intptr_t mOffset; 188 }; 189 190 gl::BindingPointer<Buffer> mBoundBuffer; // Captured when glVertexAttribPointer is called. 191 192 bool mArrayEnabled; // From glEnable/DisableVertexAttribArray 193 float mCurrentValue[4]; // From glVertexAttrib 194 }; 195 196 typedef VertexAttribute VertexAttributeArray[MAX_VERTEX_ATTRIBS]; 197 198 struct TextureUnit 199 { 200 Color color; 201 GLenum environmentMode; 202 GLenum combineRGB; 203 GLenum combineAlpha; 204 GLenum src0RGB; 205 GLenum src0Alpha; 206 GLenum src1RGB; 207 GLenum src1Alpha; 208 GLenum src2RGB; 209 GLenum src2Alpha; 210 GLenum operand0RGB; 211 GLenum operand0Alpha; 212 GLenum operand1RGB; 213 GLenum operand1Alpha; 214 GLenum operand2RGB; 215 GLenum operand2Alpha; 216 }; 217 218 // Helper structure to store all raw state 219 struct State 220 { 221 Color colorClearValue; 222 GLclampf depthClearValue; 223 int stencilClearValue; 224 225 bool cullFaceEnabled; 226 GLenum cullMode; 227 GLenum frontFace; 228 bool depthTestEnabled; 229 GLenum depthFunc; 230 bool blendEnabled; 231 GLenum sourceBlendRGB; 232 GLenum destBlendRGB; 233 GLenum sourceBlendAlpha; 234 GLenum destBlendAlpha; 235 GLenum blendEquationRGB; 236 GLenum blendEquationAlpha; 237 bool stencilTestEnabled; 238 GLenum stencilFunc; 239 GLint stencilRef; 240 GLuint stencilMask; 241 GLenum stencilFail; 242 GLenum stencilPassDepthFail; 243 GLenum stencilPassDepthPass; 244 GLuint stencilWritemask; 245 bool polygonOffsetFillEnabled; 246 GLfloat polygonOffsetFactor; 247 GLfloat polygonOffsetUnits; 248 bool sampleAlphaToCoverageEnabled; 249 bool sampleCoverageEnabled; 250 GLclampf sampleCoverageValue; 251 bool sampleCoverageInvert; 252 bool scissorTestEnabled; 253 bool ditherEnabled; 254 GLenum shadeModel; 255 256 GLfloat lineWidth; 257 258 GLenum generateMipmapHint; 259 GLenum perspectiveCorrectionHint; 260 GLenum fogHint; 261 262 GLint viewportX; 263 GLint viewportY; 264 GLsizei viewportWidth; 265 GLsizei viewportHeight; 266 float zNear; 267 float zFar; 268 269 GLint scissorX; 270 GLint scissorY; 271 GLsizei scissorWidth; 272 GLsizei scissorHeight; 273 274 bool colorMaskRed; 275 bool colorMaskGreen; 276 bool colorMaskBlue; 277 bool colorMaskAlpha; 278 bool depthMask; 279 280 unsigned int activeSampler; // Active texture unit selector - GL_TEXTURE0 281 gl::BindingPointer<Buffer> arrayBuffer; 282 gl::BindingPointer<Buffer> elementArrayBuffer; 283 GLuint framebuffer; 284 gl::BindingPointer<Renderbuffer> renderbuffer; 285 286 VertexAttribute vertexAttribute[MAX_VERTEX_ATTRIBS]; 287 gl::BindingPointer<Texture> samplerTexture[TEXTURE_TYPE_COUNT][MAX_TEXTURE_UNITS]; 288 289 GLint unpackAlignment; 290 GLint packAlignment; 291 292 TextureUnit textureUnit[MAX_TEXTURE_UNITS]; 293 }; 294 295 class [[clang::lto_visibility_public]] Context : public egl::Context 296 { 297 public: 298 Context(egl::Display *display, const Context *shareContext, const egl::Config *config); 299 300 void makeCurrent(gl::Surface *surface) override; 301 EGLint getClientVersion() const override; 302 EGLint getConfigID() const override; 303 304 void finish() override; 305 306 void markAllStateDirty(); 307 308 // State manipulation 309 void setClearColor(float red, float green, float blue, float alpha); 310 void setClearDepth(float depth); 311 void setClearStencil(int stencil); 312 313 void setCullFaceEnabled(bool enabled); 314 bool isCullFaceEnabled() const; 315 void setCullMode(GLenum mode); 316 void setFrontFace(GLenum front); 317 318 void setDepthTestEnabled(bool enabled); 319 bool isDepthTestEnabled() const; 320 void setDepthFunc(GLenum depthFunc); 321 void setDepthRange(float zNear, float zFar); 322 323 void setAlphaTestEnabled(bool enabled); 324 bool isAlphaTestEnabled() const; 325 void setAlphaFunc(GLenum alphaFunc, GLclampf reference); 326 327 void setBlendEnabled(bool enabled); 328 bool isBlendEnabled() const; 329 void setBlendFactors(GLenum sourceRGB, GLenum destRGB, GLenum sourceAlpha, GLenum destAlpha); 330 void setBlendEquation(GLenum rgbEquation, GLenum alphaEquation); 331 332 void setStencilTestEnabled(bool enabled); 333 bool isStencilTestEnabled() const; 334 void setStencilParams(GLenum stencilFunc, GLint stencilRef, GLuint stencilMask); 335 void setStencilWritemask(GLuint stencilWritemask); 336 void setStencilOperations(GLenum stencilFail, GLenum stencilPassDepthFail, GLenum stencilPassDepthPass); 337 338 void setPolygonOffsetFillEnabled(bool enabled); 339 bool isPolygonOffsetFillEnabled() const; 340 void setPolygonOffsetParams(GLfloat factor, GLfloat units); 341 342 void setSampleAlphaToCoverageEnabled(bool enabled); 343 bool isSampleAlphaToCoverageEnabled() const; 344 void setSampleCoverageEnabled(bool enabled); 345 bool isSampleCoverageEnabled() const; 346 void setSampleCoverageParams(GLclampf value, bool invert); 347 348 void setShadeModel(GLenum mode); 349 void setDitherEnabled(bool enabled); 350 bool isDitherEnabled() const; 351 void setLightingEnabled(bool enabled); 352 bool isLightingEnabled() const; 353 void setLightEnabled(int index, bool enable); 354 bool isLightEnabled(int index) const; 355 void setLightAmbient(int index, float r, float g, float b, float a); 356 void setLightDiffuse(int index, float r, float g, float b, float a); 357 void setLightSpecular(int index, float r, float g, float b, float a); 358 void setLightPosition(int index, float x, float y, float z, float w); 359 void setLightDirection(int index, float x, float y, float z); 360 void setLightAttenuationConstant(int index, float constant); 361 void setLightAttenuationLinear(int index, float linear); 362 void setLightAttenuationQuadratic(int index, float quadratic); 363 void setSpotLightExponent(int index, float exponent); 364 void setSpotLightCutoff(int index, float cutoff); 365 366 void setGlobalAmbient(float red, float green, float blue, float alpha); 367 void setMaterialAmbient(float red, float green, float blue, float alpha); 368 void setMaterialDiffuse(float red, float green, float blue, float alpha); 369 void setMaterialSpecular(float red, float green, float blue, float alpha); 370 void setMaterialEmission(float red, float green, float blue, float alpha); 371 void setMaterialShininess(float shininess); 372 void setLightModelTwoSide(bool enable); 373 374 void setFogEnabled(bool enabled); 375 bool isFogEnabled() const; 376 void setFogMode(GLenum mode); 377 void setFogDensity(float fogDensity); 378 void setFogStart(float fogStart); 379 void setFogEnd(float fogEnd); 380 void setFogColor(float r, float g, float b, float a); 381 382 void setTexture2Denabled(bool enabled); 383 bool isTexture2Denabled() const; 384 void setTextureExternalEnabled(bool enabled); 385 bool isTextureExternalEnabled() const; 386 void clientActiveTexture(GLenum texture); 387 GLenum getClientActiveTexture() const; 388 unsigned int getActiveTexture() const; 389 390 void setTextureEnvMode(GLenum texEnvMode); 391 void setTextureEnvColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); 392 void setCombineRGB(GLenum combineRGB); 393 void setCombineAlpha(GLenum combineAlpha); 394 void setOperand0RGB(GLenum operand); 395 void setOperand1RGB(GLenum operand); 396 void setOperand2RGB(GLenum operand); 397 void setOperand0Alpha(GLenum operand); 398 void setOperand1Alpha(GLenum operand); 399 void setOperand2Alpha(GLenum operand); 400 void setSrc0RGB(GLenum src); 401 void setSrc1RGB(GLenum src); 402 void setSrc2RGB(GLenum src); 403 void setSrc0Alpha(GLenum src); 404 void setSrc1Alpha(GLenum src); 405 void setSrc2Alpha(GLenum src); 406 407 void setLineWidth(GLfloat width); 408 409 void setGenerateMipmapHint(GLenum hint); 410 void setPerspectiveCorrectionHint(GLenum hint); 411 void setFogHint(GLenum hint); 412 413 void setViewportParams(GLint x, GLint y, GLsizei width, GLsizei height); 414 415 void setScissorTestEnabled(bool enabled); 416 bool isScissorTestEnabled() const; 417 void setScissorParams(GLint x, GLint y, GLsizei width, GLsizei height); 418 419 void setColorMask(bool red, bool green, bool blue, bool alpha); 420 void setDepthMask(bool mask); 421 422 void setActiveSampler(unsigned int active); 423 424 GLuint getFramebufferName() const; 425 GLuint getRenderbufferName() const; 426 427 GLuint getArrayBufferName() const; 428 429 void setVertexAttribArrayEnabled(unsigned int attribNum, bool enabled); 430 const VertexAttribute &getVertexAttribState(unsigned int attribNum); 431 void setVertexAttribState(unsigned int attribNum, Buffer *boundBuffer, GLint size, GLenum type, 432 bool normalized, GLsizei stride, const void *pointer); 433 const void *getVertexAttribPointer(unsigned int attribNum) const; 434 435 const VertexAttributeArray &getVertexAttributes(); 436 437 void setUnpackAlignment(GLint alignment); 438 GLint getUnpackAlignment() const; 439 440 void setPackAlignment(GLint alignment); 441 GLint getPackAlignment() const; 442 443 // These create and destroy methods are merely pass-throughs to 444 // ResourceManager, which owns these object types 445 GLuint createBuffer(); 446 GLuint createTexture(); 447 GLuint createRenderbuffer(); 448 449 void deleteBuffer(GLuint buffer); 450 void deleteTexture(GLuint texture); 451 void deleteRenderbuffer(GLuint renderbuffer); 452 453 // Framebuffers are owned by the Context, so these methods do not pass through 454 GLuint createFramebuffer(); 455 void deleteFramebuffer(GLuint framebuffer); 456 457 void bindArrayBuffer(GLuint buffer); 458 void bindElementArrayBuffer(GLuint buffer); 459 void bindTexture2D(GLuint texture); 460 void bindTextureExternal(GLuint texture); 461 void bindFramebuffer(GLuint framebuffer); 462 void bindRenderbuffer(GLuint renderbuffer); 463 464 void setFramebufferZero(Framebuffer *framebuffer); 465 466 void setRenderbufferStorage(RenderbufferStorage *renderbuffer); 467 468 void setVertexAttrib(GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); 469 470 Buffer *getBuffer(GLuint handle); 471 virtual Texture *getTexture(GLuint handle); 472 Framebuffer *getFramebuffer(GLuint handle); 473 virtual Renderbuffer *getRenderbuffer(GLuint handle); 474 475 Buffer *getArrayBuffer(); 476 Buffer *getElementArrayBuffer(); 477 Texture2D *getTexture2D(); 478 TextureExternal *getTextureExternal(); 479 Texture *getSamplerTexture(unsigned int sampler, TextureType type); 480 Framebuffer *getFramebuffer(); 481 482 bool getFloatv(GLenum pname, GLfloat *params); 483 bool getIntegerv(GLenum pname, GLint *params); 484 bool getBooleanv(GLenum pname, GLboolean *params); 485 bool getPointerv(GLenum pname, const GLvoid **params); 486 487 int getQueryParameterNum(GLenum pname); 488 bool isQueryParameterInt(GLenum pname); 489 bool isQueryParameterFloat(GLenum pname); 490 bool isQueryParameterBool(GLenum pname); 491 bool isQueryParameterPointer(GLenum pname); 492 493 void drawArrays(GLenum mode, GLint first, GLsizei count); 494 void drawElements(GLenum mode, GLsizei count, GLenum type, const void *indices); 495 void drawTexture(GLfloat x, GLfloat y, GLfloat z, GLfloat width, GLfloat height); 496 void blit(sw::Surface *source, const sw::SliceRect &sRect, sw::Surface *dest, const sw::SliceRect &dRect) override; 497 void readPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLsizei *bufSize, void* pixels); 498 void clear(GLbitfield mask); 499 void flush(); 500 501 void recordInvalidEnum(); 502 void recordInvalidValue(); 503 void recordInvalidOperation(); 504 void recordOutOfMemory(); 505 void recordInvalidFramebufferOperation(); 506 void recordMatrixStackOverflow(); 507 void recordMatrixStackUnderflow(); 508 509 GLenum getError(); 510 511 static int getSupportedMultisampleCount(int requested); 512 513 void bindTexImage(gl::Surface *surface) override; 514 EGLenum validateSharedImage(EGLenum target, GLuint name, GLuint textureLevel) override; 515 egl::Image *createSharedImage(EGLenum target, GLuint name, GLuint textureLevel) override; 516 egl::Image *getSharedImage(GLeglImageOES image); 517 518 Device *getDevice(); 519 520 void setMatrixMode(GLenum mode); 521 void loadIdentity(); 522 void load(const GLfloat *m); 523 void pushMatrix(); 524 void popMatrix(); 525 void rotate(GLfloat angle, GLfloat x, GLfloat y, GLfloat z); 526 void translate(GLfloat x, GLfloat y, GLfloat z); 527 void scale(GLfloat x, GLfloat y, GLfloat z); 528 void multiply(const GLfloat *m); 529 void frustum(GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar); 530 void ortho(GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar); 531 532 void setClipPlane(int index, const float plane[4]); 533 void setClipPlaneEnabled(int index, bool enable); 534 bool isClipPlaneEnabled(int index) const; 535 536 void setColorLogicOpEnabled(bool enable); 537 bool isColorLogicOpEnabled() const; 538 void setLogicalOperation(GLenum logicOp); 539 540 void setPointSmoothEnabled(bool enable); 541 bool isPointSmoothEnabled() const; 542 543 void setLineSmoothEnabled(bool enable); 544 bool isLineSmoothEnabled() const; 545 546 void setColorMaterialEnabled(bool enable); 547 bool isColorMaterialEnabled() const; 548 549 void setNormalizeEnabled(bool enable); 550 bool isNormalizeEnabled() const; 551 552 void setRescaleNormalEnabled(bool enable); 553 bool isRescaleNormalEnabled() const; 554 555 void setVertexArrayEnabled(bool enable); 556 bool isVertexArrayEnabled() const; 557 558 void setNormalArrayEnabled(bool enable); 559 bool isNormalArrayEnabled() const; 560 561 void setColorArrayEnabled(bool enable); 562 bool isColorArrayEnabled() const; 563 564 void setPointSizeArrayEnabled(bool enable); 565 bool isPointSizeArrayEnabled() const; 566 567 void setTextureCoordArrayEnabled(bool enable); 568 bool isTextureCoordArrayEnabled() const; 569 570 void setMultisampleEnabled(bool enable); 571 bool isMultisampleEnabled() const; 572 573 void setSampleAlphaToOneEnabled(bool enable); 574 bool isSampleAlphaToOneEnabled() const; 575 576 void setPointSpriteEnabled(bool enable); 577 bool isPointSpriteEnabled() const; 578 void setPointSizeMin(float min); 579 void setPointSizeMax(float max); 580 void setPointDistanceAttenuation(float a, float b, float c); 581 void setPointFadeThresholdSize(float threshold); 582 583 private: 584 ~Context() override; 585 586 bool applyRenderTarget(); 587 void applyState(GLenum drawMode); 588 GLenum applyVertexBuffer(GLint base, GLint first, GLsizei count); 589 GLenum applyIndexBuffer(const void *indices, GLsizei count, GLenum mode, GLenum type, TranslatedIndexData *indexInfo); 590 void applyTextures(); 591 void applyTexture(int sampler, Texture *texture); 592 593 void detachBuffer(GLuint buffer); 594 void detachTexture(GLuint texture); 595 void detachFramebuffer(GLuint framebuffer); 596 void detachRenderbuffer(GLuint renderbuffer); 597 598 bool cullSkipsDraw(GLenum drawMode); 599 bool isTriangleMode(GLenum drawMode); 600 601 const egl::Config *const config; 602 603 State mState; 604 605 gl::BindingPointer<Texture2D> mTexture2DZero; 606 gl::BindingPointer<TextureExternal> mTextureExternalZero; 607 608 gl::NameSpace<Framebuffer> mFramebufferNameSpace; 609 610 VertexDataManager *mVertexDataManager; 611 IndexDataManager *mIndexDataManager; 612 613 bool lightingEnabled; 614 Light light[MAX_LIGHTS]; 615 Color globalAmbient; 616 Color materialAmbient; 617 Color materialDiffuse; 618 Color materialSpecular; 619 Color materialEmission; 620 GLfloat materialShininess; 621 bool lightModelTwoSide; 622 623 // Recorded errors 624 bool mInvalidEnum; 625 bool mInvalidValue; 626 bool mInvalidOperation; 627 bool mOutOfMemory; 628 bool mInvalidFramebufferOperation; 629 bool mMatrixStackOverflow; 630 bool mMatrixStackUnderflow; 631 632 bool mHasBeenCurrent; 633 634 // state caching flags 635 bool mDepthStateDirty; 636 bool mMaskStateDirty; 637 bool mBlendStateDirty; 638 bool mStencilStateDirty; 639 bool mPolygonOffsetStateDirty; 640 bool mSampleStateDirty; 641 bool mFrontFaceDirty; 642 bool mDitherStateDirty; 643 644 sw::MatrixStack ¤tMatrixStack(); 645 GLenum matrixMode; 646 sw::MatrixStack modelViewStack; 647 sw::MatrixStack projectionStack; 648 sw::MatrixStack textureStack0; 649 sw::MatrixStack textureStack1; 650 651 bool texture2Denabled[MAX_TEXTURE_UNITS]; 652 bool textureExternalEnabled[MAX_TEXTURE_UNITS]; 653 GLenum clientTexture; 654 655 int clipFlags; 656 657 bool alphaTestEnabled; 658 GLenum alphaTestFunc; 659 float alphaTestRef; 660 661 bool fogEnabled; 662 GLenum fogMode; 663 float fogDensity; 664 float fogStart; 665 float fogEnd; 666 Color fogColor; 667 668 bool lineSmoothEnabled; 669 bool colorMaterialEnabled; 670 bool normalizeEnabled; 671 bool rescaleNormalEnabled; 672 bool multisampleEnabled; 673 bool sampleAlphaToOneEnabled; 674 675 bool pointSpriteEnabled; 676 bool pointSmoothEnabled; 677 float pointSizeMin; 678 float pointSizeMax; 679 Attenuation pointDistanceAttenuation; 680 float pointFadeThresholdSize; 681 682 bool colorLogicOpEnabled; 683 GLenum logicalOperation; 684 685 Device *device; 686 ResourceManager *mResourceManager; 687 }; 688 } 689 690 #endif // INCLUDE_CONTEXT_H_ 691