mirror of
https://github.com/Kiritow/MiniEngine.git
synced 2024-03-22 13:11:22 +08:00
Add class UniRandom. (Random Number Generator)
This commit is contained in:
parent
d8e2bb9e2b
commit
e183a09f34
|
@ -31,11 +31,36 @@ std::string GetMD5(unsigned char* buffer,unsigned int bufferLen)
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
int CompareSurface(const Surface& surface1, const Surface& surface2, int allowableError)
|
/// Compare two surfaces. Currently, Surface::getRawPointer() does not has constant attribute.
|
||||||
|
int CompareSurface(Surface& surface1, Surface& surface2, int allowableError)
|
||||||
{
|
{
|
||||||
return SDLTest_CompareSurfaces(surface1.getRawPointer(),surface2.getRawPointer(),allowableError);
|
return SDLTest_CompareSurfaces(surface1.getRawPointer(),surface2.getRawPointer(),allowableError);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//private
|
||||||
|
struct UniRandom::_impl
|
||||||
|
{
|
||||||
|
SDLTest_RandomContext context;
|
||||||
|
};
|
||||||
|
|
||||||
|
UniRandom::UniRandom()
|
||||||
|
{
|
||||||
|
_sp.reset(new _impl);
|
||||||
|
SDLTest_RandomInitTime(&(_sp.get()->context));
|
||||||
|
}
|
||||||
|
|
||||||
|
UniRandom::UniRandom(unsigned int A, unsigned int B)
|
||||||
|
{
|
||||||
|
_sp.reset(new _impl);
|
||||||
|
SDLTest_RandomInit(&(_sp.get()->context),A,B);
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t UniRandom::get()
|
||||||
|
{
|
||||||
|
return SDLTest_Random(&(_sp.get()->context));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}/// End of namespace MiniEngine::Test
|
}/// End of namespace MiniEngine::Test
|
||||||
|
|
||||||
}/// End of namespace MiniEngine
|
}/// End of namespace MiniEngine
|
||||||
|
|
|
@ -12,6 +12,18 @@ std::string GetMD5(unsigned char* buffer,unsigned int bufferLen);
|
||||||
void GetMD5Raw(unsigned char* buffer,unsigned int bufferLen,unsigned char* outbuff);
|
void GetMD5Raw(unsigned char* buffer,unsigned int bufferLen,unsigned char* outbuff);
|
||||||
int CompareSurface(const Surface& surface1,const Surface& surface2,int allowableError);
|
int CompareSurface(const Surface& surface1,const Surface& surface2,int allowableError);
|
||||||
|
|
||||||
|
class UniRandom
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
/// Default Constructor is based on system current time.
|
||||||
|
UniRandom();
|
||||||
|
UniRandom(unsigned int A,unsigned int B);
|
||||||
|
uint32_t get();
|
||||||
|
private:
|
||||||
|
struct _impl;
|
||||||
|
std::shared_ptr<_impl> _sp;
|
||||||
|
};
|
||||||
|
|
||||||
}/// End of namespace MiniEngine::Test
|
}/// End of namespace MiniEngine::Test
|
||||||
|
|
||||||
}/// End of namespace MiniEngine
|
}/// End of namespace MiniEngine
|
||||||
|
|
Loading…
Reference in New Issue
Block a user