00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #include "OSDLBezier.h"
00028
00029 #include "OSDLSurface.h"
00030 #include "OSDLPoint2D.h"
00031 #include "OSDLVideo.h"
00032
00033 #include "Ceylan.h"
00034
00035
00036
00037 #ifdef OSDL_USES_CONFIG_H
00038 #include <OSDLConfig.h>
00039 #endif // OSDL_USES_CONFIG_H
00040
00041
00042 #if OSDL_ARCH_NINTENDO_DS
00043 #include "OSDLConfigForNintendoDS.h"
00044 #endif // OSDL_ARCH_NINTENDO_DS
00045
00046
00047
00048 #if OSDL_USES_SDL_GFX
00049
00050 #include "SDL_gfxPrimitives.h"
00051
00052 #endif // OSDL_USES_SDL_GFX
00053
00054
00055
00056 using namespace OSDL::Video ;
00057
00058 using namespace Ceylan::Log ;
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068 bool TwoDimensional::drawBezierCurve(
00069 Surface & targetSurface,
00070 const listPoint2D & controlPoints,
00071 Ceylan::Uint16 numberOfSteps,
00072 Pixels::ColorElement red,
00073 Pixels::ColorElement green,
00074 Pixels::ColorElement blue,
00075 Pixels::ColorElement alpha )
00076 {
00077
00078 return drawBezierCurve( targetSurface, controlPoints, numberOfSteps,
00079 Pixels::convertRGBAToColorDefinition( red, green, blue, alpha ) ) ;
00080
00081 }
00082
00083
00084
00085 bool TwoDimensional::drawBezierCurve(
00086 Surface & targetSurface,
00087 const listPoint2D & controlPoints,
00088 Ceylan::Uint16 numberOfSteps,
00089 Pixels::ColorDefinition colorDef )
00090 {
00091
00092 #if OSDL_USES_SDL_GFX
00093
00094
00095
00096
00097
00098
00099 Ceylan::System::Size vertexCount = controlPoints.size() ;
00100
00101
00102
00103
00104
00105
00106 Coordinate * abscissaArray = new Coordinate[ vertexCount ] ;
00107 Coordinate * ordinateArray = new Coordinate[ vertexCount ] ;
00108
00109 vertexCount = 0 ;
00110
00111 for ( listPoint2D::const_iterator it = controlPoints.begin();
00112 it != controlPoints.end(); it++ )
00113 {
00114 abscissaArray[ vertexCount ] = (*it)->getX() ;
00115 ordinateArray[ vertexCount ] = (*it)->getY() ;
00116
00117 vertexCount++ ;
00118 }
00119
00120 int res = ::bezierColor( & targetSurface.getSDLSurface(),
00121 abscissaArray, ordinateArray,
00122 static_cast<int>( vertexCount ), numberOfSteps,
00123 Pixels::convertColorDefinitionToRawPixelColor( colorDef ) ) ;
00124
00125 delete [] abscissaArray ;
00126 delete [] ordinateArray ;
00127
00128 return ( res == 0 ) ;
00129
00130 #else // OSDL_USES_SDL_GFX
00131
00132 throw VideoException( "TwoDimensional::drawBezierCurve failed: "
00133 "no SDL_gfx support available" ) ;
00134
00135 #endif // OSDL_USES_SDL_GFX
00136
00137 }
00138