Video drivers on linux

I can’t get SDL to use any video drivers other than x11 on Linux. Code
is attached below; can someone tell me what I’m doing wrong?

The output is:

aalib – SDL_Init() failed: No available video device
fbcon – SDL_Init() failed: No available video device
ggi – SDL_Init() failed: No available video device
svgalib – SDL_Init() failed: No available video device
x11 – OK

System is SUSE 7.1, kernel 2.2.something, SDL 1.2.2, XFree86 4.0.2. Let
me know if any other information would be relevant.

--------------------- demo.cpp begins -------------------------
#include “SDL.h”
#include
#include
#include
#include
#include
#include <stdlib.h>

const std::string driver_var(“SDL_VIDEODRIVER”);

void test_sdl(const std::string& driver) {
std::cout << driver << " – ";
// Update the video driver environment variable
std::string env_str(driver_var + “=” + driver);
std::vector env(env_str.size() + 1);
std::memcpy(&env[0], env_str.c_str(), env.size());
if (putenv(&env[0]) != 0) {
std::cout << "putenv() failed: " << std::strerror(errno) << “\n”;
return;
}
// Check that it’s set correctly
const char* test_env(getenv(driver_var.c_str()));
if (test_env == 0) {
std::cout << “getenv() returned null\n”;
return;
}
if (test_env != driver) {
std::cout << “getenv() returned “” << test_env << “”\n”;
return;
}
// Try to initialise SDL
if (SDL_Init(SDL_INIT_VIDEO) != 0) {
std::cout << "SDL_Init() failed: " << SDL_GetError() << “\n”;
return;
}
std::cout << “OK\n”;
SDL_Quit();
}

int main() {
test_sdl(“aalib”);
test_sdl(“fbcon”);
test_sdl(“ggi”);
test_sdl(“svgalib”);
test_sdl(“x11”);
return 0;
}
--------------------- demo.cpp ends ---------------------------

--------------------- Makefile begins -------------------------
NAME = demo
BUILD = gcc
BUILD_DIR = build/$(BUILD)_$(OSTYPE:-gnu=)
SDL_CFLAGS = $(shell sdl-config --cflags)
SDL_LIBS = $(shell sdl-config --libs)
CPLUS = g++
CDEFINES = -D_REENTRANT -D_XOPEN_SOURCE=500
CFLAGS = -ansi -pedantic -W -Wall -Werror
LD = g++
LDFLAGS = -s
LDLIBS =
OBJECTS = $(BUILD_DIR)/demo.o
TARGET = $(BUILD_DIR)/$(NAME)

$(BUILD_DIR)/%.o: %.cpp
$(CPLUS) $(CDEFINES) $(CFLAGS) $(SDL_CFLAGS) -c $< -o $@

.DELETE_ON_ERROR:

.PHONY: all clean test

all: $(TARGET)

clean:
-rm -rf $(BUILD_DIR)

test: $(TARGET)
$(TARGET)

$(BUILD_DIR):
mkdir -p $(BUILD_DIR)

$(TARGET): $(BUILD_DIR) $(OBJECTS)
$(LD) $(LDFLAGS) $(OBJECTS) $(SDL_LIBS) $(LDLIBS) -o $(TARGET)

$(BUILD_DIR)/demo.o: demo.cpp
--------------------- Makefile ends -----------------------------
Ross Smith … ross.s at ihug.co.nz
Ihug (Auckland, New Zealand) … http://www.ihug.co.nz/

       Vs lbh pna ernq guvf, lbh'er ivbyngvat gur QZPN

The output is:

aalib – SDL_Init() failed: No available video device

I think you’ll find that test_sdl(“dkfskdjfsdkfj”) will give you the same
result. You need to make sure that the driver is compiled into your SDL
library, and that external things it needs (like fbcon kernel support for
the fbcon driver, etc) exist.

–ryan.

“Ryan C. Gordon” wrote:

The output is:

aalib – SDL_Init() failed: No available video device

I think you’ll find that test_sdl(“dkfskdjfsdkfj”) will give you the same
result. You need to make sure that the driver is compiled into your SDL
library, and that external things it needs (like fbcon kernel support for
the fbcon driver, etc) exist.

It occurred to me that it might be something like that, but I downloaded
the source tarball and I can’t find anything in there, or anywhere on
the SDL web site, about compiling with or without support for any
particular drivers (or for that matter about any kind of compilation
options at all). The version I’m using is the SDl-1.2.2-1.i386.rpm from
the main SDL download page. Does that only have support for x11? If so,
how do I get support for anything else? (And why doesn’t the download
page warn about this?)–
Ross Smith … ross.s at ihug.co.nz
Ihug (Auckland, New Zealand) … http://www.ihug.co.nz/

       Vs lbh pna ernq guvf, lbh'er ivbyngvat gur QZPN

If so, how do I get support for anything else? (And why doesn’t the
download page warn about this?)

try “./configure --help” in you SDL source directory it will list all
options (also the ones for the supported video devices) which you can
use with the configure script to change compilation behaviour.

Live long and prosper /,

  • Zordan Ehrwald

Zordan Ehrwald wrote:

If so, how do I get support for anything else? (And why doesn’t the
download page warn about this?)

try “./configure --help” in you SDL source directory it will list all
options (also the ones for the supported video devices) which you can
use with the configure script to change compilation behaviour.

Oh, thanks. Yes, that looks helpful. Unfortunately it means
I’ll have to distribute a custom-built SDL.so along with my game, but it
looks like there’s no way around that.

I’d like to suggest to the SDL maintainers that, if there’s some
technical reason why you have to distribute a lowest-common-denominator
version of the library, it might be a good idea to say something about
this on the web site. Presumably everyone who uses SDL, at least with
anything other than the bog standard video driver, has had to go through
this same game of twenty questions.–
Ross Smith … ross.s at ihug.co.nz
Ihug (Auckland, New Zealand) … http://www.ihug.co.nz/

       Vs lbh pna ernq guvf, lbh'er ivbyngvat gur QZPN