I need to find the screen resolution of a users screen who visits my website?
var screenWidth = window.screen.width, screenHeight = window.screen.height;
You can then send it to the server via Ajax (with an
See also the MDC
I would NOT use raw sockets to do this. Instead use JSON over HTTP because PHP supports processing HTTP without any special consideration. It's simple to run your PHP pages on the hosted apache instance on GoDaddy or Amazon EC2. Sure you can use sockets, but very very few people actually do that. Massively more people process and respond to HTTP with PHP. That means you'll find vastly more people who can help answer your questions if you follow the herd here. Also there are API libraries on both sides for doing this easily. Using sockets comes with plenty of things you'll have to do yourself or suffer through all the strange bugs that comes with working with raw sockets for the first time.
Also JSON processing is easily supported by both Java and PHP to it's very easy to send the data to the client and server using that.
Well you can certainly use PHP on the backend and Java on the frontend if you like, but I'd suggest canceling your Go-Daddy account and get an Amazon EC2/S3 account because you get a full machine dedicated to whatever you want to put on it. So if you want to do Java on the backend you can just by installing the JDK, Tomcat, etc yourself on the amazon instance and you're good to go. You can also host PHP on there too. There is even plenty of AMI instances pre-installed for Java or PHP stacks.
In the SDL 2 wiki, you have a category named Display and Window Management. It lists everything you need to know about SDL 2's management of displays (screens) and windows.
You have multiple choices, the most generic would be using
SDL_GetDesktopDisplayMode. The difference is explained in the wiki :
There's a difference between SDL_GetDesktopDisplayMode() and SDL_GetCurrentDisplayMode() when SDL runs fullscreen and has changed the resolution. In that case SDL_GetDesktopDisplayMode() will return the previous native display mode, and not the current display mode.
After setting a
SDL_DisplayMode with one of these, you can retrieve its attributes
However, there is another function that might be more appropriate and straightforward :
SDL_GetDisplayBounds. If I am not mistaken, it gives you the coordinates of the display relative to the whole set of displays that can be active on the computer, and also the size of the display.
Both methods need you to know the index of the display you want to know about. I have not played that much with this part of SDL 2, but I guess you can use
SDL_GetNumVideoDisplays to get the number of displays (and check if there is at least one ? - I think the
SDL_Window part might not work if there is no display available anyway) and choose one. Or you could pick the first one, which has index 0.
Oh, and you can look at the exemple on the page of
SDL_GetCurrentDisplayMode, they effectively retreive the size of a display.
No, AFAIK this is not possible.
Essentially, you can set a cookie or you can even do some Ajax to send the info to a PHP script. If you use jQuery, you can do it something like this:
All that is really basic but it should get you somewhere. Normally screen resolution is not what you really want though. You may be more interested in the size of the actual browser's view port since that is actually where the page is rendered...