Jump to content

C++ and graphics

Featured Replies

I have taken two, year long, highschool classes in programming, one was C++ at the basic level, the other was Java at the AP level. During my second year I wanted to make a program that just displays cool moving graphics things in lots of colors. Something similar can be seen in the "we'll be back soon" screen for That 70's Show, or as "plasma" (i think) in a package called "really slick screensavers".

 

The way I went about doing it was to make a bunch of randomly moving Bezier curves that were random colors(in c++). I was going to flood fill the space between them with their respective colors and use an algorithm to make it fade smoothly from one to the other. But i couldnt get my flood fill fast enough. I tried doing it pixel by pixel, both recursively and non, and I tried checking how much space between one edge and the next and doing a line instead of pixels. both were MUCH slower than I would need, so I was left wondering how they do things like video games, and if that's too complicated, I was wondering if there is a way to do what I was trying to do a bit faster than one frame every forty seconds or so. Is there some technique they use to do such things? I would think it would be a relatively simple matter to flood fill a blank area on a screen. After all, paint does it in about a half a second.

 

Any hints?

Any hints?

well yes, but you're not going to like it.... spend years becoming a games programmer and you'll find out!

 

well im not sure about programing it, but you could do this kinda of thing on an animation program (such as flash mx) which makes video files - or you could use a program which can produce .gif files, which can be animated and also used for background wallpapers and such - although they will slow down the computer.

  • Author

pffft.

 

thanks for the info, but i really want to know if there is an efficient way to program it. also, it needs to be random, no go on the animated gif.

well there obviously is, think of the default windows screensavers where they just have random things changing colour, however i believe that the colour moves in sequence, although a random colour generator could somehow be made.

  • Author
well there obviously is, think of the default windows screensavers where they just have random things changing colour, however i believe that the colour moves in sequence, although a random colour generator could somehow be made.

 

i can get the randomly moving things, i can make them random colors, i can make the colors randomly fade from one to the other. its the flood fill function im having trouble with. i cant make it fill a space in less than about 30 secs(depending on the size of the space obviously). keep in mind the space were talking about isnt square, doesnt have straight edges, and can be any size. how does paint do it so quickly?

paint is soo much simpler. in paint you are filling a limited space with a specified colour, there are obvious and fixed boudaries to the single specified colour the gap is being filled.... whereas for your thing, theres a random colour filling a randomly changing space with random colours, theres so much random and so little certain it takes longer to work out -- im guessing, i cant see any other reasoning for it anyway.

  • Author

actually when its filling in the space nothing is moving and no colors are changing. it moves the curves, fills them in with that color, then moves and color shifts again. there are no changes taking place while its filling in the pixels.

Try a professional graphics library like LEDA or OpenGL, thats what I use currently.

  • Author
Try a professional graphics library like LEDA or OpenGL, thats what I use currently.

 

ill give it a shot, but i really want to know how to do this stuff. how do you make a flood fill efficient enough to use for something like that?

Winamp has a function that allows you to create your own AVs, you might want to open the source to winamp and see how they do it :)

I thought you might know that mate. It can obviously be done

  • Author
I thought you might know that mate. It can obviously be done

 

i have an ok understanding of many aspects of a computer, but not ones that would require me to be a "leet haxxor" sorry.

ill give it a shot, but i really want to know how to do this stuff. how do you make a flood fill efficient enough to use for something like that?

 

There could be some hi-concept algos to do it. These libraries generally contain super efficient implementations of stuff.

I guess for things like DirectX and OpenGL the most efficient bits of coding (like flood filling) are probably done using something like assembly or some extremely fast interpreted language. Same for things like memory allocation, etc.

Archived

This topic is now archived and is closed to further replies.

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.