As you are all probably (and painfully) aware by now, I'm trying to learn how to program graphics using OpenGL, and sticking strictly to using assembly language. Thanks to a LOT of help from a LOT of people on this forum (and I thank you all again), I've managed to get a working program up and running that displays a simple, rotating, multi-coloured triangle (as attached, but you won't like my programming style :eusa_naughty:)
To get to the point, I'm wondering if there is any difference in speed between running in windowed mode and running in fullscreen mode. I've read that OpenGL automatically uses hardware acceleration when it's available (which it is, on my pc), so can I assume that when I run my little example it's already running with hardware acceleration even in windowed mode? Or do I need to do something extra to get it running in fullscreen/hardware-accelerated mode?
Does anyone know of any good examples/tutorials that describe how to get an OpenGL program running in fullscreen mode with hardware acceleration (assuming that this is completely different to running in windowed mode)?
Finally, Hutch - would it be useful to have a Forum section dedicated to OpenGL, and graphics programming in general, so as not to clutter up the Campus too much?
Thanks in anticipation.
Phil
you have undoubtedly looked in the control panel, Display settings, hardware accel...
i think from win7 and up, full-screen "mode" isn't available
so, maybe not a good idea to plan on using that
but - you can still make a borderless window and take up the whole screen - lol
i doubt the program runs any faster, but you could try measuring the speed
count the updates - measure the time - and divide
when you close the program, display a message box that shows the rate
if you want to get more accurate measurements, use Michael's timing macros to measure clock cycles
many of us use the macros for benchmarking algorithms
http://masm32.com/board/index.php?topic=49.0 (http://masm32.com/board/index.php?topic=49.0)
by the way - your program runs ok on XP MC2005, SP3
Hi Dave, nice to hear from you again,
My 128 Mb NVIDIA card has a vertical (default, I believe) refresh frequency of 60 Hz, and the little spinning triangle seems to rotate at about that rate. The program swaps the buffers every 1 degree of rotation, and it seems to spin at about that rate (60 Hz). But that's just a little, simple triangle. I'm wondering, once I get onto programming DOOM XXVII whether the same will apply, i.e. if the whole drawing gets a LOT more complicated (lights, fog, textures etc.), will it all still get rendered and swap buffers at 60 Hz. I'm afraid I don't know enough about graphics cards and how they work (or OpenGL for that matter) to answer that (yet) but I'm trying to get to grips with it all.
So I'm at the starting point, trying to lay solid foundations for the future. Do I need to start off getting fullscreen/hardware acceleration up and running, or is this something I don't even need to take into consideration, now, or ever? Again, I'm just a novice on graphics, and I don't know enough about how graphics cards or OpenGL does things behind the scenes. But if there's something that needs to be done, now's the time, eh?
Phil
Hi hamper,
Are you aware of the NeHe tutorials?
A lot of OpenGL info.
Have a look at the "Legacy Tutorials".
http://nehe.gamedev.net/
right
i am more or less in the same boat - also a novice with OpenGL
as for acceleration....
each machine has a set of drivers associated with the video adapter/CPU/OS
if acceleration is available, the drivers will support it
i don't think you have to be too concerned with it
it will either be there, or it won't - and OpenGL uses the fastest thing supported
i am primarily interested in 3D height maps, at the moment
so, the triangle was of interest to me because it may be the basic structure in my future code
http://masm32.com/board/index.php?topic=1890.msg20167#msg20167 (http://masm32.com/board/index.php?topic=1890.msg20167#msg20167)
so my app is a little different, and i don't intend to update as often as 60 Hz
in reality, the human eye only updates something like 10 times a second
but - many video formats use ~24 to 30 frames per second to get good results
even though you are drawing many more - and more complex triangles, they are also much smaller :biggrin:
either way, i suspect OpenGL is the fastest you are going to get over a variety of hardware platforms
the issue i am currently looking into is OpenGL versions
it seems that providing 2 routines for everything may not be a bad approach, if you want highest performance
i am using XP - many do - and i want my software to support XP
so - that leaves me at, say, OpenGL ver 1.2-1.4
but, newer machines support 3.3 and higher, which may execute older code slowly
if you want best performance on those machines, you may have to use different code
There are at least a couple of active threads on flatassembler.net that would be worthwhile consulting:
http://board.flatassembler.net/topic.php?t=15917
http://board.flatassembler.net/topic.php?t=15746
search for other opengl and glfw threads at board.flatassembler.net
hth,
farrier
thanks farrier :t
a bit over my head, for now - lol
Nice program.
I looked at your code but did not see what to change to effect a slower rotation speed ?
Thanks,
Andy
Hi hamper,
nice to see you with another hot topic
Maybe glHint (http://www.opengl.org/sdk/docs/man/xhtml/glHint.xml) function is what you need at a moment:
QuoteDescription
Certain aspects of GL behavior, when there is room for interpretation, can be controlled with hints. A hint is specified with two arguments. target is a symbolic constant indicating the behavior to be controlled, and mode is another symbolic constant indicating the desired behavior. The initial value for each target is GL_DONT_CARE. mode can be one of the following:
GL_FASTEST
The most efficient option should be chosen.
GL_NICEST
The most correct, or highest quality, option should be chosen.
GL_DONT_CARE
No preference.
...
Another helpful function to explore your device caps / settings is glGet (http://www.opengl.org/sdk/docs/man/xhtml/glGet.xml)
There was the separate OpenGL board (http://www.masmforum.com/board/index.php?PHPSESSID=4cb435eec0965974b726d50a7d347352&board=41.0) in the older forum
P.S.: BTW nehe.gamedev.net is not available from here :(
P.P.S.: but I've found this post (http://www.masmforum.com/board/index.php?topic=17222.0) !!!
Here are the Masm OpenGl examples by hitchhikr
http://perso.orange.fr/franck.charlet/Ogl_Asm.zip
very nice Marinus !
he has a lot of cool stuff on his site...
http://franck.charlet.pagesperso-orange.fr/ (http://franck.charlet.pagesperso-orange.fr/)
Quote from: Siekmanski on November 19, 2013, 10:16:44 PM
Here are the Masm OpenGl examples by hitchhikr
http://perso.orange.fr/franck.charlet/Ogl_Asm.zip
My Smart Screen blocked this download reporting that it had a virus inside.
Did anybody else try to download it and scan with AV ?
Does anybody has "healthy" version of the archive ?
it's probably your AV - i doubt Franck would do anything malicious
the archive is ~4 mb
if your AV won't allow you to d/l it from Franck's site, i don't know how else i'd get it to you
see if you can temporarily disable it
http://www.howtogeek.com/75356/ (http://www.howtogeek.com/75356/)
Well, I solved the problem
That archive is already here in special AV folder:
D:\ProgramData\Microsoft\Windows Defender\LocalCopy\{AE7B293D-397A-4DF8-8152-BAA2182838B1}-Ogl_Asm.zip
EDIT: Thank you, Dave !
report:
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.
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
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
(http://img18.imageshack.us/img18/6742/jsek.png)
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.
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?
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.gametutorials.com/gtstore/c-1-test-cat.aspx)
http://www.belanecbn.sk/3dtutorials/ (http://www.belanecbn.sk/3dtutorials/)
http://bcz.asterope.fr/index.htm (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
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.
some interesting reading about CS_OWNDC and OpenGL
http://www.opengl.org/discussion_boards/showthread.php/139003-About-CS_OWNDC/page2 (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
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.gametutorials.com/gtstore/c-1-test-cat.aspx)
http://www.belanecbn.sk/3dtutorials/ (http://www.belanecbn.sk/3dtutorials/)
http://bcz.asterope.fr/index.htm (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
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. (http://stackoverflow.com/questions/12153472/getdc-vs-beginpaint-performance-considerations) If I read it correctly, the WM_SIZE handler is the best place to create a new
own DC, and release the old one.
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/ (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 (http://www.opengl.org/wiki/Getting_Started)
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?
And the online version of the blue book is at
http://www.glprogramming.com/blue/
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
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.