-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUtility.cpp
More file actions
76 lines (62 loc) · 1.41 KB
/
Utility.cpp
File metadata and controls
76 lines (62 loc) · 1.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#ifdef WIN32
#include <crtdbg.h>
#endif
#include <iostream>
#include <cassert>
#include <fstream>
#include <string>
#include <cerrno>
#include "IncludeGL.h"
#include "Utility.h"
namespace Utilities
{
void ReportError( const std::string& message )
{
std::cerr << message << std::endl;
#ifdef WIN32
MessageBoxA( NULL, message.c_str(), "ERROR", MB_ICONERROR );
#endif
}
void ReportMemoryLeaks()
{
#ifdef WIN32
assert( _CrtCheckMemory() );
_CrtDumpMemoryLeaks();
#endif
}
std::string GetFileContents(const char *filename)
{
std::ifstream in( filename, std::ios::in | std::ios::binary );
// If the file exists
if (in)
{
std::string contents;
// Reading the file
in.seekg( 0, std::ios::end );
contents.resize( static_cast< unsigned int >( in.tellg() ) );
in.seekg( 0, std::ios::beg );
in.read( &contents[0], contents.size() );
in.close();
return(contents);
}
throw( errno );
}
void OutPutText( float x, float y, int fontSize, unsigned const char* text )
{
#ifdef EMSCRIPTEN
#else
glDisable( GL_TEXTURE_2D );
glPushMatrix();
glRasterPos2f( x, y );
glutBitmapString( GLUT_BITMAP_TIMES_ROMAN_24, text );
glPopMatrix();
glEnable( GL_TEXTURE_2D );
#endif
}
}
void Drawing::ApplyTransformations( float x, float y, float angle, float scaleX, float scaleY )
{
glTranslatef( x, y, 0.0f );
glRotatef( angle, 0.0f, 0.0f, 1.0f );
glScalef( scaleX, scaleY, 1.0f );
}