This project is read-only.


Oct 10, 2010 at 5:40 AM

You may have seen many (many) people ask about GUIs, and so have I. This leads me to wonder, "Did I help spark some of the interest?"

Last year, I created my own GUI for Cosmos. It was kinda cool, but did nothing, because it was a GUI without an OS. (yeah, I program backwards...)

My two YouTube videos (under the account MrErtnerd) displaying my simple little GUI have a combined view count of 5,695. (What??? [at least it isn't over 9000])

Anyway, now I plan on making a reliable DOS like OS first, then making a GUI for that.  I've read around that someone else here is making a GUI. (It will probably be coded better than mine.)

What are you plans and future projects with Cosmos?

Oct 10, 2010 at 9:02 PM

who is this person ur talking about? lol

btw how did the screen buffer work? xD

Oct 11, 2010 at 12:16 AM

really really really well. =D got about 16 fps on a virtual machine without a flickering screen, and I think 76 or so fps on real hardware (I think.. It's been a year)

oh, and if you meant the mechanics,

I just had an array 'uint[] screenbuffer' that I wrote to (where 'screenbuffer[1] = 2' would be color #2 on pixel x=1, y=0.) That way I don't call Screen.SetPixel320x200x8() for every pixel twice.

Then I had a function that sent all the data from the screenbuffer[y * 320 + x] array to Screen.SetPixel320x200x8(x, y, color);

screenbuffer[z] = color, when z = (y * maxScreenSizeX + x) is a pretty good way of storing color values in just one variable per pixel.
and with some loops, you can make a simple fillRectangle  function, or even a bitmap image renderer.


(I hope that makes sense...)

Oct 11, 2010 at 3:52 AM

seriously  over 70 fps before it flicered. nice my idea of having an os that can run fast enough for movies might not just be a dream

Oct 11, 2010 at 3:56 AM
Edited Oct 11, 2010 at 4:00 AM

That's the power of love! real hardware.


I just realized that if you actually replace 'love' with 'real hardware' in that song, it actually works... 

(yes, that was off topic) 

Oct 11, 2010 at 7:30 PM

lol @ random song part xD

but i still dont get how the screenbuffer works

Oct 11, 2010 at 8:30 PM

lol so instead of using y for ur buffer u just use the line number like 4 times it by 360 and add the x for the pixel ur working on and thats how ur array would store the code. thats pretty cool but u can also use a jagged array like

uint[] screen = { new uint[] { pixels for line one}, new uint[] { pixels for line two}} and just keep anding new uint[]s until u had all ur lines and then to call a loaction it would be like

screen[0][0] for the first pixel of the first line

then screen[5][7] for the 8th pixel on the 6th line

im noth sure it works better but it works.

what do u mean by calling setpixel for each one twice tho

Oct 12, 2010 at 1:20 AM

say you have two rectangles that overlap each other. 

__|          |
|    |         |
|    |____|

if you have:

fillRectangle(uint x, uint  y, uint width, uint height, uint color)
{ ... Screen.SetPixel320x200x8(x, y, color) ... }

For the areas that overlap in the two rectangles, you use the SetPixel function twice.
Thus, some pixels will be written to twice. (which can really slow you down.)

The idea with the buffer is that you just assign a number in an array twice, instead of updating the screen twice.
(it takes less time to write to the buffer array than to use the SetPixel function.)

Then when it comes time to actually write to the screen, the SetPixel function is only used once per pixel, which saves a lot of time, speeds up your graphics, AND prevents the horrid screen flicker between updates. 

As for the jagged array... I've never heard of them! D=  If only I knew then, the troubles I could have avoided (if Cosmos supports them.) 
Thank you for bringing this to my attention, and teaching me a new trick. :D  (I have known C# for a few years now, and had learned from a For Dummies book that I stopped reading half-way through.)

Oct 12, 2010 at 5:03 AM

yah cosmos supports them and i understand what u mean now and i might have to implement it but i got ride of most of the problem my self

but with the screen buffer u would have to like test each pixel in the buffer with the current pixel or a un updated buffer version if u wanted to do it with out updating the entire screen each time and that would take aprox 64000 if statements obviouslty in a loop (1 for each pixel) which would be really slow much slower than drawing the same pixel twice

or do u have an array that stores the updated pixels

but the way i do it is to simply undraw a shape if i need to get rid of it and not clear the screen.

Oct 16, 2010 at 10:49 PM
Edited Oct 16, 2010 at 10:50 PM

how to use keyboard and mouse together in Cosmos.


           like in Notepad the Mouse still works while keyboard input is being entered.

          I would like to create the same effect for a Text Editor in my Cosmos OS.


Oct 18, 2010 at 2:50 AM

simply put tests / updates for ur mouse and keyboard in the same loop

Oct 22, 2010 at 9:16 PM

When i put them both in the same loop I have to press a Key and Move the mouse at the same time. I cannot use one with using the order.

Oct 23, 2010 at 4:54 AM

Remove the while loop in Cosmos.Hardware.Keyboard.ReadChar()

//This is the function you are looking for.
public char ReadChar() {
            char xResult = '\0';
            while (mBuffer.Count == 0 || !GetCharValue(mBuffer.Dequeue(), out xResult)) {
                //Global.Sleep(10); //ToDo optimize value
            return xResult;


or just remove Core.Global.CPU.Halt(); from the loop.

But now you will be flooded with null characters.

Or you can write some new fancy function that won't flood you with empty characters. Just have fun with it.