Changing Video Mode!

hi all!

we need to go back and forth between these 2 video modes:

int g_videoMode = SDL_HWSURFACE | SDL_FULLSCREEN;
int g_3dMode = SDL_OPENGL | SDL_FULLSCREEN;

SetVideoMode(WINDOW_TITLE, 800, 600, 32, g_videoMode)) == NULL)
SetVideoMode(WINDOW_TITLE, 800, 600, 32, g_3dMode)) == NULL)

once g_videoMode has been activated the cursor disapears and there is no way to
get it back so far… anyone can think of a way to retrieve the cursor?

plz help!

thx

hi all!

we need to go back and forth between these 2 video modes:

Why? Seriously, why do you need to do that?

	Bob PendletonOn Mon, 2005-04-04 at 17:23 +0000, Golgoth! wrote:

plz help!

thx


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


±-------------------------------------+

Golgoth! wrote:

hi all!

we need to go back and forth between these 2 video modes:

int g_videoMode = SDL_HWSURFACE | SDL_FULLSCREEN;
int g_3dMode = SDL_OPENGL | SDL_FULLSCREEN;

SetVideoMode(WINDOW_TITLE, 800, 600, 32, g_videoMode)) == NULL)
SetVideoMode(WINDOW_TITLE, 800, 600, 32, g_3dMode)) == NULL)

once g_videoMode has been activated the cursor disapears and there is no way to
get it back so far… anyone can think of a way to retrieve the cursor?

Ok, I don’t have any free time ATM, but please write a small SDL program
that makes the cursor disappear and compiles as-is and post it here. So
we could at least :

  • know if someone else can reproduce the problem on a system other than
    yours
  • have someone else (or me in a month from now) look at it and try to fix it

Also, you’re using windows xp, but is this with the DIB or Directx
backend ? Could you try both ?

Stephane

Seriously, DO NOT DO THAT, unless you’re trying to play some kind of
practical joke on all CRT users. (They sure won’t appreciate it
either way. :wink:

Even if the resolutions and timings are the same for the 2D and 3D
modes (which cannot be guaranteed on all platforms, I suspect…),
there’s a great risk of the video subsystem disrupting the timing, or
even switching back to the desktop mode for a brief moment, when SDL
reinitializes it’s display. Even a single sync pulse that’s slightly
off will have some CRTs do the full “resync cycle”, which means the
user will be looking at a black screen (or worse) for well over a
second on some devices.

Just do it all with OpenGL. You avoid the problem, and you get faster
rendering with some serious blending and transformation
possibilities. If your application needs OpenGL to work properly
anyway, I can’t think of any valid reason not to use it throughout.

//David Olofson - Programmer, Composer, Open Source Advocate

.- Audiality -----------------------------------------------.
| Free/Open Source audio engine for games and multimedia. |
| MIDI, modular synthesis, real time effects, scripting,… |
`-----------------------------------> http://audiality.org -’
http://olofson.nethttp://www.reologica.se —On Monday 04 April 2005 19.23, Golgoth! wrote:

hi all!

we need to go back and forth between these 2 video modes:

Why? Seriously, why do you need to do that?

we need to go back and forth between these 2 video modes:!!!

oviously the video mode switch at the bigining and at end of the movie… not
all the time!

the reason im trying this is for playing quicktime in a 3d opengl engine…
would be nice to have sdl doing it… it does… but with side effecs!

heres a sample:

as is… the cursor disapear!

take out one l_screen = … and u get the cursor back…

#include <sdl.h>
#pragma comment(lib, “SDLmain.lib”)
#pragma comment(lib, “SDL.lib”)

int main(int in_argc, char **in_argv)
{
SDL_Init(SDL_INIT_VIDEO);
SDL_WM_SetCaption(“SDL Test”, NULL);
SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8);
SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8);
SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8);
SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, 8);
SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, 8);
SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 32);
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);

SDL_Surface *l_screen;
l_screen = SDL_SetVideoMode(640, 480, 32, SDL_HWSURFACE | 

SDL_FULLSCREEN);
l_screen = SDL_SetVideoMode(640, 480, 32, SDL_OPENGL | SDL_FULLSCREEN);

SDL_Event l_event;
l_event.type = SDL_NOEVENT;

while (l_event.type != SDL_QUIT)
{
	while(SDL_PollEvent(&l_event))
	{
	switch (l_event.type)
	{
	case SDL_KEYDOWN:
	{
		switch (l_event.key.keysym.sym)
		{
			case SDLK_ESCAPE:
				{
					fclose(l_file);
					SDL_Quit();
					return 0;
				}
				break;
		}
	}
	break;
	}
	}
}
SDL_Quit();
return 0;

}

maybe there is a simplier way to play back video with sdl… but when i play
quictime video with SDL_OPENGL it turns out all black… sounds is audible tho.

thx

Quoth Golgoth! , on 2005-04-05 02:26:32 +0000:

maybe there is a simplier way to play back video with sdl… but
when i play quictime video with SDL_OPENGL it turns out all
black… sounds is audible tho.

How exactly is the QuickTime engine accessing the screen?

If it’s trying to access a 2D framebuffer directly, can you tell it to
access a 2D buffer of your choosing and blit that to the screen,
perhaps with glDrawPixels? Is it using hardware acceleration, and if
so, can you get the video card driver to make that play nice with
OpenGL rendering somehow?

—> Drake Wilson
-------------- next part --------------
A non-text attachment was scrubbed…
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20050404/68f1c737/attachment.pgp

we need to go back and forth between these 2 video modes:!!!
[…]
heres a sample:

as is… the cursor disapear!

take out one l_screen = … and u get the cursor back…

[… minimal example …]

AFAIK, SDL uses windib for opening an OpenGL window.
Your example worked perfectly after selecting the windib driver
(e.g. via the SDL_VIDEODRIVER env var) for both video surfaces.

Regards,
Johannes

< http://libufo.sourceforge.net > The OpenGL GUI ToolkitOn Tuesday 05 April 2005 04:26, Golgoth! wrote:

How exactly is the QuickTime engine accessing the screen?

first i create a surace!

g_videoSurface = SDL_CreateRGBSurface(SDL_HWSURFACE, WINDOW_WIDTH,
WINDOW_HEIGHT, 24, r, g, b, a);

set video mode to g_surface = SetVideoMode(…SDL_HWSURFACE | SDL_HWACCEL |
SDL_NOFRAME…;

tell qt what grafic surface to use…

if(QTNewGWorldFromPtr(&l_world, k24RGBPixelFormat, &l_rect, NULL, NULL, 0,
(char*) g_videoSurface->pixels, g_videoSurface->pitch) != noErr)

update movie and:

SDL_BlitSurface(g_videoSurface, 0, g_surface, 0);
SDL_UpdateRect(g_surface, 0, 0, g_surface->w, g_surface->h);

this works perfecly in SDL_HWSURFACE mode… but remains all black with
SDL_OPENGL…

can you get the video card driver to make that play nice with OpenGL rendering
somehow?

thats what im trying to do… i probably need an hocus pocus trick like
glReadpixel… make buffer something then pass it back sdl… thats what im
confused about!

so close to get video playback… if you guys have any ideas on this!

golgoth!

AFAIK, SDL uses windib for opening an OpenGL window. Your example worked
perfectly after selecting the windib driver (e.g. via the SDL_VIDEODRIVER env
var) for both video surfaces.

can you post what you did to make it work exacly?

or can anyone clear this up?

thx!

Quoth Golgoth! , on 2005-04-05 17:34:21 +0000:

g_videoSurface = SDL_CreateRGBSurface(SDL_HWSURFACE, WINDOW_WIDTH,
WINDOW_HEIGHT, 24, r, g, b, a);
[…]
SDL_BlitSurface(g_videoSurface, 0, g_surface, 0);
SDL_UpdateRect(g_surface, 0, 0, g_surface->w, g_surface->h);

You cannot blit to the screen using SDL functions in OpenGL mode.
After creating your surface, use glDrawPixels to copy the pixels to the
screen where you want them. An example of this structure might be:

/* During initialization, or when the size changes: /
/
The masks are dependent on your system endianness and the
data type specified in the glDrawPixels call later, but I don’t
remember how this works exactly and I’m not on a system with
SDL+OpenGL at the moment – someone specify this? */
quicktime_surface =
SDL_CreateRGBSurface(SDL_SWSURFACE, quicktime_width,
quicktime_height, 32, rmask, gmask,
bmask, amask);

/* Each frame: /
/
This assumes you don’t have any other GL stuff in effect that
would modify the glDrawPixels call in strange ways. You may
also need to fiddle the glPixelStore options, depending. */
DoSomeQTRendering(quicktime_surface->pixels, some_quicktime_object);
glDrawPixels(quicktime_width, quicktime_height,
GL_RGBA, GL_UNSIGNED_INT_8_8_8_8, surface->pixels);

I’m not sure how this would interact with SDL_HWSURFACE; you’d need
to lock the surface before rendering to it in that case, which might
interact badly with the QuickTime library. Also, the pixel format
of the SDL surface may require you to set options for the transfer
with glPixelStore; glPixelStorei(GL_UNPACK_ALIGNMENT, 1) is relatively
common, for instance, if you don’t know how the pixel data in memory
will be aligned. GL_UNPACK_ROW_LENGTH may also need to be set if the
pitch of the surface is not the same as the row length.

—> Drake Wilson

Why? Seriously, why do you need to do that?

we need to go back and forth between these 2 video modes:!!!

That is not a reason :slight_smile:

oviously the video mode switch at the bigining and at end of the movie… not
all the time!

the reason im trying this is for playing quicktime in a 3d opengl engine…
would be nice to have sdl doing it… it does… but with side effecs!

That is not a reason. It would appear that you don’t know how to blit a
buffer in memory (where quicktime puts your frame) onto the screen. So,
you need to read a little more about OpenGL.

	Bob PendletonOn Tue, 2005-04-05 at 02:26 +0000, Golgoth! wrote:


±-------------------------------------+

[…]

SDL_BlitSurface(g_videoSurface, 0, g_surface, 0);
SDL_UpdateRect(g_surface, 0, 0, g_surface->w, g_surface->h);

this works perfecly in SDL_HWSURFACE mode… but remains all black
with SDL_OPENGL…

Of course! :wink: SDL 2D blitting is not supported when using the OpenGL
backend.

You could try abusing glSDL to get away easy, but keep in mind that it
messes with the OpenGL state in undefined ways. (It’s a 2D backend;
not an OpenGL helper library.)

can you get the video card driver to make that play nice with OpenGL
rendering somehow?

Not really. You have to make the blits go through OpenGL, one way or
another.

The proper way would be to have QuickTime render into an OpenGL
texture instead of an SDL surface, and stay in OpenGL mode at all
times. (As I’ve pointed out before, there are other reasons to do
that as well.)

Same method, actually; just a different API.

thats what im trying to do… i probably need an hocus pocus trick
like glReadpixel… make buffer something then pass it back sdl…
thats what im confused about!

Wrong way. You want to get stuff to the screen, right? So, you
should use glWritePixels() or normal texture uploading + quad
rendering. I’d definitely go for the latter, as the former is slow on
some hardware/drivers, and the latter allows you to do any OpenGL
transformations (scaling, most importantly!) and other tricks on the
video surface, just like with any normal texture. (It’s in fact a
"procedural texture", to use pure 3D programming terms.)

//David Olofson - Programmer, Composer, Open Source Advocate

.- Audiality -----------------------------------------------.
| Free/Open Source audio engine for games and multimedia. |
| MIDI, modular synthesis, real time effects, scripting,… |
`-----------------------------------> http://audiality.org -’
http://olofson.nethttp://www.reologica.se —On Tuesday 05 April 2005 19.34, Golgoth! wrote:

How exactly is the QuickTime engine accessing the screen?

first i create a surace!

g_videoSurface = SDL_CreateRGBSurface(SDL_HWSURFACE, WINDOW_WIDTH,
WINDOW_HEIGHT, 24, r, g, b, a);

Right here you could get a software surface, which is likely to be
much faster anyway…

set video mode to g_surface = SetVideoMode(…SDL_HWSURFACE | SDL_HWACCEL |
SDL_NOFRAME…;

tell qt what grafic surface to use…

if(QTNewGWorldFromPtr(&l_world, k24RGBPixelFormat, &l_rect, NULL, NULL, 0,
(char*) g_videoSurface->pixels, g_videoSurface->pitch) != noErr)

update movie and:

SDL_BlitSurface(g_videoSurface, 0, g_surface, 0);
SDL_UpdateRect(g_surface, 0, 0, g_surface->w, g_surface->h);

Instead of this you could use OpenGL to blit the software surface to the
full screen, or to any region of the screen you want. That means you
would never have to change the video mode.

this works perfecly in SDL_HWSURFACE mode… but remains all black with
SDL_OPENGL…

Yes, of course it does. When you are in OpenGL mode none of the SDL blit
functions work on the screen. They can’t work, the screen is
controlled by the OpenGL driver and SDL can’t access it.

BTW, asking for a surface that is both a hardware surface and an opengl
surface is meaningless.

can you get the video card driver to make that play nice with OpenGL rendering
somehow?

thats what im trying to do… i probably need an hocus pocus trick like
glReadpixel… make buffer something then pass it back sdl… thats what im
confused about!

so close to get video playback… if you guys have any ideas on this!

Just learn to do blits in OpenGL. Not hard to do at all. Also, try
reading the articles at http://www.oreillynet.com/articles/author/1205

golgoth!

	Bob PendletonOn Tue, 2005-04-05 at 17:34 +0000, Golgoth! wrote:

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


±-------------------------------------+

Hmm, can’t test it at the moment (don’t have access to a windows box).

I have inserted putenv(“SDL_VIDEODRIVER=windib”); before the SDL calls.
It worked under WindowsXP Home Edition.
“It worked” means I’ve seen a cursor.

Nevertheless, consider the other answers about drawing via OpenGL.

Regards,
Johannes

< http://libufo.sourceforge.net > The OpenGL GUI ToolkitOn Tuesday 05 April 2005 19:38, Golgoth! wrote:

AFAIK, SDL uses windib for opening an OpenGL window. Your example worked
perfectly after selecting the windib driver (e.g. via the SDL_VIDEODRIVER
env var) for both video surfaces.

can you post what you did to make it work exacly?

or can anyone clear this up?

Hello all,
I am currently writting a kiosk like application that has dual touch
screens. I have 2 SDL applications that I am trying to have run
simultaneously in fullscreen mode. I have 2 separate desktops :0.0 and
:0.1. If I initialize SDL into fullscreen mode, and run the
applicaiton on both desktops, only one of them will get the touch
inputs. If I start SDL in windowed mode, then pop it into fullscreen
mode via the WM_Fullscreen command, only one of the desktops will run,
until the other desktop has stopped.

Is there a way that I can run two fullscreen applications in SDL
simultaneously?

Robert

Dear Bob !

…snip
Instead of this you could use OpenGL to blit the software surface to the
full screen, or to any region of the screen you want. That means you
would never have to change the video mode.

Just learn to do blits in OpenGL. Not hard to do at all.
…snip

great great great… any known sample or anything i can start to learn to do
blits in OpenGL?

would be greatly appreciate!

thx

great great great… any known sample or anything i can start to learn to do
blits in OpenGL?

great great great… any known sample or anything i can start to learn to do
blits in OpenGL?

Make your SDL_Surfaces in a format compatible with an OpenGL texture
format (such as R8G8B8), upload them using glTexture2D(), and render
quads to the screen, possibly in ortho mode.

Dear Bob !

…snip
Instead of this you could use OpenGL to blit the software surface to the
full screen, or to any region of the screen you want. That means you
would never have to change the video mode.

Just learn to do blits in OpenGL. Not hard to do at all.
…snip

great great great… any known sample or anything i can start to learn to do
blits in OpenGL?

You could look at the source for SDL. The opengl_blit code is still in
there. You could look at glSDL for sample code. Or, you could read the
OpenGL documentation at
http://www.opengl.org/documentation/red_book_1.0/ and
http://www.opengl.org/documentation/blue_book_1.0/ or you could try
googling for it. Also, the NEHE tutorials may have something on the
subject.

would be greatly appreciate!

thx

Bob PendletonOn Wed, 2005-04-06 at 02:46 +0000, Golgoth! wrote:

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


±-------------------------------------+

Johannes Schmidt <sdl myrealbox.com> writes:
I have inserted putenv(“SDL_VIDEODRIVER=windib”); before the SDL calls.

you mean:

putenv(“SDL_VIDEODRIVER=windib”);
SDL_Surface *l_screen;
l_screen = SDL_SetVideoMode(640, 480, 32, SDL_HWSURFACE | SDL_FULLSCREEN);
l_screen = SDL_SetVideoMode(640, 480, 32, SDL_OPENGL | SDL_FULLSCREEN);

i dont understand what u mean… SDL_VIDEODRIVER is not even recongnize… so
is putenv… can you clear this up plz… it may solve my problem for now…

thx again!