Author Topic: Request: Setting background color  (Read 12861 times)

MikeHart

  • Guest
Request: Setting background color
« on: 2010-Feb-14 »
Hi folks,

There is BLACKSCREEN for automatically coloring the background black after each flip. Would be nice if there is something to set the background color to something else.

Thanks
Michael

Offline Ian Price

  • Administrator
  • Prof. Inline
  • *******
  • Posts: 4143
  • On the shoulders of giants.
    • View Profile
    • My Apps
Re: Request: Setting background color
« Reply #1 on: 2010-Feb-14 »
Well you can USEASBMP (after selecting a bitmap every clear screen will draw that image) or DRAWRECT at the start of every loop.
I came. I saw. I played.

MikeHart

  • Guest
Re: Request: Setting background color
« Reply #2 on: 2010-Feb-14 »
I know I could do that, but it slows down the framerate, which you don't have enough on the IPhone.

In OpenGL(ES) there exist a glClearColor command for this.

Offline Ian Price

  • Administrator
  • Prof. Inline
  • *******
  • Posts: 4143
  • On the shoulders of giants.
    • View Profile
    • My Apps
Re: Request: Setting background color
« Reply #3 on: 2010-Feb-14 »
Seriously? The framerate is affected by either of those? Just how shit is the iPhone? Both of these work without problem on GP2X and Wiz, which are technically inferior.
I came. I saw. I played.

Offline Schranz0r

  • Premium User :)
  • Administrator
  • Prof. Inline
  • *******
  • Posts: 5013
  • O Rly?
    • View Profile
Re: Request: Setting background color
« Reply #4 on: 2010-Feb-14 »
DRAWRECT!
I <3 DGArray's :D

PC:
AMD RYzen 7 1700 @3.9Ghz, 16GB HyperX Fury 2666Mhz Ram, ASUS ROG GTX 1060 STRIX 6GB, Windows 10 Pro 64Bit, MSi Tomahawk B350 Mainboard

Offline Moru

  • Administrator
  • Prof. Inline
  • *******
  • Posts: 1772
    • View Profile
    • Homepage
Re: Request: Setting background color
« Reply #5 on: 2010-Feb-14 »
You only need drawrect once to set the background color, then you use "USEASBMP" once and from that point the screen will be cleared to whatever was on the screen when you last called USEASBMP. It should not change the execution-speed of your game at all. (Unless the iPhone is even worse than I thought)

MikeHart

  • Guest
Re: Request: Setting background color
« Reply #6 on: 2010-Feb-14 »
Seriously? The framerate is affected by either of those? Just how shit is the iPhone? Both of these work without problem on GP2X and Wiz, which are technically inferior.

It's not shit! But as you can imagine yourself, drawing a 480x320 image each frame is some kind of overhead when you could get the same result with other functionality. Anyway, I just asked if something like this could be implemented.

We will see when the IPad will be available and someone will recomment drawing an 1024x768 image each frame.  :D

Offline Moru

  • Administrator
  • Prof. Inline
  • *******
  • Posts: 1772
    • View Profile
    • Homepage
Re: Request: Setting background color
« Reply #7 on: 2010-Feb-14 »
There is only one recommending drawing the box each frame, did you try the other ideas at all?

MikeHart

  • Guest
Re: Request: Setting background color
« Reply #8 on: 2010-Feb-14 »
There is only one recommending drawing the box each frame, did you try the other ideas at all?

Moru, thanks for your suggestion. No, I didn't try it because I know the result would be the same like a BLACKSCREEN, just with a different color. My inital request was because drawing a rectangle or an image with all the state changes that might be involved internally will be slower than other possible implementations. Its not a must but a nice to have. So lets end here.

Offline Ian Price

  • Administrator
  • Prof. Inline
  • *******
  • Posts: 4143
  • On the shoulders of giants.
    • View Profile
    • My Apps
Re: Request: Setting background color
« Reply #9 on: 2010-Feb-14 »
But it won't be slower. The USEASBMP command will change the black CLS to whatever bitmap or rectangle colour you choose. There will be NO impact on gamespeed. If you're getting 60FPS with just a showscreen now, you'd still get 60FPS when using USEASBMP before you're main loop.

You load or create an image and USEASBMP before your main loop, and that's it. All done. You never need to call it again.
I came. I saw. I played.

MikeHart

  • Guest
Re: Request: Setting background color
« Reply #10 on: 2010-Feb-15 »
So you are saying that BLACKSCREEN is basically a combination of drawing a black rectangle and USEASBMP?

Offline Moru

  • Administrator
  • Prof. Inline
  • *******
  • Posts: 1772
    • View Profile
    • Homepage
Re: Request: Setting background color
« Reply #11 on: 2010-Feb-15 »
Basicly yes. Try it and see if it does anything to the framerate on your target machine.

MikeHart

  • Guest
Re: Request: Setting background color
« Reply #12 on: 2010-Feb-15 »
If it act the same, then it won't be slower.

Offline Albert

  • Dr. Type
  • ****
  • Posts: 257
    • View Profile
    • Blog
Re: Request: Setting background color
« Reply #13 on: 2010-Feb-15 »
If you use any backbuffer instead of BLACKSCREEN, you get a lower framerate on PC as well. Try on a slow netbook as I do, and you will see.

Offline Kitty Hello

  • code monkey
  • Administrator
  • Prof. Inline
  • *******
  • Posts: 10689
  • here on my island the sea says 'hello'
    • View Profile
    • http://www.glbasic.com
Re: Request: Setting background color
« Reply #14 on: 2010-Feb-15 »
You're right. It totally sucks.
I'll make an optional parameter for the clear colour of BLACKSCREEN in a next update, OK?