A list of questions

Hi, I’ve got a list of questions…Please help.

  1. The system() function does not work on win-2000 after SDL_Init() call…
    Any fix or work around for this ? I would like to open a help.html in a
    browser window when the user presses F1 in the game. For this I want to use
    the system() function.

  2. What is difference between LOGICAL PALETTE and PHYSICAL PALETTE ? I am
    working with a set of 8-bit images, each having a same palette of 256
    colors. Also, what is the difference between SDL_SetColor() and
    SDL_SetPalette() ? When and how do I call these functions ? I mean do they
    need to be called on each single .gif that is loaded ?

  3. Is there a void PlayWave(char *FileName) kind of function to play wav
    files, in any of the libraries ?

  4. What is, in general, a callback function ? I’ve not used one
    before…

See ya,

  • Meetul Kinarivala

Hi, I’ve got a list of questions…Please help.

  1. The system() function does not work on win-2000 after SDL_Init() call…
    Any fix or work around for this ? I would like to open a help.html in a
    browser window when the user presses F1 in the game. For this I want to use
    the system() function.

Well, I’ve never really tried the system() function on Win-2000, nor do I use
Win-2000 SDL. But, I’ve used the Linux version of the system() function call and
it works perfectly. Only see to it that you dont grab all input that is sent to
the Window Manager, which in your case is Win2000, using the
SDL_WM_GrabInput(SDL_GRAB_ON). This causes problems in the sharing of input
focus between the Browser and your SDL application.

I might not be completely right, but if you post your code that does the
initializing and then calls the system() function, I might be able to look
through it and help you better.

  1. What is difference between LOGICAL PALETTE and PHYSICAL PALETTE ? I am
    working with a set of 8-bit images, each having a same palette of 256
    colors. Also, what is the difference between SDL_SetColor() and
    SDL_SetPalette() ? When and how do I call these functions ? I mean do they
    need to be called on each single .gif that is loaded ?

I cant really help you with this!

  1. Is there a void PlayWave(char *FileName) kind of function to play wav
    files, in any of the libraries ?

Well, you can use SDL Audio library. Its pretty easy and http://www.libsdl.org
has a few examples on how to load wav files and play them using call back
functions.

  1. What is, in general, a callback function ? I’ve not used one
    before…

Its a concept in the C programming language. It deals with function pointers.
Like normal variables have addresses in memory, so do functions. This means
that, if I could store the address of the function in a pointer, I could eaisly
call the function using that pointer. But the pointers used for this purpose are
a little different from the ones used for normal variables, when it comes to
declaring and assigning. Try this code snippet out and may be read up more on
pointers to functions before you can really understand callback functions.

#include <stdio.h>

void func1()
{
printf(“Hello\n”);
}

int main()
{
void (* p)(); /* Declaring a function pointer */

    p=func1;	/* Assigning the address of the pointer to the address of func1

/
p(); /
Calling func1 using the function pointer */
return 0;
}

Well, I hope I was of some help to you.

Bye,
Nishal.

  1. What is difference between LOGICAL PALETTE and PHYSICAL PALETTE
    ? I am working with a set of 8-bit images, each having a same
    palette of 256 colors. Also, what is the difference between
    SDL_SetColor() and SDL_SetPalette() ? When and how do I call these
    functions ? I mean do they need to be called on each single .gif
    that is loaded ?

According to the docs, the logical palette is used in blits to/from
the surface, while the physical palette is used when the hardware
will show that surface.

SDL_SetPalette modifies one or both of these palettes - SDL_SetColors
modifies both palettes, and is the same as calling SDL_SetPalette
with the flags (SDL_LOGPAL | SDL_PHYSPAL).

The advantage of this is that you can create effects like fading,
flashing, dimming, etc, by simply modifying the physical palette.

  1. What is, in general, a callback function ? I’ve not used
    one before…

It is a function that is called by fx. the library you are using when
it wants to do something special. That way you can determine what and
how it does this. For example, in a GUI, you might have a callback
function that is called whenever the user press a button. When this
happens, the lib calls the function you set it up to, and so, you can
set the behaviour of that button to whatever you like.–
Trick


Linux User #229006 * http://counter.li.org

Hi, I’ve got a list of questions…Please help.

  1. The system() function does not work on win-2000 after SDL_Init() call…
    Any fix or work around for this ? I would like to open a help.html in a
    browser window when the user presses F1 in the game. For this I want to
    use
    the system() function.

use ShellExecute, it will automatically determine the type of file (works
for any registered file type), and opens the assigned viewer.

I’ve included the PlatformSDK page for ShellExecute below, hope this helps.

Anthony

Now you see that evil will always triumph, because good is dumb.
– Dark Helmet
BxSci Alumnus '97

ShellExecute
Performs an operation on a specified file.

HINSTANCE ShellExecute(
HWND hwnd,
LPCTSTR lpOperation,
LPCTSTR lpFile,
LPCTSTR lpParameters,
LPCTSTR lpDirectory,
INT nShowCmd
);

Parameters
hwnd
[in] Handle to a parent window. This window receives any message boxes
that an application produces, such as error reporting.
lpOperation
[in] Pointer to a null-terminated string, referred to in this case as a
verb, that specifies the action to be performed. The set of available verbs
depends on the particular file or folder. Generally, the actions available
from an object’s shortcut menu are available verbs. For more information
about verbs and their availability, see Object Verbs. See Extending Shortcut
Menus for further discussion of shortcut menus. The following verbs are
commonly used.

    Verb Description
    edit  Launches an editor and opens the document for editing. If

lpFile is not a document file, the function will fail.
explore Explores the folder specified by lpFile.
find Initiates a search starting from the specified directory.
open Opens the file specified by the lpFile parameter. The file can
be an executable file, a document file, or a folder.
print Prints the document file specified by lpFile. If lpFile is
not a document file, the function will fail.

If you set this parameter to NULL:

a.. For systems prior to Microsoft? Windows? 2000, the default verb is

used if it is valid and available in the registry. If not, the “open” verb
is used.
b… For Windows 2000 and later systems, the default verb is used if
available. If not, the “open” verb is used. If neither verb is available,
the system uses the first verb listed in the registry.
lpFile
[in] Pointer to a null-terminated string that specifies the file or object
on which to execute the specified verb. To specify a Shell namespace object,
pass the fully-qualified parse name. Note that not all verbs are supported
on all objects. For example, not all document types support the "print"
verb.
lpParameters
[in] If the lpFile parameter specifies an executable file, lpParameters is
a pointer to a null-terminated string that specifies the parameters to be
passed to the application. The format of this string is determined by the
verb that is to be invoked. If lpFile specifies a document file,
lpParameters should be NULL.
lpDirectory
[in] Pointer to a null-terminated string that specifies the default
directory.
nShowCmd
[in] Flags that specify how an application is to be displayed when it is
opened. If lpFile specifies a document file, the flag is simply passed to
the associated application. It is up to the application to decide how to
handle it.

    SW_HIDE  Hides the window and activates another window.
    SW_MAXIMIZE  Maximizes the specified window.
    SW_MINIMIZE  Minimizes the specified window and activates the next

top-level window in the z-order.
SW_RESTORE Activates and displays the window. If the window is
minimized or maximized, Windows restores it to its original size and
position. An application should specify this flag when restoring a minimized
window.
SW_SHOW Activates the window and displays it in its current size
and position.
SW_SHOWDEFAULT Sets the show state based on the SW_ flag specified
in the STARTUPINFO structure passed to the CreateProcess function by the
program that started the application. An application should call ShowWindow
with this flag to set the initial show state of its main window.
SW_SHOWMAXIMIZED Activates the window and displays it as a
maximized window.
SW_SHOWMINIMIZED Activates the window and displays it as a
minimized window.
SW_SHOWMINNOACTIVE Displays the window as a minimized window. The
active window remains active.
SW_SHOWNA Displays the window in its current state. The active
window remains active.
SW_SHOWNOACTIVATE Displays a window in its most recent size and
position. The active window remains active.
SW_SHOWNORMAL Activates and displays a window. If the window is
minimized or maximized, Windows restores it to its original size and
position. An application should specify this flag when displaying the window
for the first time.

Return Values
Returns a value greater than 32 if successful, or an error value that is
less than or equal to 32 otherwise. The following table lists the error
values. The return value is cast as an HINSTANCE for backward compatibility
with 16-bit Microsoft? Windows? applications. It is not a true HINSTANCE,
however. The only thing that can be done with the returned HINSTANCE is to
cast it to an integer and compare it with the value 32 or one of the error
codes below.

  0  The operating system is out of memory or resources.
  ERROR_FILE_NOT_FOUND  The specified file was not found.
  ERROR_PATH_NOT_FOUND  The specified path was not found.
  ERROR_BAD_FORMAT  The .exe file is invalid (non-Win32? .exe or error

in .exe image).
SE_ERR_ACCESSDENIED The operating system denied access to the
specified file.
SE_ERR_ASSOCINCOMPLETE The file name association is incomplete or
invalid.
SE_ERR_DDEBUSY The DDE transaction could not be completed because
other DDE transactions were being processed.
SE_ERR_DDEFAIL The DDE transaction failed.
SE_ERR_DDETIMEOUT The DDE transaction could not be completed because
the request timed out.
SE_ERR_DLLNOTFOUND The specified dynamic-link library was not found.
SE_ERR_FNF The specified file was not found.
SE_ERR_NOASSOC There is no application associated with the given file
name extension. This error will also be returned if you attempt to print a
file that is not printable.
SE_ERR_OOM There was not enough memory to complete the operation.
SE_ERR_PNF The specified path was not found.
SE_ERR_SHARE A sharing violation occurred.

Remarks
This method allows you to execute any commands in a folder’s shortcut menu
or stored in the registry.

To open a folder, use either of the following calls:

ShellExecute(handle, NULL, path_to_folder, NULL, NULL, SW_SHOWNORMAL);

or

ShellExecute(handle, “open”, path_to_folder, NULL, NULL, SW_SHOWNORMAL);

To explore a folder, use:

ShellExecute(handle, “explore”, path_to_folder, NULL, NULL, SW_SHOWNORMAL);

To launch the Shell’s Find utility for a directory, use:

ShellExecute(handle, “find”, path_to_folder, NULL, NULL, 0);

If lpOperation is NULL, the function opens the file specified by lpFile. If
lpOperation is “open” or “explore”, the function will attempt to open or
explore the folder.

To obtain information about the application that is launched as a result of
calling ShellExecute, use ShellExecuteEx.

Windows 95/98/Me: ShellExecute is supported by the Microsoft Layer for
Unicode. To use this, you must add certain files to your application, as
outlined in Microsoft Layer for Unicode on Windows 95/98/Me Systems.

See Also
IShellExecuteHook

Requirements
Windows NT/2000: Requires Windows NT 3.1 or later.
Windows 95/98/Me: Requires Windows 95 or later.
Header: Declared in Shellapi.h.
Import Library: Shell32.lib.

----- Original Message -----
From: siliconmike@yahoo.com (Meetul Kinarivala)
To:
Sent: Saturday, September 29, 2001 4:03 PM
Subject: [SDL] A list of questions