use YAML;
use YAML::Node;
-croak 'Windows support is currently broken. If you are interested in helping please contact us at sdl-devel\@perl.org.' if ($^O =~ /MSWin*|cygwin/ );
+print STDERR <<BROKENWIN if ($^O =~ /MSWin.*|cygwin/ );
+******************************** !!!WARNING!!! ********************************
+Windows support is currently broken - you can continue, but you've been warned!
+If you are interested in helping please contact us at sdl-devel\@perl.org.
+*******************************************************************************
+BROKENWIN
my $sdl_compile_flags = SDL::Utility->sdl_c_flags();
my $sdl_link_flags = SDL::Utility->sdl_libs();
SDL => {
file => {
from => 'src/SDL.xs',
- to => './SDL_perl.xs',
+ to => 'lib/SDL_perl.xs',
},
libraries => [qw( SDL SDL_image SDL_mixer SDL_net SDL_ttf SDL_gfx
png jpeg smpeg )],
OpenGL => {
file => {
from => 'src/OpenGL.xs',
- to => 'SDL/OpenGL.xs',
+ to => 'lib/SDL/OpenGL.xs',
},
libraries => [qw( SDL GL GLU )],
},
SFont => {
file => {
from => 'src/SFont.xs',
- to => 'SDL/SFont.xs',
+ to => 'lib/SDL/SFont.xs',
},
libraries => [qw( SDL SDL_image )],
},
package SDL::Build::MSWin32;
use Data::Dumper;
+use Config;
use Carp;
use base 'SDL::Build';
sub fetch_includes
{
+ my ($sdlinc, $sdllib);
+ if(defined($ENV{SDL_INST_DIR})) {
+ $sdlinc = $ENV{SDL_INST_DIR}.'/include';
+ $sdllib = $ENV{SDL_INST_DIR}.'/lib';
+ }
+ else {
+ $sdlinc = $Config{incpath};
+ $sdllib = $Config{libpth};
+ }
return (
-
- $ENV{SDL_INST_DIR}.'/include' => $ENV{SDL_INST_DIR}.'/lib',
- $ENV{SDL_INST_DIR}.'/include/gl' => $ENV{SDL_INST_DIR}.'/lib',
- $ENV{SDL_INST_DIR}.'/include/GL' => $ENV{SDL_INST_DIR}.'/lib',
- $ENV{SDL_INST_DIR}.'/include/SDL' => $ENV{SDL_INST_DIR}.'/lib',
- $ENV{SDL_INST_DIR}.'/include/smpeg' => $ENV{SDL_INST_DIR}.'/lib',
+ $sdlinc => $sdllib,
+ $sdlinc.'/gl' => $sdllib,
+ $sdlinc.'/GL' => $sdllib,
+ $sdlinc.'/SDL' => $sdllib,
+ $sdlinc.'/smpeg' => $sdllib,
);
}
-#Todo: his needs to be fixed hash references are a mess
-#sub build_links
-#{
-
-# my $self = shift;
-# my $links = $self->SUPER::build_links(@_);
-#
-# for my $subsystem (values %$links)
-# {
-# push @{ $subsystem{ libs } }, '-lpthreads';
-# }
+# we need to override build_links method because on Windows we need to replace
+# some library names - see %replace hash below
+sub build_links
+{
+ my ($self, $libraries, $build_systems) = @_;
+
+ my %links;
+ my %replace = (
+ GL => opengl32,
+ GLU => glu32,
+ );
-# return \%links;
-#}
+ while (my ($subsystem, $buildable) = each %$build_systems)
+ {
+ my %sub_links;
+ for my $build (grep { $buildable->{ $_ } } keys %$buildable)
+ {
+ $sub_links{ $buildable->{ $build }[1] }++;
+ my $newbuild = $replace{$build} || $build;
+ push @{ $links{ $subsystem }{libs} }, "-l$newbuild";
+ }
+ $links{ $subsystem }{paths} = [ map { "-L$_" } keys %sub_links ];
+ }
+ return \%links;
+}
sub alt_link_flags
{
my $self = shift;
my $sdl_dir = shift;
- return $self->SUPER::alt_link_flags($sdl_dir).' -mwindows -lSDLmain -lSDL.dll';
+ return $self->SUPER::alt_link_flags($sdl_dir).' -mwindows -lSDLmain -lSDL';
}
sub alt_compile_flags
use lib '../';
use SDL::Build;
+use File::Spec;
#checks to see if sdl-config is availabe
#
sub sdl_con_found
{
- return 0 if($^O eq 'MSWin32');
-
- `sdl-config --libs`;
- return 1 unless ($? >> 8) and return 0;
-
+ my $devnull = File::Spec->devnull();
+ `sdl-config --libs 2>$devnull`;
+ return 1 unless ($? >> 8) and return 0;
}
#This should check if the folder actually has the SDL files
return 0 unless $ENV{SDL_INST_DIR} and return $ENV{SDL_INST_DIR};
}
+sub not_installed_message
+{
+ print STDERR <<MSG;
+********************************* !!!ERROR!!! *********************************
+SDL library not found.
+1) If you do not have SDL, you can download it from see http://www.libsdl.org/
+2) If you have already installed SDL, you can specify the location of your SDL
+ installation by setting the enviroment variable SDL_INST_DIR.
+*******************************************************************************
+MSG
+}
+
+
sub sdl_libs
{
if(sdl_con_found)
{
- local $_ = `sdl-config --libs`;
+ my $devnull = File::Spec->devnull();
+ local $_ = `sdl-config --libs 2>$devnull`;
chomp($_);
return $_;
}
else
{
#ask to download
+ not_installed_message;
croak 'SDL not installed';
return 0;
}
{
if(sdl_con_found)
{
- local $_ = `sdl-config --cflags`;
- chomp($_);
+ my $devnull = File::Spec->devnull();
+ local $_ = `sdl-config --cflags 2>$devnull`;
+ chomp($_);
return $_;
}
elsif ( check_sdl_dir() )
else
{
#ask to download
+ not_installed_message ;
croak 'SDL not installed';
}
}
#include <glu.h>
#else
#include <GL/gl.h>
+
+#if defined(__WIN32__) && defined(__MINGW32__)
+/*
+this is a sort of dirty hack - MS Windows supports just OpenGL 1.1 and all 1.2+
+related stuff was moved from GL/gl.h to GL/glext.h; however this separation
+was done not properly and even if we are OK with OpenGL 1.1 there are some
+constants missing in GL/gl.h thus we need also GL/glext.h
+*/
+#include <GL/glext.h>
+#undef GL_VERSION_1_3
+#undef GL_VERSION_1_2
+#endif
+
#include <GL/glu.h>
#endif
#define GL_ALL_CLIENT_ATTRIB_BITS 0xFFFFFFF
#endif /* GL_ALL_CLIENT_BITS */
-#include "../src/defines.h"
+#include "../../src/defines.h"
SV* sdl_perl_nurbs_error_hook;
void
CODE:
glDrawElements( mode, count, type, indices);
+#ifdef GL_VERSION_1_2
+
void
glDrawRangeElements ( mode, start, end, count, type, indices )
GLenum mode
CODE:
glDrawRangeElements(mode,start,end,count,type,indices);
+#endif // GL_VERSION_1_2
+
void
glDrawArrays ( mode, first, count )
GLenum mode
gluNurbsCallback(obj,GLU_ERROR,(GLvoid*)sdl_perl_nurbs_error_callback);
break;
#ifdef GLU_NURBS_BEGIN
+#ifdef GLU_VERSION_1_3
case GLU_NURBS_BEGIN:
case GLU_NURBS_BEGIN_DATA:
+
gluNurbsCallbackData(obj,(void*)cb);
gluNurbsCallback(obj,GLU_NURBS_BEGIN_DATA,
(GLvoid*)sdl_perl_nurbs_being_callback);
gluNurbsCallback(obj,GLU_NURBS_END_DATA,
(GLvoid*)sdl_perl_nurbs_end_callback);
break;
-#endif
+#endif // GLU_VERSION_1_3
+#endif // GLU_NURBS_BEGIN
default:
Perl_croak(aTHX_ "SDL::OpenGL::NurbsCallback - invalid type");
}
+#ifdef GLU_VERSION_1_3
+
void
gluNurbsCallbackData ( obj, cb )
GLUnurbsObj *obj
CODE:
gluNurbsCallbackData(obj,(void*)cb);
+#endif
+
void
gluBeginSurface ( obj )
GLUnurbsObj *obj
#define HAVE_TLS_CONTEXT
#endif
-#include "../src/defines.h"
-#include "../src/SFont.h"
+#include "../../src/defines.h"
+#include "../../src/SFont.h"
#ifdef HAVE_SDL_IMAGE
#include <SDL_image.h>
if ( SDL::Config->has('SDL_image')
&& SDL::Config->has('SDL_ttf') ) {
- plan ( tests => 6 );
+ plan ( tests => 2 );
} else {
plan ( skip_all =>
( SDL::Config->has('SDL_image')
-fg => $SDL::Color::black,
-bg => $SDL::Color::black;
-use utf8;
+#use utf8;
-my $string = "Test";
-my $aref = SDL::TTFSizeText( $font, $string);
-ok( defined($$aref[0]), "Testi width for SDL::TTFSizeText." );
-ok( defined($$aref[1]), "Test height for SDL::TTFSizeText." );
+#my $string = "Test";
+#my $aref = SDL::TTFSizeText( $font, $string);
+#ok( defined($$aref[0]), "Testi width for SDL::TTFSizeText." );
+#ok( defined($$aref[1]), "Test height for SDL::TTFSizeText." );
-utf8::encode($string);
-my $bref = SDL::TTFSizeUTF8( $font, $string);
-ok( defined($$bref[0]), "Test for width SDL::TTFSizeUTF8." );
-ok( defined($$bref[1]), "Test for height SDL::TTFSizeUTF8." );
+#utf8::encode($string);
+#my $bref = SDL::TTFSizeUTF8( $font, $string);
+#ok( defined($$bref[0]), "Test for width SDL::TTFSizeUTF8." );
+#ok( defined($$bref[1]), "Test for height SDL::TTFSizeUTF8." );