Windows NT4 issues (Steve Lupton)

Message: 13

Hi

SDL on Win32 uses DirectX 5 or later for its hardware acceleration. Windows
NT 4 only supports DirectX 3.

I am not speaking completely authoritatively on this matter but I do suspect
that this is where your problem lies. Perhaps someone else can confirm this?

Either you are creating a memory leak, or SDL is - why don’t you post a code
fragment showing what you are doing?

Someone else on the list will be able to confirm the behaviour you are
seeing, or point out where the problem is.

Regards,

Steve

Steve, the hypothesis that DirectX incompatibility is the cause of my
problems is a good one. Following your suggestion, here is my test
program. You’ll see that only SDL_SetPalette() gets called repeatedly.

//Program paldemo.c

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

#include “SDL.h”

#define NXPIXELS 1024
#define NYPIXELS 768
#define NBITSPP 8

void make_demo(void);
void make_basepal(void);
void make_pal(int paloffset);
void make_block(int ix0, int iy0, int nxpix, int nypix, Uint32 colour);
void interrogate_video(void);
int InitGraphics(Uint32 video_flags);

SDL_Surface *video=NULL;
SDL_Color base_colors[256];

int
main(int argc, char *argv[])
{
int i,j,k,err;
int paloffset=0;
int ncycles=0;
clock_t start,end;
Uint32 video_flags;

if (argc == 2) {
	k = sscanf(argv[1],"%d",&ncycles);
}
else {
	printf("Usage: paldemo ncycles\n");
	printf("       ncycles is the number of times to cycle through the

palette\n");
printf("\n");
ncycles = 1;
}
printf(“ncycles: %d\n”,ncycles);
video_flags = SDL_SWSURFACE|SDL_FULLSCREEN; //|SDL_DOUBLEBUF;
err = InitGraphics(video_flags);
if (err != 0) {
printf(“InitGraphics failed: %d\n”,err);
return(1);
}
interrogate_video();
if (ncycles == 0)
exit(1);

make_basepal();
if ( SDL_MUSTLOCK(video) ) {
	printf("MUSTLOCK\n");
	SDL_LockSurface(video);
}
make_demo();
if ( SDL_MUSTLOCK(video) )
	SDL_UnlockSurface(video);

for(i=0;i<ncycles;i++) {
	start = clock();
	for(j=0;j<256;j++) {
		paloffset = (paloffset+1)%256;
		make_pal(paloffset);
	}
	end = clock();
	printf("Cycle: %d  seconds:

%f\n",i,(double)(end-start)/CLOCKS_PER_SEC);
}
SDL_Quit();
return(0);
}

void
make_demo(void)
{
Uint16 ix,i;

for(i=0;i<256;i++) {
	ix = 4*i;
	make_block(ix,0,4,NYPIXELS,i);
}

}

void
make_basepal(void)
{
int i;

for(i=0;i<256;i++){
	base_colors[i].r=i;
	base_colors[i].g=i;
	base_colors[i].b=0;
}

}

void
make_pal(int paloffset)
{
int i,j;
SDL_Color colors[256];

for(i=0;i<256;i++){
	j = i + paloffset;
	if (j > 255) j -= 256;
	if (j < 0) j += 256;
	colors[i].r = base_colors[j].r;
	colors[i].g = base_colors[j].g;
	colors[i].b = base_colors[j].b;
}
SDL_SetPalette(video, SDL_PHYSPAL, colors, 0, 256);

}

void
make_block(int ix0, int iy0, int nxpix, int nypix, Uint32 colour)
{
SDL_Rect r;
r.x = (Sint16)ix0;
r.y = (Sint16)iy0;
r.w = (Uint16)nxpix;
r.h = (Uint16)nypix;
SDL_FillRect(video, &r, colour);
}

int
InitGraphics(Uint32 video_flags)
{
Uint8 i;

if (SDL_Init(SDL_INIT_VIDEO) < 0) {
	fprintf(stderr,"Couldn't initialize SDL: %s\n",SDL_GetError());
	return(1);
}
video = SDL_SetVideoMode(NXPIXELS, NYPIXELS, NBITSPP, video_flags);
if ( video == NULL ) {
	fprintf(stderr,"Couldn't set a %dx%d video mode: %s\n",
						NXPIXELS,NYPIXELS,SDL_GetError());
	return(2);
}
printf("Set %dx%dx%d video mode\n",
		video->w, video->h, video->format->BitsPerPixel);

/* We ignore all but keyboard events */
for ( i = 0; i<SDL_NUMEVENTS; ++i ) {
	if ( (i != SDL_KEYDOWN) && (i != SDL_QUIT) ) {
		SDL_EventState(i, SDL_IGNORE);
	}
}
atexit(SDL_Quit);

return(0);

}

void
interrogate_video(void)
{
char namebuf[256];
int maxlen=256;
SDL_VideoInfo *vinfo=NULL;

SDL_VideoDriverName(namebuf, maxlen);
printf("Video driver: %s\n",namebuf);
vinfo = SDL_GetVideoInfo();
if (vinfo->hw_available == 1)
	printf("Hardware surfaces are available\n");
else
	printf("Hardware surfaces are NOT available\n");
if (vinfo->wm_available == 1)
	printf("Window manager is available\n");
else
	printf("Window manager is NOT available\n");
if (vinfo->blit_hw == 1)
	printf("Hardware to hardware blits are accelerated\n");
else
	printf("Hardware to hardware blits are NOT accelerated\n");
if (vinfo->blit_hw_CC == 1)
	printf("Hardware to hardware colorkey blits are accelerated\n");
else
	printf("Hardware to hardware colorkey blits are NOT accelerated\n");
if (vinfo->blit_hw_A == 1)
	printf("Hardware to hardware alpha blits are accelerated\n");
else
	printf("Hardware to hardware alpha blits are NOT accelerated\n");
if (vinfo->blit_sw == 1)
	printf("Software to hardware blits are accelerated\n");
else
	printf("Software to hardware blits are NOT accelerated\n");
if (vinfo->blit_sw_CC == 1)
	printf("Software to hardware colorkey blits are accelerated\n");
else
	printf("Software to hardware colorkey blits are NOT accelerated\n");
if (vinfo->blit_sw_A == 1)
	printf("Software to hardware alpha blits are accelerated\n");
else
	printf("Software to hardware alpha blits are NOT accelerated\n");
if (vinfo->blit_fill == 1)
	printf("Color fills are accelerated\n");
else
	printf("Color fills are NOT accelerated\n");
printf("Video memory: %d Kb\n",vinfo->video_mem);
printf("\n");

}> From: Steve Lupton

To: “‘sdl at libsdl.org’”
Subject: RE: [SDL] Re: Windows NT4 issues
Date: Tue, 25 Dec 2001 16:02:07 -0000
Reply-To: sdl at libsdl.org