OpenWindowedScreen colour
-
IdeasVacuum
- Always Here

- Posts: 6426
- Joined: Fri Oct 23, 2009 2:33 am
- Location: Wales, UK
- Contact:
OpenWindowedScreen colour
I thought there would be a simple way to do this: Change the OpenWindowedScreen colour from the default black to another colour of choice (Without disturbing the displayed entities).
I started off trying ClearScreen, for example ClearScreen(RGB($CC,$00,$00))
That does not do anything in terms of the screen colour so I tried a Billboard (Hide/UnHide) as a background. Sort of works but not satisfactory for my purpose. Surely this is a simple requirement.....? Is there a PB command specifically for this task that I have missed?
I started off trying ClearScreen, for example ClearScreen(RGB($CC,$00,$00))
That does not do anything in terms of the screen colour so I tried a Billboard (Hide/UnHide) as a background. Sort of works but not satisfactory for my purpose. Surely this is a simple requirement.....? Is there a PB command specifically for this task that I have missed?
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
If it sounds simple, you have not grasped the complexity.
Re: OpenWindowedScreen colour
clearscreen is the correct command, but to see it you need to flip the buffers (using flipbuffers(), strangely enough)
there is no sig, only zuul (and the following disclaimer)
WARNING: may be talking out of his hat
WARNING: may be talking out of his hat
Re: OpenWindowedScreen colour
In 3D use CameraBackColor()
Please correct my english
http://purebasic.developpez.com/
http://purebasic.developpez.com/
Re: OpenWindowedScreen colour
Why is that strange? You always draw on the hidden screen, which becomes only visibile after a FlipBuffers().citystate wrote:clearscreen is the correct command, but to see it you need to flip the buffers (using flipbuffers(), strangely enough)
( PB6.00 LTS Win11 x64 Asrock AB350 Pro4 Ryzen 5 3600 32GB GTX1060 6GB - upgrade incoming...)
( The path to enlightenment and the PureBasic Survival Guide right here... )
( The path to enlightenment and the PureBasic Survival Guide right here... )
Re: OpenWindowedScreen colour
is just my sense of humor - it's "strange" that to flip the buffers, you need to use flipbuffers(), in that it's not strange at all, but is stating the obvious on my part 
there is no sig, only zuul (and the following disclaimer)
WARNING: may be talking out of his hat
WARNING: may be talking out of his hat
-
IdeasVacuum
- Always Here

- Posts: 6426
- Joined: Fri Oct 23, 2009 2:33 am
- Location: Wales, UK
- Contact:
Re: OpenWindowedScreen colour
Hello chaps
Thanks to everyone for helping, so quickly too. I had to try a lot of permutations before finally getting the desired result. ClearScreen definitely not working with OpenWindowedScreen (for the purpose of changing the screen colour), but I get the impression from the PB sample files that it should be - perhaps a bug this time and not a Newbie oversight?
CameraBackColor does do the job
but only with supporting code as follows, which I hope will be of use to some other Newbie one day:
Thanks to everyone for helping, so quickly too. I had to try a lot of permutations before finally getting the desired result. ClearScreen definitely not working with OpenWindowedScreen (for the purpose of changing the screen colour), but I get the impression from the PB sample files that it should be - perhaps a bug this time and not a Newbie oversight?
CameraBackColor does do the job
Code: Select all
CameraBackColor(#Camera1, RGB(255, 255, 255)) ; White screen
RenderWorld()
FlipBuffers()
RenderWorld()
FlipBuffers()
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
If it sounds simple, you have not grasped the complexity.
-
IdeasVacuum
- Always Here

- Posts: 6426
- Joined: Fri Oct 23, 2009 2:33 am
- Location: Wales, UK
- Contact:
Re: OpenWindowedScreen colour
....but, tiny issue in that the new screen colour is not applied to the last horizontal line of pixels. Being a Newbie, most problems are home-made of course but my gut feeling says it possibly isn't me this time..... :roll:
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
If it sounds simple, you have not grasped the complexity.
Re: OpenWindowedScreen colour
this code work fine
Code: Select all
InitEngine3D()
InitSprite()
InitKeyboard()
w = 800
h = 600
OpenWindow(0, 0, 0, w, h, "Test", #PB_Window_SystemMenu)
OpenWindowedScreen(WindowID(0), 0, 0, w, h, 0, 0, 0, #PB_Screen_NoSynchronization)
CreateCamera(0, 0, 0, 100, 100)
CameraBackColor(0, RGB(255,255,255))
Repeat
Repeat
Event = WindowEvent()
If Event = #PB_Event_CloseWindow
Quit = 1
EndIf
Until Event
ExamineKeyboard()
RenderWorld()
FlipBuffers()
Until KeyboardPushed(#PB_Key_Escape) Or Quit = 1Please correct my english
http://purebasic.developpez.com/
http://purebasic.developpez.com/
-
IdeasVacuum
- Always Here

- Posts: 6426
- Joined: Fri Oct 23, 2009 2:33 am
- Location: Wales, UK
- Contact:
Re: OpenWindowedScreen colour
Hi Comtois
...In my project, the problem manifests when the OpenWindowedScreen is set as re-sizable, it is smaller than the Parent Window (which has a Status Bar) and there is a Mesh Entity displayed. I see the issue when the screen colour is changed on-the-fly.
However, there must be a bug in my code. When my window is displayed, the OpenWindowedScreen is "displayed", but as though it were greyed-out. As soon as an Entity is loaded, the screen is displayed with the correct colour and from then on everything behaves as expected.
If I edit your sample code so that it is more similar to my project, it still works absolutely fine and the screen is displayed correctly from the get-go:
Nothing to worry about but it is "another strange thing".
...In my project, the problem manifests when the OpenWindowedScreen is set as re-sizable, it is smaller than the Parent Window (which has a Status Bar) and there is a Mesh Entity displayed. I see the issue when the screen colour is changed on-the-fly.
However, there must be a bug in my code. When my window is displayed, the OpenWindowedScreen is "displayed", but as though it were greyed-out. As soon as an Entity is loaded, the screen is displayed with the correct colour and from then on everything behaves as expected.
If I edit your sample code so that it is more similar to my project, it still works absolutely fine and the screen is displayed correctly from the get-go:
Code: Select all
Global igCurrentColour = 0
Declare ScreenColour()
#Window = 0
#Camera1 = 1
#Btn = 2
#StatusBar = 3
InitEngine3D()
InitSprite()
InitKeyboard()
w = 800
h = 600
OpenWindow(#Window, 0, 0, w, h, "Test", #PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget | #PB_Window_SizeGadget | #PB_Window_ScreenCentered)
SetWindowColor(#Window, RGB(185,190,225))
CreateStatusBar(#StatusBar, WindowID(#Window))
ButtonGadget(#Btn, 10, 10, 100, 24, "Screen Colour")
OpenWindowedScreen(WindowID(#Window), 50, 50, w-100, h-100, 1, 5, 30, #PB_Screen_NoSynchronization)
CreateCamera(#Camera1, 0, 0, 100, 100)
CameraBackColor(#Camera1, igCurrentColour)
CameraProjectionMode(#Camera1, #PB_Camera_Perspective)
CameraLocate(#Camera1, 0, 0, 300)
Repeat
Repeat
Event = WindowEvent()
iGadgetID = EventGadget()
If Event = #PB_Event_CloseWindow
Quit = 1
ElseIf Event = #PB_Event_Gadget
If iGadgetID = #Btn : ScreenColour() : EndIf
EndIf
Until Event
ExamineKeyboard()
RenderWorld()
FlipBuffers()
Until KeyboardPushed(#PB_Key_Escape) Or Quit = 1
Procedure ScreenColour()
;-----------------------
iNewColour = ColorRequester(igCurrentColour)
CameraBackColor(#Camera1, iNewColour)
igCurrentColour = iNewColour
EndProcedure
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
If it sounds simple, you have not grasped the complexity.
-
IdeasVacuum
- Always Here

- Posts: 6426
- Joined: Fri Oct 23, 2009 2:33 am
- Location: Wales, UK
- Contact:
Re: OpenWindowedScreen colour
....even stranger now because I can't get the fault to re-occur and I haven't changed the code!
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
If it sounds simple, you have not grasped the complexity.
- Kaeru Gaman
- Addict

- Posts: 4826
- Joined: Sun Mar 19, 2006 1:57 pm
- Location: Germany
Re: OpenWindowedScreen colour
one essential mistake:
your inner loop repeats until an event occurs.
this is the wrong way round:
it needs to repeat until NO event occurs. (read the examples more carefully)
so, change this line toand try again.
plus for the future, please mention in your postings when you use Engine3D.
from your first posts I was getting the impression it's a problem on the WindowedScreen without 3D.
Code: Select all
Until Event this is the wrong way round:
it needs to repeat until NO event occurs. (read the examples more carefully)
so, change this line to
Code: Select all
Until Event = #Null plus for the future, please mention in your postings when you use Engine3D.
from your first posts I was getting the impression it's a problem on the WindowedScreen without 3D.
oh... and have a nice day.
-
IdeasVacuum
- Always Here

- Posts: 6426
- Joined: Fri Oct 23, 2009 2:33 am
- Location: Wales, UK
- Contact:
Re: OpenWindowedScreen colour
Hello Kaeru
Yes, I should have mentioned using Engine3D because program behavior is different when using it
, sorry. Another issue is the expectations of the environment. I'm not coding-up a game, I'm using PB to make some small apps for engineers and designers. I have a ton of CAD-CAM experience for engineering, using pretty hefty applications, so I tend to think in terms of what I can do when programming for them. When programing in C, you do find yourself re-inventing the wheel a bit. PB is much easier, so much is already done for you, but I'm finding I get caught-out sometimes because the PB ease of use triggers a shut-down of my other brain cell 
True, but Comtois just threw the example together to show me that Camera Back Colour does work. There are many things in there that you would not have in your 'real' code. Of course for programming Newbies it could add to their confusion, though the help is pretty adamant about many important issues. What I do find on this forum is that more experienced Users like yourself are very kind with the amount of time you spend helping others. I try to be so too on forums for other languages but the PB forum experts are way ahead of the norm.Until Event
Yes, I should have mentioned using Engine3D because program behavior is different when using it
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
If it sounds simple, you have not grasped the complexity.
- Kaeru Gaman
- Addict

- Posts: 4826
- Joined: Sun Mar 19, 2006 1:57 pm
- Location: Germany
Re: OpenWindowedScreen colour
if you have a ton of CAD-CAM experience, you should perhaps also check out the other 3D Engines that could be set upon PB (Irrlicht, DreaMotion),
and have a look at NickTheQuick's RealTime Raytracing (it's a work in progress).
what I somethimes thought about was taking PureBasic for creating a script with solid primitives descriptions, and render the Pictures with POVRay.
sure, you also need practicing programming, but these may show you additional ways to obtain different goals.
POVRay is not suitable for realtime, but you can create posters with it, something that would look shitty with some standard D3D rendering.
and have a look at NickTheQuick's RealTime Raytracing (it's a work in progress).
what I somethimes thought about was taking PureBasic for creating a script with solid primitives descriptions, and render the Pictures with POVRay.
sure, you also need practicing programming, but these may show you additional ways to obtain different goals.
POVRay is not suitable for realtime, but you can create posters with it, something that would look shitty with some standard D3D rendering.
oh... and have a nice day.

