PageRenderTime 14ms CodeModel.GetById 9ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 0ms

/opengles/src/RasterizerState.cpp

http://ftk.googlecode.com/
C++ | 98 lines | 41 code | 18 blank | 39 comment | 18 complexity | 53c3b502be7b1a4524ddba2b49405668 MD5 | raw file
 1// ==========================================================================
 2//
 3// RasterizerState	Rasterizer State Class for 3D Rendering Library
 4//
 5//					The rasterizer state maintains all the state information
 6//					that is necessary to determine the details of the
 7//					next primitive to be scan-converted.
 8//
 9// --------------------------------------------------------------------------
10//
11// 10-10-2003		Hans-Martin Will	initial version
12//
13// --------------------------------------------------------------------------
14//
15// Copyright (c) 2004, Hans-Martin Will. All rights reserved.
16// 
17// Redistribution and use in source and binary forms, with or without 
18// modification, are permitted provided that the following conditions are 
19// met:
20// 
21//	 *  Redistributions of source code must retain the above copyright
22// 		notice, this list of conditions and the following disclaimer. 
23//   *	Redistributions in binary form must reproduce the above copyright
24// 		notice, this list of conditions and the following disclaimer in the 
25// 		documentation and/or other materials provided with the distribution. 
26// 
27// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
28// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
29// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
30// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 
31// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, 
32// OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 
33// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
34// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
35// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
36// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 
37// THE POSSIBILITY OF SUCH DAMAGE.
38//
39// ==========================================================================
40
41
42#include "stdafx.h"
43#include "RasterizerState.h"
44
45
46using namespace EGL;
47
48
49RasterizerState :: RasterizerState():
50	m_ShadingModel(ShadeModelSmooth),
51	m_SampleCoverage(EGL_ONE),
52	m_InvertSampleCoverage(false)
53{
54}
55
56
57bool RasterizerState :: CompareCommon(const RasterizerState& other) const {
58	if (!(m_ShadingModel == other.m_ShadingModel)  ||
59		!(m_Fog == other.m_Fog) ||
60		!(m_DepthTest == other.m_DepthTest)) {
61		return false;
62	}
63
64	for (size_t unit = 0; unit < EGL_NUM_TEXTURE_UNITS; ++unit) {
65		if (!(m_Texture[unit] == other.m_Texture[unit]))
66			return false;
67	}
68
69	return
70		m_Mask == other.m_Mask &&
71		m_Alpha == other.m_Alpha &&
72		m_Blend == other.m_Blend &&
73		m_ScissorTest == other.m_ScissorTest &&
74		m_LogicOp == other.m_LogicOp &&
75		m_Stencil == other.m_Stencil &&
76
77		m_SampleCoverage == other.m_SampleCoverage &&
78		m_InvertSampleCoverage == other.m_InvertSampleCoverage;
79}
80
81
82bool RasterizerState :: ComparePoint(const RasterizerState& other) const {
83	return m_Point == other.m_Point &&
84		CompareCommon(other);
85}
86
87
88bool RasterizerState :: CompareLine(const RasterizerState& other) const {
89	return m_Line == other.m_Line &&
90		CompareCommon(other);
91}
92
93
94bool RasterizerState :: ComparePolygon(const RasterizerState& other) const {
95	return m_Polygon == other.m_Polygon &&
96		CompareCommon(other);
97}
98