News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

OpenGL - fullscreen or windowed? Any difference?

Started by hamper, November 19, 2013, 08:56:55 AM

Previous topic - Next topic

hamper

Hi Siekmanski, and many thanks for the info. Yes, I had a look at the NeHe tutorials, and they seem pretty good. He seems to get fullscreen using the ChangeDisplaySettings and DEVMODE way (see below), but I'll certainly be a regular visitor to his site. Lots of good examples there.

And my thanks to everyone else for their advice and links etc.

Well, I messed about ad-nauseum with all of these...

   Display device structures
   EnumDisplayDevicesA
   DEVMODE structures
   ChangeDisplaySettingsA
   ChangeDisplaySettingsExA

   ...and found that I didn't actually need ANY of them!

I haven't noticed any difference whatsoever, in either quality or rendering speed, between using all the above methods to get fullscreen, and just using good old CreateWindowExA with different parameters to get fullscreen (as per the example attached).

The attached examples include:
   opengl.exe and opengl.asm, the small windowed version
   openglfs.exe and openglfs.asm, the fullscreen version

I've included some salient comments in the openglfs.asm file, so you should be able to reconfigure it to suit. Also to help out those who prefer symbolic constants to plain old numbers :t

When running fullscreen, I'm finding it uses anywhere between 0% and 5% cpu, the average seems to be about 2% cpu.

I guess display lists would be the next obvious step. Should speed things up a bit more I hope. Maybe hints as well, as suggested by vertograd.


dedndave

i think full-screen is only advantageous for text-mode consoles
in full-screen, it uses the video bios fonts - maybe a little faster than software fonts

i'll have a look at your attachment   :t

dedndave

both programs use ~50% CPU
i guess, if you run "wide open" from the message loop, that's bound to happen

the full-screen program isn't quite full-screen, though
to the right of center, at the bottom, you can see part of my wallpaper


hamper

Hi Dave,

Well, not on my system.
It runs full, fullscreen - nothing else on the desktop whatsoever - and cpu reports 0-5% as previous.

Are you on so-called "integrated" graphics (that use the cpu) as opposed to a dedicated graphics card maybe?
I'm on XP SP3 Acer laptop with duo-core Intel and NVIDIA 128Mb card.

hamper

Just done another check on cpu usage.
Initial spike to about 18% when program started - maybe to do with getting all the handles, contexts and other initialisation routines etc.?
Then ticks over at about 2% during rendering.
Final spike to about 8% on program shutdown - maybe getting rid of the handles, contexts etc. and departing back to Windows?

dedndave

i can't really answer that - lol
i am using an intel 915GV express motherboard with integrated graphics (ATI, i think)
so - it probably does share some resources

i didn't look at the code, so i don't know how you get the size, but....
you can get the desktop dimensions with GetSystemMetrics
    INVOKE  GetSystemMetrics,SM_CXSCREEN
;EAX = screen width

    INVOKE  GetSystemMetrics,SM_CYSCREEN
;EAX = screen height


on another note.....
i found some other tutorials that look very promising...

http://www.gametutorials.com/gtstore/c-1-test-cat.aspx
http://www.belanecbn.sk/3dtutorials/
http://bcz.asterope.fr/index.htm

most of the code is some flavour of C, of course
we get used to translation, around here   :P

hamper

Since my last main post (with the examples), I've been checking and testing things, and there are a couple of points worth mentioning:

1. My line of code

   mov mywc.style,35                      ; CS_VREDRAW + CS_HREDRAW + CS_OWNDC

CS_VREDRAW and CS_HREDRAW are not required for a fullscreen window, so can be entirely omitted. But CS_OWNDC is still required for OpenGL (whether fullscreen or windowed).

2. My line of code

   push 8                    ; WS_EX_TOPMOST

WS_EX_TOPMOST is not actually required for a fullscreen OpenGL application (the program will still run fullscreen without it), but it is highly recommended for obvious reasons (window is created as the topmost window), so it is definitely best left in IMHO.


dedndave

some interesting reading about CS_OWNDC and OpenGL

http://www.opengl.org/discussion_boards/showthread.php/139003-About-CS_OWNDC/page2

i think i'll register for that forum - see what i can learn   :P

in the version i tested, i wound up getting the DC once and releasing it once
i did not use the flag - so, i guess it may use more memory that way ?

as for the topmost - that should be ok for an app that's intended to be full-screen
you can also use SetWindowPos to get more control over z-order

Gunther

Dave,

Quote from: dedndave on November 20, 2013, 06:00:35 AM
i found some other tutorials that look very promising...

http://www.gametutorials.com/gtstore/c-1-test-cat.aspx
http://www.belanecbn.sk/3dtutorials/
http://bcz.asterope.fr/index.htm

most of the code is some flavour of C, of course
we get used to translation, around here   :P

you've found very interesting projects. The translation from C to assembly language will do the compiler.

Gunther
You have to know the facts before you can distort them.

jj2007

Quote from: dedndave on November 20, 2013, 08:33:08 AM
some interesting reading about CS_OWNDC and OpenGL

What's wrong with getting the DC (private or common) once in the WM_CREATE handler?

Here is an interesting answer. If I read it correctly, the WM_SIZE handler is the best place to create a new own DC, and release the old one.

dedndave

of course, it depends on the application
the demos we have been playing with the last few days are continuously being updated
it makes sense to get a DC and hang on to it

but, i can also see many cases where it may be more desirable to get a DC when needed, then release it
and, while i'm not sure i completely understand the implications of sizing a window,
my understanding of a DC is that it will hold whatever image you select into it
i.e., the size is dependant on selected objects

i view the DC as a structure that defines attributes - nothing more

back to the tutorials   :biggrin:

i found the "red book" for older OpenGL versions
http://www.glprogramming.com/red/
it may not have a lot of pretty pictures or demo programs,
but i think it explains the underlying basics better than some tutorials
i am going to see if i can work my way through it without too many coding examples   :P

i found it here, which seperates the tutorials into pre- and post- version 3.0
http://www.opengl.org/wiki/Getting_Started

jj2007

Quote from: dedndave on November 20, 2013, 02:46:14 PM
i view the DC as a structure that defines attributes - nothing more

Maybe it's a jump table, OLE style. Some older sources say it's sitting in a 64k GDI heap that is common to all processes, and therefore a precious system resource. One argument more for CS_OWNDC. It's a pity that the internals are so badly documented; for example, I'd like to know whether ExitProcess does ReleaseDC for the lazy programmer... probably it does for the own DC, but what about the common ones?

hamper

And the online version of the blue book is at

http://www.glprogramming.com/blue/


Gunther

Hi hamper,

Quote from: hamper on November 20, 2013, 09:39:43 PM
And the online version of the blue book is at

http://www.glprogramming.com/blue/

thank you for providing the link.

Gunther
You have to know the facts before you can distort them.

Farabi

Fullscreen and windowed had the same performance, but depend on the screen size it will effect the CPU usage. For example, you might end up wasting CPU usage when doing full screen at 720p while others only used 240p. My SiS Mirage 3 hardware acceleration support only as good as Playstation 1 which is 320x240 resolutions at 60FPS, above it, it will run only at 30 FPS or less. Even with only few vertices. Using shadow, the FPS decreased to 25 FPS at resolution 640x480 with only about 15k vertices. But it really depend on the pixel fills not depend on vertices rate.
http://farabidatacenter.url.ph/MySoftware/
My 3D Game Engine Demo.

Contact me at Whatsapp: 6283818314165