2 * Copyright (C) 2005-2013 Team XBMC
5 * Test patterns designed by Ofer LaOr - hometheater.co.il
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 2, or (at your option)
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.
17 * You should have received a copy of the GNU General Public License
18 * along with XBMC; see the file COPYING. If not, see
19 * <http://www.gnu.org/licenses/>.
26 #include "system_gl.h"
27 #include "GUIWindowTestPatternGL.h"
29 CGUIWindowTestPatternGL::CGUIWindowTestPatternGL(void) : CGUIWindowTestPattern()
33 CGUIWindowTestPatternGL::~CGUIWindowTestPatternGL(void)
37 void CGUIWindowTestPatternGL::DrawVerticalLines(int top, int left, int bottom, int right)
40 glColor3f(m_white, m_white, m_white);
41 for (int i = left; i <= right; i += 2)
44 glVertex2d(i, bottom);
49 void CGUIWindowTestPatternGL::DrawHorizontalLines(int top, int left, int bottom, int right)
52 glColor3f(m_white, m_white, m_white);
53 for (int i = top; i <= bottom; i += 2)
61 void CGUIWindowTestPatternGL::DrawCheckers(int top, int left, int bottom, int right)
64 glColor3f(m_white, m_white, m_white);
65 for (int y = top; y <= bottom; y++)
67 for (int x = left; x <= right; x += 2)
78 void CGUIWindowTestPatternGL::DrawBouncingRectangle(int top, int left, int bottom, int right)
80 m_bounceX += m_bounceDirectionX;
81 m_bounceY += m_bounceDirectionY;
83 if ((m_bounceDirectionX == 1 && m_bounceX + TEST_PATTERNS_BOUNCE_SQUARE_SIZE == right) || (m_bounceDirectionX == -1 && m_bounceX == left))
84 m_bounceDirectionX = -m_bounceDirectionX;
86 if ((m_bounceDirectionY == 1 && m_bounceY + TEST_PATTERNS_BOUNCE_SQUARE_SIZE == bottom) || (m_bounceDirectionY == -1 && m_bounceY == top))
87 m_bounceDirectionY = -m_bounceDirectionY;
89 glColor3f(m_white, m_white, m_white);
90 glRecti(m_bounceX, m_bounceY, m_bounceX + TEST_PATTERNS_BOUNCE_SQUARE_SIZE, m_bounceY + TEST_PATTERNS_BOUNCE_SQUARE_SIZE);
93 void CGUIWindowTestPatternGL::DrawContrastBrightnessPattern(int top, int left, int bottom, int right)
95 int x5p = (int) (left + (0.05f * (right - left)));
96 int y5p = (int) (top + (0.05f * (bottom - top)));
97 int x12p = (int) (left + (0.125f * (right - left)));
98 int y12p = (int) (top + (0.125f * (bottom - top)));
99 int x25p = (int) (left + (0.25f * (right - left)));
100 int y25p = (int) (top + (0.25f * (bottom - top)));
101 int x37p = (int) (left + (0.375f * (right - left)));
102 int y37p = (int) (top + (0.375f * (bottom - top)));
103 int x50p = left + (right - left) / 2;
104 int y50p = top + (bottom - top) / 2;
105 int x62p = (int) (left + (0.625f * (right - left)));
106 int y62p = (int) (top + (0.625f * (bottom - top)));
107 int x75p = (int) (left + (0.75f * (right - left)));
108 int y75p = (int) (top + (0.75f * (bottom - top)));
109 int x87p = (int) (left + (0.875f * (right - left)));
110 int y87p = (int) (top + (0.875f * (bottom - top)));
111 int x95p = (int) (left + (0.95f * (right - left)));
112 int y95p = (int) (top + (0.95f * (bottom - top)));
114 m_blinkFrame = (m_blinkFrame + 1) % TEST_PATTERNS_BLINK_CYCLE;
116 // draw main quadrants
117 glColor3f(m_white, m_white, m_white);
118 glRecti(x50p, top, right, y50p);
119 glRecti(left, y50p, x50p, bottom);
123 glColor3f(m_white, m_white, m_white);
124 glVertex2d(left, y5p);
125 glVertex2d(x50p, y5p);
126 glVertex2d(x5p, top);
127 glVertex2d(x5p, y50p);
128 glVertex2d(x50p, y95p);
129 glVertex2d(right, y95p);
130 glVertex2d(x95p, y50p);
131 glVertex2d(x95p, bottom);
133 glColor3f(m_black, m_black, m_black);
134 glVertex2d(x50p, y5p);
135 glVertex2d(right, y5p);
136 glVertex2d(x5p, y50p);
137 glVertex2d(x5p, bottom);
138 glVertex2d(left, y95p);
139 glVertex2d(x50p, y95p);
140 glVertex2d(x95p, top);
141 glVertex2d(x95p, y50p);
144 // draw inner rectangles
145 glColor3f(m_white, m_white, m_white);
146 glRecti(x12p, y12p, x37p, y37p);
147 glRecti(x62p, y62p, x87p, y87p);
149 glColor3f(m_black, m_black, m_black);
150 glRecti(x62p, y12p, x87p, y37p);
151 glRecti(x12p, y62p, x37p, y87p);
153 // draw inner circles
154 if (m_blinkFrame < TEST_PATTERNS_BLINK_CYCLE / 2)
155 glColor3f(m_black + 0.05f, m_black + 0.05f, m_black + 0.05f);
157 glColor3f(0.0f, 0.0f, 0.0f); //BTB
158 DrawCircle(x25p, y75p, (y37p - y12p) / 3);
159 DrawCircle(x75p, y25p, (y37p - y12p) / 3);
161 if (m_blinkFrame < TEST_PATTERNS_BLINK_CYCLE / 2)
162 glColor3f(m_white - 0.05f, m_white - 0.05f, m_white - 0.05f);
164 glColor3f(1.0f, 1.0f, 1.0f); //WTW
165 DrawCircle(x25p, y25p, (y37p - y12p) / 3);
166 DrawCircle(x75p, y75p, (y37p - y12p) / 3);
169 void CGUIWindowTestPatternGL::DrawCircle(int originX, int originY, int radius)
174 int vectorY1 = originY;
175 int vectorX1 = originX;
177 glBegin(GL_TRIANGLES);
178 for (int i = 0; i <= 360; i++)
180 angle = (float)(((double)i)/57.29577957795135);
181 vectorX = (int) (originX + (radius*(float)sin((double)angle)));
182 vectorY = (int) (originY + (radius*(float)cos((double)angle)));
183 glVertex2d(originX, originY);
184 glVertex2d(vectorX1, vectorY1);
185 glVertex2d(vectorX, vectorY);
192 void CGUIWindowTestPatternGL::BeginRender()
194 glDisable(GL_TEXTURE_2D);
196 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
199 void CGUIWindowTestPatternGL::EndRender()
201 glEnable(GL_TEXTURE_2D);