UbixOS  2.0
colours.cc
Go to the documentation of this file.
1 /*-
2  * Copyright (c) 2002-2018 The UbixOS Project.
3  * All rights reserved.
4  *
5  * This was developed by Christopher W. Olsen for the UbixOS Project.
6  *
7  * Redistribution and use in source and binary forms, with or without modification, are permitted
8  * provided that the following conditions are met:
9  *
10  * 1) Redistributions of source code must retain the above copyright notice, this list of
11  * conditions, the following disclaimer and the list of authors.
12  * 2) Redistributions in binary form must reproduce the above copyright notice, this list of
13  * conditions, the following disclaimer and the list of authors in the documentation and/or
14  * other materials provided with the distribution.
15  * 3) Neither the name of the UbixOS Project nor the names of its contributors may be used to
16  * endorse or promote products derived from this software without specific prior written
17  * permission.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
20  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
21  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
22  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
24  * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
26  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27  */
28 
29 #include <sde/sde.h>
30 #include <sde/ogDisplay_UbixOS.h>
31 #include <objgfx40/objgfx40.h>
32 
33 
34 #include <sys/video.h>
35 #include <vmm/paging.h>
36 #include <string.h>
37 #include <lib/kprintf.h>
38 #include <lib/kmalloc.h>
39 #include <ubixos/sched.h>
40 #include <ubixos/vitals.h>
41 
42  void sdeTestThread() {
43  ogSurface *screen = 0x0;
44  while (screen == 0x0) {
45  screen = (ogDisplay_UbixOS *) systemVitals->screen;
46  }
47  while (!screen->ogAvail())
48  ;
49 
50 ogSurface* background = new ogSurface();
51 background->ogClone(*screen); // same res and pixel format
52 for (int x = 0; x < 255; x++) {
53  for (int y = 0; y < 255; y++) {
54  for (int z = 0; z < 255; z++) {
55  //background->ogSetPixel((x+100-(z/2)) + g, (y+100) - g, background->ogPack(x, y, z));
56 //background->ogSetPixel(x+500-(z/2), y+z+25, background->ogPack(x, y, z));
57 //background->ogSetPixel(x+-(z/2)+(800-(256+128)), y+(z/2)+600-(256+128), background->ogPack(x, y, z));
58 background->ogSetPixel(x-(z/2)+(800-(256+128))/2, y+(z/2)+(600-(256+128))/2, background->ogPack(x, 255-y, z));
59  } // for z
60  } // for y
61 } // for x
62 screen->ogCopy(*background);
63 
64 while (1) {
65  sched_yield();
66 }
67 
68 }
69 
70 
72 // uInt32 count, i = 0x0;
73  uInt8 r, g, b;
74  ogSurface *screen = 0x0;
75  ogPoint2d points[4];
76  ogRGBA8 colours[4];
77  r = g = b = 0;
78  while (screen == 0x0) {
79  screen = (ogDisplay_UbixOS *) systemVitals->screen;
80  }
81  while (!screen->ogAvail())
82  ;
83 
84  points[0].x = screen->ogGetMaxX() - 150;
85  points[0].y = 0;
86  points[1].x = screen->ogGetMaxX();
87  points[1].y = 0;
88  points[2].x = screen->ogGetMaxX();
89  points[2].y = 150;
90  points[3].x = screen->ogGetMaxX() - 250;
91  points[3].y = 250;
92 
93  colours[0].red = 255;
94  colours[0].green = 0;
95  colours[0].blue = 0;
96  colours[0].alpha = 255;
97  colours[1].red = 0;
98  colours[1].green = 255;
99  colours[1].blue = 128;
100  colours[1].alpha = 255;
101  colours[2].red = 128;
102  colours[2].green = 255;
103  colours[2].blue = 128;
104  colours[2].alpha = 255;
105  colours[3].red = 63;
106  colours[3].green = 63;
107  colours[3].blue = 63;
108  colours[3].alpha = 255;
109  screen->ogSetAntiAliasing(true);
110 
111  while (true) {
112 #if 0
113  for (count = 150; count > 0; count--) {
114  screen->Line(screen->GetMaxX() / 2, screen->GetMaxY() / 2,
115  screen->GetMaxX(), count*8,
116  screen->RGB(r, g, b));
117  screen->FillCircle(screen->GetMaxX() - 50, 50, count,
118  screen->RGB(r, g, b));
119 
120 // screen->FillRect(screen->GetMaxX() - 50 - count, count,
121 // screen->GetMaxX() - count, 100 - count,
122 // screen->RGB(r, g, b));
123  r -= 8;
124  g += 8;
125  b -= 8;
126  } // for
127 #endif
128  screen->ogFillGouraudPolygon(4, points, colours);
129  //kprintf("colours(0)[0x%X]\n",colours[0]);
130  colours[0].red -= 8;
131  colours[0].green += 8;
132  colours[0].blue -= 8;
133  colours[1].red += 8;
134  colours[1].green += 8;
135  colours[1].blue -= 8;
136  colours[2].red += 8;
137  colours[2].green -= 8;
138  colours[2].blue += 8;
139  colours[3].red += 8;
140  colours[3].green += 8;
141  colours[3].blue += 8;
142 
143  } // while
144 
145  } // sdeTestThread
string.h
ogDisplay_UbixOS.h
video.h
sched.h
ogDisplay_UbixOS
Definition: ogDisplay_UbixOS.h:89
systemVitals
vitalsNode * systemVitals
Definition: vitals.c:35
sdeTestThreadOld
void sdeTestThreadOld()
Definition: colours.cc:71
kprintf.h
vitals.h
uInt8
unsigned char uInt8
Definition: objgfx30.h:47
paging.h
sde.h
vitalsStruct::screen
void * screen
Definition: vitals.h:47
kmalloc.h
sdeTestThread
void sdeTestThread()
Definition: colours.cc:42
sched_yield
void sched_yield()
Definition: sched.c:244