BackBuffer,SDL and Linux

Hi
I am using BackBuffer class written by Michael P. Welch.
Currently i am using it for windows.
Since i am a windows program i am aware of device handle and painting in
windows.
Now i want to port my game to linux and using SDL.
But i don’t know much about linux and how GUI is created.
So my question is :

  1. How linux creates windows and is there anything like HDC?
  2. As windows uses registry, what linux uses to store application specific
    information? or do i need to write my own functionality to store it in files?

It will better if linux has feature like registry.

3)Is there any function in regisry using which i can create SDL_Surface from
backbuffer?

I hope there must be one to create surface by providing a necessary data.
I need to dig deeper in SDL doc.
I think i found one SDL_CreateRGBSurfaceFrom.

You great game developers out there, Please confirm my guess and correct if i
am wrong.
“The SDL_Surface is same as BackBuffer used in DirectDraw”

Thanks in advance.
Hemu

Since i am a windows program i am aware…

You’re a Windows program? Wow, I haven’t been keeping up with the latest
advances in AI. (Sorry, I couldn’t resist :wink:

It will better if linux has feature like registry.

In the opinion of many, including myself, the registry is one of the
dumbest ideas MS has come up with. Try not to inflict it on the rest of us
:slight_smile: The functional equivalent in Linux (or at least the closest thing) is
separate configuration files for each program. Works well and avoids the
nightmare of registry nonsense.

JeffOn Thursday 23 September 2004 07:18 am, Hemu wrote:

Hello Hemu,

[snip]

It will better if linux has feature like registry.

To avoid trolling now (it’s a bit controversed topic)…

AFAIK there’s no common or generalized registry-like system for GNU/Linux
systems. The common scheme is flat ASCII files. Gnome provides a centralized
engine for all application settings (gconf) and maybe KDE too. You may also
find some other tools to manage that (ask to freshmeat.net, there are a few
ones like elektra or registery, none I’ve ever used), really nothing common or
standard but the good old text file :slight_smile: that everyone can read and edit (and
port).

Regards,On Thu, 23 Sep 2004 14:18:33 +0000 (UTC) Hemu <hemant_gamer-sdl at yahoo.co.in> wrote:


wwp

Hemu wrote:

  1. How linux creates windows and is there anything like HDC?

There are X11 Displays and Windows, but almost every toolkit hide these
beasts wrapping around their abstraction (with SDL the window is a
SDL_Surface).

You great game developers out there, Please confirm my guess and correct if i
am wrong.
“The SDL_Surface is same as BackBuffer used in DirectDraw”

If with backbuffer you mean the surface where you draw to, the answer is
yes, but you don’t need to define a surface of your own, the
SDL_SetVideoMode() call, if called without SDL_HWSURFACE or
SDL_DOUBLEBUF, already allocate a backbuffer for you that is than
blitted to the application window with the call SDL_UpdateRect(s).

You’ll find that using SDL many things are simpler to do than with
directx, often without performance loss, also on win32.

Bye,
Gabry

It will better if linux has feature like registry.

To avoid trolling now (it’s a bit controversed topic)…

AFAIK there’s no common or generalized registry-like system for GNU/Linux
systems. The common scheme is flat ASCII files.

It might be good to note that most applications save their settings in an $HOME/.application_name directory or if it’s just one file sometimes in a file by simular name. ($HOME is like /home/someuser).

Installation direcorys for the software does not work exactly as in windows (all on one directory), instead files are grouped by type, like /usr/bin for binarys, /usr/share/appname/ for data and so on.

Also it could be good to know that program and data files generally are owned by root and the normal user can’t nor should be able to change them. When the program saves settings, or other per-user data, it does this in the current users homedirectory/.application_name/.

It’s a good idea to study other multiplatform applications, there are lots of them at freshmeat.net or sf.net.

Hi
I am using BackBuffer class written by Michael P. Welch.
Currently i am using it for windows.
Since i am a windows program i am aware of device handle and painting
in
windows.
Now i want to port my game to linux and using SDL.
But i don’t know much about linux and how GUI is created.
So my question is :

  1. How linux creates windows and is there anything like HDC?

If you’re using GDI functions then your game is pretty outdated
(technologically speaking) even on Windows. SDL programming is more
comparable to DirectX than GDI (however the underlying implementation
of control between SDL and Windows can use DirectX or GDI as you
choose; by “default” it’s DirectX.)

  1. As windows uses registry, what linux uses to store application
    specific
    information? or do i need to write my own functionality to store it in
    files?

It will better if linux has feature like registry.

The Windows Registry is popularly thought of as being pretty bad, for a
variety of reasons. But you do not need to write your own way of
storing information in files, many libraries exist to make this process
as simple as possible. They are unrelated to SDL, though maybe someone
on the list may jump in on this thread and help you out with that
anyway.

3)Is there any function in regisry using which i can create
SDL_Surface from
backbuffer?

I hope there must be one to create surface by providing a necessary
data.
I need to dig deeper in SDL doc.
I think i found one SDL_CreateRGBSurfaceFrom.

By regisry, I can only assume you meant registry; and by registry, I
can only assume you mean the Windows Register… which is a problem
because the Windows Registry doesn’t have anything to do with back
buffers.

As for creating a back buffer, it is very easy. Just enable double
buffering by adding the SDL_DOUBLEBUF flag to your call to
SDL_SetVideoMode().

If I am misunderstanding you, please elaborate.

You great game developers out there, Please confirm my guess and
correct if i
am wrong.
“The SDL_Surface is same as BackBuffer used in DirectDraw”

Not entirely. IIRC, SDL_Surfaces are the ideologically as
DDSURFACEDESC2 structures. To eliminate any confusion, let me state
that the term “back buffer” refers to a second screen buffer, on which
you draw the contents of your next frame before "flipping the page."
This eliminates the video game faux pas of drawing objects
incrementally so the player ends up watching lots of drawing occurring
right on the screen.On Sep 23, 2004, at 10:18 AM, Hemu wrote:

AFAIK there’s no common or generalized registry-like system for GNU/Linux
systems. The common scheme is flat ASCII files.

http://elektra.sourceforge.net/

Not a very practical piece of software, still it does exist.

It’s a good idea to study other multiplatform applications, there are lots of them at freshmeat.net or sf.net.

http://www.pathname.com/fhs/pub/fhs-2.3.html

You can findout more about *NIX’s Filesystem Hierarchy, there.

Have fun.On Thu, 2004-09-23 at 18:30 +0000, Joakim Kolsj? wrote:

By the way, and this is a shameless plug, but I wrote a class for C++ to
help make creating, reading and editing *.ini files easy. It’s free and open
source, and cross platform friendly:
http://www.codeproject.com/useritems/CIniFile.asp

That might help in your transition. Welcome to the Dark Side.

-Todd

----Original Message Follows----From: hemant_gamer-sdl@yahoo.co.in (Hemant Muthiyan)
Reply-To: “A list for developers using the SDL library.
(includesSDL-announce)”
To: sdl at libsdl.org
Subject: [SDL] BackBuffer,SDL and Linux
Date: Thu, 23 Sep 2004 14:18:33 +0000 (UTC)

Hi
I am using BackBuffer class written by Michael P. Welch.
Currently i am using it for windows.
Since i am a windows program i am aware of device handle and painting in
windows.
Now i want to port my game to linux and using SDL.
But i don’t know much about linux and how GUI is created.
So my question is :

  1. How linux creates windows and is there anything like HDC?
  2. As windows uses registry, what linux uses to store application specific
    information? or do i need to write my own functionality to store it in
    files?

It will better if linux has feature like registry.

3)Is there any function in regisry using which i can create SDL_Surface from
backbuffer?

I hope there must be one to create surface by providing a necessary data.
I need to dig deeper in SDL doc.
I think i found one SDL_CreateRGBSurfaceFrom.

You great game developers out there, Please confirm my guess and correct if
i
am wrong.
“The SDL_Surface is same as BackBuffer used in DirectDraw”

Thanks in advance.
Hemu


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

Jeff wrote:

You’re a Windows program? Wow, I haven’t been keeping up with the latest
advances in AI. (Sorry, I couldn’t resist

Thanks Jeff for pointing my typo mistake.
I will take care of checking my spellings before posting.
Well I am not Windows program but I am windows programmer.

Let me tell you all that I don’t want to start any kind of argument war on who
is best “Microsoft” or “open source community”.

I respect both for their great work.

There was typo mistake in my third question.

3)Is there any function in regisry using which i can create SDL_Surface from
backbuffer?

Actually i wanted to ask
Is there any function in SDL using which i can create SDL_Surface from
backbuffer?

For time being i am doing pixel manipulation in backbuffer and at the time of
flipping the surface, I set the pixel data from backbuffer to SDL_Surface.
It works fine except the images are not displayed in there original color.

I tried to set RGB mask, loss and shift values but no luck.
I need help in understanding the usage and importance of these values and how
they affect the image.

Thank you all for your valuable suggestions.
Hemu

Jeff wrote:

You’re a Windows program? Wow, I haven’t been keeping up with the
latest
advances in AI. (Sorry, I couldn’t resist

Thanks Jeff for pointing my typo mistake.
I will take care of checking my spellings before posting.
Well I am not Windows program but I am windows programmer.

Let me tell you all that I don’t want to start any kind of argument
war on who
is best “Microsoft” or “open source community”.

Microsoft sucks! (hahaha…)

Actually i wanted to ask
Is there any function in SDL using which i can create SDL_Surface from
backbuffer?

You’ll want to use SDL_CreateRGBSurface and then blit screen to the new
surface.

For time being i am doing pixel manipulation in backbuffer and at the
time of
flipping the surface, I set the pixel data from backbuffer to
SDL_Surface.

What does “I set the pixel data from backbuffer to SDL_Surface” mean
exactly?

It works fine except the images are not displayed in there original
color.

I tried to set RGB mask, loss and shift values but no luck.
I need help in understanding the usage and importance of these values
and how
they affect the image.

This actually has given me a great idea for you! It should be possible
to use SDL_DisplayFormat! Here is its description from the man page:

    This  function  takes  a  surface and copies it to a new surface 

of the
pixel format and colors of the video framebuffer, suitable
for fast
blitting onto the display surface.

SDL_DisplayFormat returns a pointer to a newly created surface, so you
won’t have to call CreateRGBSurface (although it probably uses this
internally, but that doesn’t really matter now does it?)

I would also like to ask why you think you must create a copy of the
back buffer to do pixel operations on it. Do you realize that at any
given time in a double buffered SDL application, screen->pixels points
to the back buffer?

Hope you find this useful.On Sep 24, 2004, at 9:44 AM, Hemu wrote:

Hi all!

I ve found this tread on Game dev!

//////////////////////////////////////////////////////////////////////////////
Ok. I successfully ported my OpenGL program to Windows except for one thing.
SDL_WM_ToggleFullscreen only works under X11. I am trying to make Windows go
fullscreen, but when I set the SDL_FULLSCREEN flag to SDL_SetVideoMode and call
it again, all my textures for OpenGL are gone and everything is white… Is
this why all comercial games reload everything after you change a little thing
and do I need to reload all my textures again also?

SNIP…

The way to do it is destroy all the textures, change resolutions, reload all
the textures. Other things such as VBO have to be recreated too, I think.

SNIP…

yes all vertex/pixel programs have to be loaded as well, not to difficult, eg
in your texture manager include the filename as well thus u can reload all
textures again if the resolution changes

SNIP…
Textures are lost like display lists and shader/program-objects because the
Open GL Context is destroyed as the Window closes. At least it should be like
that. Under X11 you can use glXCopyContext to save the GL States. Although I
can’t name it, there is a similar function under Windows.
//////////////////////////////////////////////////////////////////////////////

may be we are talking about the same thing here… we re actualy destroying all
textures each time the screen resolution change… (on windows xp, SDL
release1.2.7) i m not too crazy about this procedure… can we some how use the
glXCopyContext or a similar function on windows? resizing the screen resolution
and/or toggle fullscreen witout reloading textures?!

a routine sample will be apreciated!

Thx

This is not related.On Sep 25, 2004, at 1:46 PM, Golgoth wrote:

Hi all!

I ve found this tread on Game dev!

//////////////////////////////////////////////////////////////////////
////////
Ok. I successfully ported my OpenGL program to Windows except for one
thing.
SDL_WM_ToggleFullscreen only works under X11. I am trying to make
Windows go
fullscreen, but when I set the SDL_FULLSCREEN flag to SDL_SetVideoMode
and call
it again, all my textures for OpenGL are gone and everything is
white… Is
this why all comercial games reload everything after you change a
little thing
and do I need to reload all my textures again also?

SNIP…

The way to do it is destroy all the textures, change resolutions,
reload all
the textures. Other things such as VBO have to be recreated too, I
think.

SNIP…

yes all vertex/pixel programs have to be loaded as well, not to
difficult, eg
in your texture manager include the filename as well thus u can reload
all
textures again if the resolution changes

SNIP…
Textures are lost like display lists and shader/program-objects
because the
Open GL Context is destroyed as the Window closes. At least it
should be like
that. Under X11 you can use glXCopyContext to save the GL States.
Although I
can’t name it, there is a similar function under Windows.
//////////////////////////////////////////////////////////////////////
////////

may be we are talking about the same thing here… we re actualy
destroying all
textures each time the screen resolution change… (on windows xp, SDL
release1.2.7) i m not too crazy about this procedure… can we some
how use the
glXCopyContext or a similar function on windows? resizing the screen
resolution
and/or toggle fullscreen witout reloading textures?!

a routine sample will be apreciated!

Thx

Hemu:

Actually i wanted to ask
Is there any function in SDL using which i can create SDL_Surface from
backbuffer?

Donny Viszneki:
You’ll want to use SDL_CreateRGBSurface and then blit screen to the new
surface.

Hemu:

For time being i am doing pixel manipulation in backbuffer and at the
time of
flipping the surface, I set the pixel data from backbuffer to
SDL_Surface.

Donny Viszneki:
What does “I set the pixel data from backbuffer to SDL_Surface” mean
exactly?

Hemu:
I am copying pixel data from BackBuffer class to SDL_surface.

Hemu:

It works fine except the images are not displayed in there original
color.

I tried to set RGB mask, loss and shift values but no luck.
I need help in understanding the usage and importance of these values
and how
they affect the image.

Donny Viszneki:

This actually has given me a great idea for you! It should be possible
to use SDL_DisplayFormat! Here is its description from the man page:

This function takes a surface and copies it to a new surface
of the pixel format and colors of the video framebuffer, suitable
for fast blitting onto the display surface.

SDL_DisplayFormat returns a pointer to a newly created surface, so you
won’t have to call CreateRGBSurface (although it probably uses this
internally, but that doesn’t really matter now does it?)

I would also like to ask why you think you must create a copy of the
back buffer to do pixel operations on it. Do you realize that at any
given time in a double buffered SDL application, screen->pixels points
to the back buffer?

Hope you find this useful.

Hemu:
I already written lot of code for drawing line,circle, rectangle etc.
I don’t want to do it again for SDL. So what i am trying to do is, use the
existing code and while blitting, set the data from my backbuffer functionality
to SDL_Surface and let SDL handle displaying.

I got the solution. After a bit debugging, i found that the true color format
i was using was different from that of used by SDL.
So now what i am doing is, I am setting a true color format used by SDL in my
backbuffer class just after creating a object of backbuffer.

Yes, information you given is really very helpfull.
Thanks a lot for replying to my post.
Hemu