├── Executables
├── linux_distro
│ └── trycl
└── windows_64
│ └── Graphulator.exe
├── GRAPHULATOR_Source
├── .idea
│ ├── .name
│ ├── codeStyles
│ │ └── Project.xml
│ ├── misc.xml
│ ├── modules.xml
│ ├── trycl.iml
│ └── workspace.xml
├── CMakeLists.txt
├── GRAPHULATOR
├── expression
│ ├── addExpression.h
│ ├── baseExpression.h
│ ├── divideExpression.h
│ ├── expressions.h
│ ├── lnExpression.h
│ ├── logExpression.h
│ ├── modExpression.h
│ ├── multiplyExpression.h
│ ├── numberExpression.h
│ ├── powExpression.h
│ ├── rpnBuilder.cpp
│ ├── rpnBuilder.h
│ ├── subtractExpression.h
│ ├── token.cpp
│ ├── token.h
│ ├── trigExpression.h
│ └── variableExpression.h
├── glut.h
├── main.cpp
└── md_res
│ ├── five.png
│ ├── four.png
│ ├── one.png
│ ├── three.png
│ └── two.png
├── LICENSE
├── README.md
├── Report
├── DOCUMENTATION-1final.pdf
├── DOCUMENTATION.docx
├── Presentation.pdf
└── Presentation.pptx
├── build.sh
└── todo.readme
/Executables/linux_distro/trycl:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CRLannister/Graphical-Calculator-OpenGL-CPlusPlus/24937f685051a89fa71f015c1dd779eaf1710b9b/Executables/linux_distro/trycl
--------------------------------------------------------------------------------
/Executables/windows_64/Graphulator.exe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CRLannister/Graphical-Calculator-OpenGL-CPlusPlus/24937f685051a89fa71f015c1dd779eaf1710b9b/Executables/windows_64/Graphulator.exe
--------------------------------------------------------------------------------
/GRAPHULATOR_Source/.idea/.name:
--------------------------------------------------------------------------------
1 | trycl
--------------------------------------------------------------------------------
/GRAPHULATOR_Source/.idea/codeStyles/Project.xml:
--------------------------------------------------------------------------------
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 |
--------------------------------------------------------------------------------
/GRAPHULATOR_Source/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/GRAPHULATOR_Source/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/GRAPHULATOR_Source/.idea/trycl.iml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/GRAPHULATOR_Source/.idea/workspace.xml:
--------------------------------------------------------------------------------
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 |
75 |
76 |
77 |
78 |
79 | true
80 | DEFINITION_ORDER
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
127 |
128 |
129 |
130 |
131 |
132 |
133 |
134 |
135 |
136 |
137 |
138 |
139 |
140 |
141 |
142 |
143 |
144 |
145 |
146 |
147 |
148 |
149 |
150 |
151 |
152 |
153 | 1519549001150
154 |
155 |
156 | 1519549001150
157 |
158 |
159 |
160 |
161 |
162 |
163 |
164 |
165 |
166 |
167 |
168 |
169 |
170 |
171 |
172 |
173 |
174 |
175 |
176 |
177 |
178 |
179 |
180 |
181 |
182 |
183 |
184 |
185 |
186 |
187 |
188 |
189 |
190 |
191 |
192 |
193 |
194 |
195 |
196 |
197 |
198 |
199 |
200 |
201 |
202 |
203 |
204 |
205 |
206 |
207 |
208 |
209 |
210 |
211 |
212 |
213 |
214 |
215 |
216 |
217 |
218 |
219 |
220 |
221 |
222 |
223 |
224 |
225 |
226 |
227 |
228 |
229 |
230 |
231 |
232 |
233 |
234 |
235 |
236 |
237 |
238 |
239 |
240 |
241 |
242 |
243 |
244 |
245 |
246 |
247 |
248 |
249 |
250 |
251 |
252 |
253 |
254 |
255 |
256 |
257 |
258 |
259 |
260 |
261 |
262 |
263 |
264 |
265 |
266 |
267 |
268 |
269 |
270 |
271 |
272 |
273 |
274 |
275 |
276 |
277 |
278 |
279 |
280 |
281 |
282 |
283 |
284 |
285 |
286 |
287 |
288 |
289 |
290 |
291 |
292 |
293 |
294 |
295 |
296 |
297 |
298 |
299 |
300 |
301 |
302 |
303 |
304 |
305 |
306 |
307 |
308 |
309 |
310 |
311 |
312 |
313 |
314 |
315 |
316 |
317 |
318 |
319 |
320 |
321 |
322 |
323 |
324 |
325 |
326 |
327 |
328 |
329 |
330 |
331 |
332 |
333 |
334 |
335 |
336 |
337 |
338 |
339 |
340 |
341 |
342 |
343 |
344 |
345 |
346 |
347 |
348 |
349 |
350 |
351 |
352 |
353 |
354 |
355 |
356 |
357 |
358 |
359 |
360 |
361 |
362 |
363 |
364 |
365 |
366 |
367 |
368 |
369 |
370 |
371 |
372 |
373 |
374 |
--------------------------------------------------------------------------------
/GRAPHULATOR_Source/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 3.7)
2 | project(trycl)
3 |
4 | find_package(OpenGL REQUIRED)
5 | find_package(GLUT REQUIRED)
6 | include_directories( ${OPENGL_INCLUDE_DIRS} ${GLUT_INCLUDE_DIRS} )
7 |
8 |
9 | set(CMAKE_CXX_STANDARD 11)
10 |
11 | add_executable(trycl main.cpp expression/addExpression.h expression/baseExpression.h expression/divideExpression.h expression/expressions.h expression/lnExpression.h expression/logExpression.h expression/modExpression.h expression/multiplyExpression.h expression/numberExpression.h expression/powExpression.h expression/rpnBuilder.h expression/subtractExpression.h expression/token.h expression/trigExpression.h expression/variableExpression.h expression/token.cpp expression/rpnBuilder.cpp)
12 | target_link_libraries(${PROJECT_NAME} ${OPENGL_LIBRARIES} ${GLUT_LIBRARY} )
13 |
--------------------------------------------------------------------------------
/GRAPHULATOR_Source/GRAPHULATOR:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CRLannister/Graphical-Calculator-OpenGL-CPlusPlus/24937f685051a89fa71f015c1dd779eaf1710b9b/GRAPHULATOR_Source/GRAPHULATOR
--------------------------------------------------------------------------------
/GRAPHULATOR_Source/expression/addExpression.h:
--------------------------------------------------------------------------------
1 |
2 |
3 | #ifndef TRYCL_ADDEXPRESSION_H
4 | #define TRYCL_ADDEXPRESSION_H
5 | #include "baseExpression.h"
6 |
7 | ///Addition operation in the expression tree. Adds two expressions together.
8 | class AddExpression : public BaseExpression
9 | {
10 |
11 | public:
12 |
13 | ///Constructs an addition expression from a left and right expression
14 | AddExpression(BaseExpression* pLeft, BaseExpression* pRight)
15 | {
16 | mLeft = pLeft;
17 | mRight = pRight;
18 | }
19 |
20 | ///Destroys this expression
21 | ~AddExpression()
22 | {
23 | delete mLeft;
24 | delete mRight;
25 | }
26 |
27 | ///Evaluates the expression at the point pX, pY
28 | inline virtual float evaluate(float pX, float pY)
29 | {
30 | return mLeft->evaluate(pX, pY) + mRight->evaluate(pX, pY);
31 | }
32 |
33 | ///Prints the expression to the console
34 | virtual void printExpression()
35 | {
36 | printf("(");
37 | mLeft->printExpression();
38 | printf(" + ");
39 | mRight->printExpression();
40 | printf(")");
41 | }
42 |
43 | };
44 | #endif //TRYCL_ADDEXPRESSION_H
45 |
--------------------------------------------------------------------------------
/GRAPHULATOR_Source/expression/baseExpression.h:
--------------------------------------------------------------------------------
1 |
2 |
3 | #ifndef TRYCL_BASEEXPRESSION_H
4 | #define TRYCL_BASEEXPRESSION_H
5 | #include
6 | #include
7 |
8 | ///The base expression class from which all other expression types are derived
9 | class BaseExpression
10 | {
11 |
12 | protected:
13 |
14 | ///The left hand side of the expression, either another expression, a variable or a number
15 | BaseExpression* mLeft;
16 |
17 | ///The right hand side of the expression
18 | BaseExpression* mRight;
19 |
20 | public:
21 |
22 | ///Constructs a new expression
23 | BaseExpression()
24 | {
25 | mLeft = mRight = 0;
26 | }
27 |
28 | ///Constructs an expression from two sides
29 | BaseExpression(BaseExpression* pLeft, BaseExpression* pRight)
30 | {
31 | mLeft = pLeft;
32 | mRight = pRight;
33 | }
34 |
35 | ///Destroys an expression
36 | ~BaseExpression()
37 | {
38 | if(mLeft)
39 | delete mLeft;
40 |
41 | if(mRight)
42 | delete mRight;
43 | }
44 |
45 |
46 | ///Evaluates the expression at the point pX, pY
47 | inline virtual float evaluate(float pX, float pY) = 0;
48 |
49 | ///Prints the expression
50 | virtual void printExpression() = 0;
51 | };
52 |
53 | #endif //TRYCL_BASEEXPRESSION_H
54 |
--------------------------------------------------------------------------------
/GRAPHULATOR_Source/expression/divideExpression.h:
--------------------------------------------------------------------------------
1 |
2 | #ifndef TRYCL_DIVIDEEXPRESSION_H
3 | #define TRYCL_DIVIDEEXPRESSION_H
4 | #include "baseExpression.h"
5 |
6 | ///A division expression class
7 | class DivideExpression : public BaseExpression
8 | {
9 |
10 | public:
11 |
12 | ///Constructs a new division expression from a left and right side
13 | DivideExpression(BaseExpression* pLeft, BaseExpression* pRight)
14 | {
15 | mLeft = pLeft;
16 | mRight = pRight;
17 | }
18 |
19 | ///Destroys this division expression
20 | ~DivideExpression()
21 | {
22 | delete mLeft;
23 | delete mRight;
24 | }
25 |
26 | ///Evaluates the expression at pX,pY, and returns infinity when dividing by 0
27 | inline virtual float evaluate(float pX, float pY)
28 | {
29 | float lRight = mRight->evaluate(pX, pY);
30 |
31 | if(lRight == 0)
32 | return INFINITY;
33 |
34 | return mLeft->evaluate(pX, pY) / lRight;
35 | }
36 |
37 | ///Prints the expression
38 | virtual void printExpression()
39 | {
40 | printf("(");
41 | mLeft->printExpression();
42 | printf(" / ");
43 | mRight->printExpression();
44 | printf(")");
45 | }
46 | };
47 | #endif //TRYCL_DIVIDEEXPRESSION_H
48 |
--------------------------------------------------------------------------------
/GRAPHULATOR_Source/expression/expressions.h:
--------------------------------------------------------------------------------
1 |
2 | #ifndef __APPLE__
3 |
4 | #include "baseExpression.h"
5 | #include "addExpression.h"
6 | #include "divideExpression.h"
7 | #include "lnExpression.h"
8 | #include "logExpression.h"
9 | #include "modExpression.h"
10 | #include "multiplyExpression.h"
11 | #include "numberExpression.h"
12 | #include "powExpression.h"
13 | #include "subtractExpression.h"
14 | #include "trigExpression.h"
15 | #include "variableExpression.h"
16 | #include "rpnBuilder.h"
17 | #include "token.h"
18 |
19 | #else
20 |
21 | #include "expression/baseExpression.h"
22 | #include "expression\addExpression.h"
23 | #include "expression\divideExpression.h"
24 | #include "expression\multiplyExpression.h"
25 | #include "expression\numberExpression.h"
26 | #include "expression\powExpression.h"
27 | #include "expression\subtractExpression.h"
28 | #include "expression\variableExpression.h"
29 | #include "RPN/rpnBuilder.h"
30 | #include "RPN/token.h"
31 |
32 | #endif
33 |
34 |
35 | BaseExpression* processString(std::string s)
36 | {
37 | RPNBuilder* builder = new RPNBuilder();
38 | std::vector vec = builder->convertToRPN(s);
39 |
40 | std::stack lExpression;
41 | for(int i =0; i
6 |
7 | ///A natural log expression that computes log(left), with base e
8 | class LnExpression : public BaseExpression
9 | {
10 |
11 | public:
12 |
13 | ///Constructs a power expression
14 | LnExpression(BaseExpression* pLeft, BaseExpression* pRight)
15 | {
16 | mLeft = pLeft;
17 | mRight = pRight;
18 | }
19 |
20 | ///Destructs the expression
21 | ~LnExpression()
22 | {
23 | delete mLeft;
24 | delete mRight;
25 | }
26 |
27 | ///Evaluates this expression, i.e compute mLeft^mRight
28 | inline virtual float evaluate(float pX, float pY)
29 | {
30 | return log(mLeft->evaluate(pX,pY));
31 | }
32 |
33 | ///Prints the expression
34 | virtual void printExpression()
35 | {
36 | printf("ln(");
37 | mLeft->printExpression();
38 | printf(")");
39 | }
40 | };
41 |
42 | #endif //TRYCL_LNEXPRESSION_H
43 |
--------------------------------------------------------------------------------
/GRAPHULATOR_Source/expression/logExpression.h:
--------------------------------------------------------------------------------
1 |
2 | #ifndef TRYCL_LOGEXPRESSION_H
3 | #define TRYCL_LOGEXPRESSION_H
4 | #include "baseExpression.h"
5 | #include
6 |
7 | ///A log expression that computes log(left), with base 10
8 | class LogExpression : public BaseExpression
9 | {
10 |
11 | public:
12 |
13 | ///Constructs a power expression
14 | LogExpression(BaseExpression* pLeft, BaseExpression* pRight)
15 | {
16 | mLeft = pLeft;
17 | mRight = pRight;
18 | }
19 |
20 | ///Destructs the expression
21 | ~LogExpression()
22 | {
23 | delete mLeft;
24 | delete mRight;
25 | }
26 |
27 | ///Evaluates this expression, i.e compute mLeft^mRight
28 | inline virtual float evaluate(float pX, float pY)
29 | {
30 | return log10(mLeft->evaluate(pX,pY));
31 | }
32 |
33 | ///Prints the expression
34 | virtual void printExpression()
35 | {
36 | printf("log(");
37 | mLeft->printExpression();
38 | printf(")");
39 | }
40 | };
41 |
42 | #endif //TRYCL_LOGEXPRESSION_H
43 |
--------------------------------------------------------------------------------
/GRAPHULATOR_Source/expression/modExpression.h:
--------------------------------------------------------------------------------
1 | #ifndef TRYCL_MODEXPRESSION_H
2 | #define TRYCL_MODEXPRESSION_H
3 | #include "baseExpression.h"
4 |
5 | ///Modulo operation in the expression tree. Computes left % right.
6 | class ModExpression : public BaseExpression
7 | {
8 |
9 | public:
10 |
11 | ///Constructs an addition expression from a left and right expression
12 | ModExpression(BaseExpression* pLeft, BaseExpression* pRight)
13 | {
14 | mLeft = pLeft;
15 | mRight = pRight;
16 | }
17 |
18 | ///Destroys this expression
19 | ~ModExpression()
20 | {
21 | delete mLeft;
22 | delete mRight;
23 | }
24 |
25 | ///Evaluates the expression at the point pX, pY
26 | inline virtual float evaluate(float pX, float pY)
27 | {
28 | return fmod(mLeft->evaluate(pX, pY),mRight->evaluate(pX, pY));
29 | }
30 |
31 | ///Prints the expression to the console
32 | virtual void printExpression()
33 | {
34 | printf("(");
35 | mLeft->printExpression();
36 | printf(" %% ");
37 | mRight->printExpression();
38 | printf(")");
39 | }
40 |
41 | };
42 | #endif //TRYCL_MODEXPRESSION_H
43 |
--------------------------------------------------------------------------------
/GRAPHULATOR_Source/expression/multiplyExpression.h:
--------------------------------------------------------------------------------
1 |
2 | #ifndef TRYCL_MULTIPLYEXPRESSION_H
3 | #define TRYCL_MULTIPLYEXPRESSION_H
4 | #include "baseExpression.h"
5 |
6 | ///A multiplication expression class
7 | class MultiplyExpression : public BaseExpression
8 | {
9 |
10 | public:
11 |
12 | ///Constructs a new multiplication expression from a left and right expression
13 | MultiplyExpression(BaseExpression* pLeft, BaseExpression* pRight)
14 | {
15 | mLeft = pLeft;
16 | mRight = pRight;
17 | }
18 |
19 | ///Destructs this multiplication expression
20 | ~MultiplyExpression()
21 | {
22 | delete mLeft;
23 | delete mRight;
24 | }
25 |
26 | ///Evaluates the expression at the point pX, pY
27 | inline virtual float evaluate(float pX, float pY)
28 | {
29 | return mLeft->evaluate(pX, pY) * mRight->evaluate(pX, pY);
30 | }
31 |
32 | ///Prints this expression
33 | virtual void printExpression()
34 | {
35 | printf("(");
36 | mLeft->printExpression();
37 | printf(" * ");
38 | mRight->printExpression();
39 | printf(")");
40 | }
41 | };
42 |
43 | #endif //TRYCL_MULTIPLYEXPRESSION_H
44 |
--------------------------------------------------------------------------------
/GRAPHULATOR_Source/expression/numberExpression.h:
--------------------------------------------------------------------------------
1 |
2 | #ifndef TRYCL_NUMBEREXPRESSION_H
3 | #define TRYCL_NUMBEREXPRESSION_H
4 | #include "baseExpression.h"
5 |
6 | ///A numeric expression that simply evaluates to it's assigned float value
7 | class NumberExpression : public BaseExpression
8 | {
9 |
10 | protected:
11 |
12 | ///The value of this numeric expression
13 | float mValue;
14 |
15 | public:
16 |
17 | ///Constructs a new numeric expression from a float value
18 | NumberExpression(float pValue)
19 | {
20 | mLeft = 0;
21 | mRight = 0;
22 | mValue = pValue;
23 | }
24 |
25 | ///Destructs this numeric expression
26 | ~NumberExpression()
27 | {
28 |
29 | }
30 |
31 | ///Returns the numeric value of this expression
32 | inline virtual float evaluate(float pX, float pY)
33 | {
34 | return mValue;
35 | }
36 |
37 | ///Prints this expression
38 | virtual void printExpression()
39 | {
40 | printf("%f",mValue);
41 | }
42 | };
43 |
44 | #endif //TRYCL_NUMBEREXPRESSION_H
45 |
--------------------------------------------------------------------------------
/GRAPHULATOR_Source/expression/powExpression.h:
--------------------------------------------------------------------------------
1 |
2 | #ifndef TRYCL_POWEXPRESSION_H
3 | #define TRYCL_POWEXPRESSION_H
4 | #include "baseExpression.h"
5 | #include
6 |
7 | ///A exponent expression that raises the left side to the power of the right side
8 | class PowerExpression : public BaseExpression
9 | {
10 |
11 | public:
12 |
13 | ///Constructs a power expression
14 | PowerExpression(BaseExpression* pLeft, BaseExpression* pRight)
15 | {
16 | mLeft = pLeft;
17 | mRight = pRight;
18 | }
19 |
20 | ///Destructs the expression
21 | ~PowerExpression()
22 | {
23 | delete mLeft;
24 | delete mRight;
25 | }
26 |
27 | ///Evaluates this expression, i.e compute mLeft^mRight
28 | inline virtual float evaluate(float pX, float pY)
29 | {
30 | return pow(mLeft->evaluate(pX, pY),mRight->evaluate(pX, pY));
31 | }
32 |
33 | ///Prints the expression
34 | virtual void printExpression()
35 | {
36 | printf("(");
37 | mLeft->printExpression();
38 | printf(" ^ ");
39 | mRight->printExpression();
40 | printf(")");
41 | }
42 | };
43 | #endif //TRYCL_POWEXPRESSION_H
44 |
--------------------------------------------------------------------------------
/GRAPHULATOR_Source/expression/rpnBuilder.cpp:
--------------------------------------------------------------------------------
1 |
2 | #include "rpnBuilder.h"
3 |
4 | using namespace std;
5 |
6 | /*
7 | * RPNBuilder Constructor.
8 | * Just fills the Operator List. Must be called for the class to work properly.
9 | */
10 | RPNBuilder::RPNBuilder ( )
11 | {
12 | opList = "()*+-/^";
13 | }
14 |
15 | std::vector RPNBuilder::toRPN ( std::vector mother )
16 | {
17 | vector output;//Output Stack
18 | stack opStack; //Operator Stack
19 | string op; //operator in string type
20 | int oplvl; //operator level
21 |
22 | //TOKEN LOOP
23 | for(int i= 0; i RPNBuilder::convertToRPN ( std::string expression )
102 | {
103 | preprocessString(expression);
104 | return toRPN ( buildTokenList ( expression ));
105 | }
106 |
107 | void RPNBuilder::preprocessString ( std::string &s )
108 | {
109 | //Removes all the spaces...cuz I don't like them in there.. Seriously.
110 | for ( int i = 0; i < s.length(); i++ )
111 | {
112 | if ( s[i] == ' ' )
113 | {
114 | s.erase(s.begin()+i);
115 | i = 0;
116 | }
117 | }
118 | }
119 |
120 | /*
121 | * RPNBuilder.findInOpList ( char c )
122 | * Just there to help in seeing whether a character is an operator.
123 | */
124 | int RPNBuilder::findInOpList ( char c )
125 | {
126 | for ( int i = 0; (i < 7) && (c >= opList[i]); i++ )
127 | if ( c == opList[i] )
128 | return i;
129 | return -1;
130 | }
131 |
132 | /*
133 | * RPNBuilder.buildTokenList ( std::string expression )
134 | * Preprocesses the string into tokens that represent a Literal value, Operator or Variable.
135 | *
136 | * Warning: Any unusual tokens are just IGNORED at the moment. There is no error checking.
137 | */
138 | std::vector RPNBuilder::buildTokenList ( std::string s )
139 | {
140 | std::vector tokenList = std::vector();
141 |
142 | TokenType currState = eBase;
143 | std::string temp = "";
144 |
145 | for ( int i = 0; i < s.length(); i++ )
146 | {
147 | switch ( currState )
148 | {
149 | case eBase:
150 | temp += s[i];
151 | if ( s[i] >= 48 && s[i] <= 57 )
152 | {
153 | //Definitely some sort of literal.
154 | currState = eLiteral;
155 | }
156 | else if ( ( s[i] >= 65 && s[i] <= 90 ) || ( s[i] >= 97 && s[i] <= 122 ) )
157 | {
158 | //Definitely a character
159 | currState = eVariable;
160 | }
161 | else if ( findInOpList ( s[i] ) >= 0 )
162 | {
163 | //Operator
164 | currState = eOperator;
165 | }
166 | else
167 | {
168 | //Really Weird input?! ignore.
169 | }
170 | break;
171 |
172 | case eVariable:
173 | //Gotta check whether the variable name continues...
174 | if ( ( s[i] >= 65 && s[i] <= 90 )
175 | || ( s[i] >= 97 && s[i] <= 122 )
176 | || ( s[i] >= 48 && s[i] <= 57 ) )
177 | temp += s[i];
178 | else
179 | {
180 | //Variable name ended...gotta put it into the token list and place
181 | // the new character into a new temporary token.
182 | tokenList.push_back(Token(currState,temp));
183 | temp = s[i];
184 | if ( s[i] >= 48 && s[i] <= 57 )
185 | currState = eLiteral;
186 | else if ( ( s[i] >= 65 && s[i] <= 90 ) || ( s[i] >= 97 && s[i] <= 122 ) )
187 | currState = eVariable;
188 | else if ( findInOpList ( s[i] ) >= 0 )
189 | currState = eOperator;
190 | }
191 | break;
192 |
193 | case eLiteral:
194 | //Literals are numbers...including decimal place :)
195 | if ( (s[i] >= 48 && s[i] <= 57) || (s[i]=='.') )
196 | temp += s[i];
197 | else
198 | {
199 | tokenList.push_back(Token(currState,temp));
200 | temp = s[i];
201 | if ( s[i] >= 48 && s[i] <= 57 )
202 | currState = eLiteral;
203 | else if ( ( s[i] >= 65 && s[i] <= 90 ) || ( s[i] >= 97 && s[i] <= 122 ) )
204 | currState = eVariable;
205 | else if ( findInOpList ( s[i] ) >= 0 )
206 | currState = eOperator;
207 | }
208 | break;
209 |
210 | case eOperator:
211 | //Just push it into the token list and put the next character into a new state.
212 | tokenList.push_back(Token(currState,temp));
213 | temp = s[i];
214 | if ( s[i] >= 48 && s[i] <= 57 )
215 | currState = eLiteral;
216 | else if ( ( s[i] >= 65 && s[i] <= 90 ) || ( s[i] >= 97 && s[i] <= 122 ) )
217 | currState = eVariable;
218 | else if ( findInOpList ( s[i] ) >= 0 )
219 | currState = eOperator;
220 | break;
221 | }
222 | }
223 | tokenList.push_back(Token(currState,temp));
224 | return tokenList;
225 | }
226 |
227 |
--------------------------------------------------------------------------------
/GRAPHULATOR_Source/expression/rpnBuilder.h:
--------------------------------------------------------------------------------
1 |
2 | #ifndef TRYCL_RPNBUILDER_H
3 | #define TRYCL_RPNBUILDER_H
4 | #include "token.h"
5 | #include
6 | #include
7 |
8 | ///Converts an expression into reverse polish notation for easy processing
9 | class RPNBuilder
10 | {
11 |
12 | private:
13 |
14 | char* opList;
15 |
16 | std::vector buildTokenList ( std::string s );
17 | std::vector toRPN ( std::vector );
18 |
19 | int findInOpList ( char v );
20 | int opLevel(std::string op);
21 | void preprocessString ( std::string &s ) ;
22 |
23 | public:
24 |
25 | RPNBuilder();
26 | std::vector convertToRPN ( std::string expression );
27 | };
28 |
29 | #endif //TRYCL_RPNBUILDER_H
30 |
--------------------------------------------------------------------------------
/GRAPHULATOR_Source/expression/subtractExpression.h:
--------------------------------------------------------------------------------
1 |
2 |
3 | #ifndef TRYCL_SUBTRACTEXPRESSION_H
4 | #define TRYCL_SUBTRACTEXPRESSION_H
5 | #include "baseExpression.h"
6 |
7 | //A subtraction operation
8 | class SubtractExpression : public BaseExpression
9 | {
10 |
11 | public:
12 |
13 | ///Creates a new subtraction expression
14 | SubtractExpression(BaseExpression* pLeft, BaseExpression* pRight)
15 | {
16 | mLeft = pLeft;
17 | mRight = pRight;
18 | }
19 |
20 | ///Destroys the expression
21 | ~SubtractExpression()
22 | {
23 | delete mLeft;
24 | delete mRight;
25 | }
26 |
27 | ///Evaluates the expression at pX, pY
28 | inline virtual float evaluate(float pX, float pY)
29 | {
30 | return mLeft->evaluate(pX, pY) - mRight->evaluate(pX, pY);
31 | }
32 |
33 | ///Prints the expression
34 | virtual void printExpression()
35 | {
36 | printf("(");
37 | mLeft->printExpression();
38 | printf(" - ");
39 | mRight->printExpression();
40 | printf(")");
41 | }
42 |
43 | };
44 |
45 | #endif //TRYCL_SUBTRACTEXPRESSION_H
46 |
--------------------------------------------------------------------------------
/GRAPHULATOR_Source/expression/token.cpp:
--------------------------------------------------------------------------------
1 |
2 | #include "token.h"
3 |
4 | //Constructs a token from a string representation and type
5 | Token::Token(TokenType pType, std::string pRepresentation)
6 | {
7 | mType = pType;
8 | mValue = pRepresentation;
9 | }
10 |
11 | //Constructs a literal token from a double value
12 | Token::Token(double pValue)
13 | {
14 | mValueAsFloat = pValue;
15 | mType = eLiteral;
16 | }
17 |
18 | //Returns the float value of the token, for literals
19 | double Token::getValue()
20 | {
21 | return mValueAsFloat;
22 | }
23 |
24 | //Returns the type of token
25 | TokenType Token::getType()
26 | {
27 | return mType;
28 | }
29 |
30 | //Return the string representation of the token
31 | std::string Token::toString()
32 | {
33 | return mValue;
34 | }
35 |
--------------------------------------------------------------------------------
/GRAPHULATOR_Source/expression/token.h:
--------------------------------------------------------------------------------
1 |
2 |
3 | #ifndef TRYCL_TOKEN_H
4 | #define TRYCL_TOKEN_H
5 | #include
6 |
7 | //The type for this token, i.e whether it's an operator, numerical literal or variable
8 | enum TokenType
9 | {
10 | //Non-used type, generic
11 | eBase,
12 |
13 | //A literal number, i.e. "5" or "100.022"
14 | eLiteral,
15 |
16 | //A variable, i.e. "x" or "y"
17 | eVariable,
18 |
19 | //An operator, i.e +,/,^, tan, etc
20 | eOperator
21 | };
22 |
23 | enum OperatorType
24 | {
25 | eAddition,
26 | eSubtraction,
27 |
28 | eMultiplication,
29 |
30 | eDivision,
31 |
32 | eMod,
33 |
34 | ePower,
35 | eRoot,
36 | eLog,
37 | eLn,
38 |
39 | eSin,
40 | eCos,
41 | eTan,
42 |
43 | eASin,
44 | eACos,
45 | eATan,
46 |
47 | eSinH,
48 | eCosH,
49 | eTanH,
50 |
51 | eASinH,
52 | eACosH,
53 | eATanH
54 |
55 | };
56 |
57 | //A class for storing a single token in an input string
58 | class Token
59 | {
60 | protected:
61 |
62 | //The string representation of the token
63 | std::string mValue;
64 |
65 | //The type of token
66 | TokenType mType;
67 |
68 | //The value of the token as a float, for literals
69 | double mValueAsFloat;
70 |
71 | public:
72 |
73 | //Constructs a token from a string representation and type
74 | Token(TokenType pType, std::string pRepresentation);
75 |
76 | //Constructs a literal token from a double value
77 | Token(double pValue);
78 |
79 | //Return the string representation of the token
80 | std::string toString();
81 |
82 | //Returns the float value of the token, for literals
83 | double getValue();
84 |
85 | //Returns the type of token
86 | TokenType getType();
87 | };
88 |
89 | #endif //TRYCL_TOKEN_H
90 |
--------------------------------------------------------------------------------
/GRAPHULATOR_Source/expression/trigExpression.h:
--------------------------------------------------------------------------------
1 |
2 | #ifndef TRYCL_TRIGEXPRESSION_H
3 | #define TRYCL_TRIGEXPRESSION_H
4 | #include "token.h"
5 | #include "baseExpression.h"
6 |
7 |
8 | ///A trig expression class
9 | class TrigExpression : public BaseExpression
10 | {
11 |
12 | protected:
13 |
14 | OperatorType mTrigFunction;
15 |
16 |
17 | public:
18 |
19 | ///Constructs a new multiplication expression from a left and right expression
20 | TrigExpression(BaseExpression* pLeft, OperatorType pTrigFunction)
21 | {
22 | mLeft = pLeft;
23 | mTrigFunction = pTrigFunction;
24 | }
25 |
26 | ///Destructs this multiplication expression
27 | ~TrigExpression()
28 | {
29 | delete mLeft;
30 | }
31 |
32 | ///Evaluates the expression at the point pX, pY
33 | inline virtual float evaluate(float pX, float pY)
34 | {
35 | float lLeft = mLeft->evaluate(pX,pY);
36 | float lVal = 0.0f;
37 |
38 | switch(mTrigFunction)
39 | {
40 | case eSin:
41 | lVal = sin(lLeft);
42 | break;
43 |
44 | case eCos:
45 | lVal = cos(lLeft);
46 | break;
47 |
48 | case eTan:
49 | lVal = tan(lLeft);
50 | break;
51 |
52 |
53 | case eASin:
54 | lVal = asin(lLeft);
55 | break;
56 |
57 | case eACos:
58 | lVal = acos(lLeft);
59 | break;
60 |
61 | case eATan:
62 | lVal = atan(lLeft);
63 | break;
64 |
65 | default:
66 | break;
67 |
68 | }
69 |
70 | return lVal;
71 | }
72 |
73 | ///Prints this expression
74 | virtual void printExpression()
75 | {
76 | char* lStrRep;
77 |
78 | switch(mTrigFunction)
79 | {
80 | case eSin:
81 | lStrRep = "sin(";
82 | break;
83 |
84 | case eCos:
85 | lStrRep = "cos(";
86 | break;
87 |
88 | case eTan:
89 | lStrRep = "tan";
90 | break;
91 |
92 |
93 | case eASin:
94 | lStrRep = "asin(";
95 | break;
96 |
97 | case eACos:
98 | lStrRep = "acos(";
99 | break;
100 |
101 | case eATan:
102 | lStrRep = "atan(";
103 | break;
104 |
105 | default:
106 | break;
107 |
108 | }
109 |
110 | printf(lStrRep);
111 | mLeft->printExpression();
112 | printf(")");
113 | }
114 | };
115 |
116 | #endif //TRYCL_TRIGEXPRESSION_H
117 |
--------------------------------------------------------------------------------
/GRAPHULATOR_Source/expression/variableExpression.h:
--------------------------------------------------------------------------------
1 | #ifndef TRYCL_VARIABLEEXPRESSION_H
2 | #define TRYCL_VARIABLEEXPRESSION_H
3 | #include "baseExpression.h"
4 |
5 | //An expression that can contain a variable representation, in this case x or y
6 | class VariableExpression : public BaseExpression
7 | {
8 | protected:
9 |
10 | //The variable type, x=true and y= false
11 | bool mVariable;
12 |
13 | public:
14 |
15 | //Constructs a new VariableExpression
16 | VariableExpression(bool pVariable)
17 | {
18 | mVariable = pVariable;
19 | }
20 |
21 | //Destroys this variable expression
22 | ~VariableExpression()
23 | {
24 | }
25 |
26 | //Evaluates this variable expressions
27 | inline virtual float evaluate(float pX, float pY)
28 | {
29 | //Return pX if this is an x variable, or pY if this a y
30 | if(mVariable)
31 | return pX;
32 | else
33 | return pY;
34 | }
35 |
36 | //Prints this expression
37 | virtual void printExpression()
38 | {
39 | if(mVariable)
40 | printf("x");
41 | else
42 | printf("y");
43 | }
44 | };
45 |
46 | //Global X and Y variables, since we only really need one instance of each
47 | static VariableExpression* gXVar = new VariableExpression(true);
48 | static VariableExpression* gYVar = new VariableExpression(false);
49 |
50 | //Defines to make them easy to access and see
51 | #define XVAR gXVar
52 | #define YVAR gYVar
53 |
54 | #endif //TRYCL_VARIABLEEXPRESSION_H
55 |
--------------------------------------------------------------------------------
/GRAPHULATOR_Source/glut.h:
--------------------------------------------------------------------------------
1 | #ifndef __glut_h__
2 | #define __glut_h__
3 |
4 | /* Copyright (c) Mark J. Kilgard, 1994, 1995, 1996, 1998. */
5 |
6 | /* This program is freely distributable without licensing fees and is
7 | provided without guarantee or warrantee expressed or implied. This
8 | program is -not- in the public domain. */
9 |
10 | #if defined(_WIN32)
11 |
12 | /* GLUT 3.7 now tries to avoid including
13 | to avoid name space pollution, but Win32's
14 | needs APIENTRY and WINGDIAPI defined properly. */
15 | # if 0
16 | /* This would put tons of macros and crap in our clean name space. */
17 | # define WIN32_LEAN_AND_MEAN
18 | # include
19 | # else
20 | /* XXX This is from Win32's */
21 | # ifndef APIENTRY
22 | # define GLUT_APIENTRY_DEFINED
23 | # if (_MSC_VER >= 800) || defined(_STDCALL_SUPPORTED) || defined(__BORLANDC__) || defined(__LCC__)
24 | # define APIENTRY __stdcall
25 | # else
26 | # define APIENTRY
27 | # endif
28 | # endif
29 | /* XXX This is from Win32's */
30 | # ifndef CALLBACK
31 | # if (defined(_M_MRX000) || defined(_M_IX86) || defined(_M_ALPHA) || defined(_M_PPC)) && !defined(MIDL_PASS) || defined(__LCC__)
32 | # define CALLBACK __stdcall
33 | # else
34 | # define CALLBACK
35 | # endif
36 | # endif
37 | /* XXX Hack for lcc compiler. It doesn't support __declspec(dllimport), just __stdcall. */
38 | # if defined( __LCC__ )
39 | # undef WINGDIAPI
40 | # define WINGDIAPI __stdcall
41 | # else
42 | /* XXX This is from Win32's and */
43 | # ifndef WINGDIAPI
44 | # define GLUT_WINGDIAPI_DEFINED
45 | # define WINGDIAPI __declspec(dllimport)
46 | # endif
47 | # endif
48 | /* XXX This is from Win32's */
49 | # ifndef _WCHAR_T_DEFINED
50 | typedef unsigned short wchar_t;
51 | # define _WCHAR_T_DEFINED
52 | # endif
53 | # endif
54 |
55 | /* To disable automatic library usage for GLUT, define GLUT_NO_LIB_PRAGMA
56 | in your compile preprocessor options. */
57 | # if !defined(GLUT_BUILDING_LIB) && !defined(GLUT_NO_LIB_PRAGMA)
58 | # pragma comment (lib, "winmm.lib") /* link with Windows MultiMedia lib */
59 | /* To enable automatic SGI OpenGL for Windows library usage for GLUT,
60 | define GLUT_USE_SGI_OPENGL in your compile preprocessor options. */
61 | # ifdef GLUT_USE_SGI_OPENGL
62 | # pragma comment (lib, "opengl.lib") /* link with SGI OpenGL for Windows lib */
63 | # pragma comment (lib, "glu.lib") /* link with SGI OpenGL Utility lib */
64 | # pragma comment (lib, "glut.lib") /* link with Win32 GLUT for SGI OpenGL lib */
65 | # else
66 | # pragma comment (lib, "opengl32.lib") /* link with Microsoft OpenGL lib */
67 | # pragma comment (lib, "glu32.lib") /* link with Microsoft OpenGL Utility lib */
68 | # pragma comment (lib, "glut32.lib") /* link with Win32 GLUT lib */
69 | # endif
70 | # endif
71 |
72 | /* To disable supression of annoying warnings about floats being promoted
73 | to doubles, define GLUT_NO_WARNING_DISABLE in your compile preprocessor
74 | options. */
75 | # ifndef GLUT_NO_WARNING_DISABLE
76 | # pragma warning (disable:4244) /* Disable bogus VC++ 4.2 conversion warnings. */
77 | # pragma warning (disable:4305) /* VC++ 5.0 version of above warning. */
78 | # endif
79 |
80 | /* Win32 has an annoying issue where there are multiple C run-time
81 | libraries (CRTs). If the executable is linked with a different CRT
82 | from the GLUT DLL, the GLUT DLL will not share the same CRT static
83 | data seen by the executable. In particular, atexit callbacks registered
84 | in the executable will not be called if GLUT calls its (different)
85 | exit routine). GLUT is typically built with the
86 | "/MD" option (the CRT with multithreading DLL support), but the Visual
87 | C++ linker default is "/ML" (the single threaded CRT).
88 |
89 | One workaround to this issue is requiring users to always link with
90 | the same CRT as GLUT is compiled with. That requires users supply a
91 | non-standard option. GLUT 3.7 has its own built-in workaround where
92 | the executable's "exit" function pointer is covertly passed to GLUT.
93 | GLUT then calls the executable's exit function pointer to ensure that
94 | any "atexit" calls registered by the application are called if GLUT
95 | needs to exit.
96 |
97 | Note that the __glut*WithExit routines should NEVER be called directly.
98 | To avoid the atexit workaround, #define GLUT_DISABLE_ATEXIT_HACK. */
99 |
100 | /* XXX This is from Win32's */
101 | # if !defined(_MSC_VER) && !defined(__cdecl)
102 | /* Define __cdecl for non-Microsoft compilers. */
103 | # define __cdecl
104 | # define GLUT_DEFINED___CDECL
105 | # endif
106 | # ifndef _CRTIMP
107 | # ifdef _NTSDK
108 | /* Definition compatible with NT SDK */
109 | # define _CRTIMP
110 | # else
111 | /* Current definition */
112 | # ifdef _DLL
113 | # define _CRTIMP __declspec(dllimport)
114 | # else
115 | # define _CRTIMP
116 | # endif
117 | # endif
118 | # define GLUT_DEFINED__CRTIMP
119 | # endif
120 |
121 | /* GLUT API entry point declarations for Win32. */
122 | # ifdef GLUT_BUILDING_LIB
123 | # define GLUTAPI __declspec(dllexport)
124 | # else
125 | # ifdef _DLL
126 | # define GLUTAPI __declspec(dllimport)
127 | # else
128 | # define GLUTAPI extern
129 | # endif
130 | # endif
131 |
132 | /* GLUT callback calling convention for Win32. */
133 | # define GLUTCALLBACK __cdecl
134 |
135 | #endif /* _WIN32 */
136 |
137 | #include
138 | #include
139 |
140 | #ifdef __cplusplus
141 | extern "C" {
142 | #endif
143 |
144 | #if defined(_WIN32)
145 | # ifndef GLUT_BUILDING_LIB
146 | extern _CRTIMP void __cdecl exit(int);
147 | # endif
148 | #else
149 | /* non-Win32 case. */
150 | /* Define APIENTRY and CALLBACK to nothing if we aren't on Win32. */
151 | # define APIENTRY
152 | # define GLUT_APIENTRY_DEFINED
153 | # define CALLBACK
154 | /* Define GLUTAPI and GLUTCALLBACK as below if we aren't on Win32. */
155 | # define GLUTAPI extern
156 | # define GLUTCALLBACK
157 | /* Prototype exit for the non-Win32 case (see above). */
158 | extern void exit(int);
159 | #endif
160 |
161 | /**
162 | GLUT API revision history:
163 |
164 | GLUT_API_VERSION is updated to reflect incompatible GLUT
165 | API changes (interface changes, semantic changes, deletions,
166 | or additions).
167 |
168 | GLUT_API_VERSION=1 First public release of GLUT. 11/29/94
169 |
170 | GLUT_API_VERSION=2 Added support for OpenGL/GLX multisampling,
171 | extension. Supports new input devices like tablet, dial and button
172 | box, and Spaceball. Easy to query OpenGL extensions.
173 |
174 | GLUT_API_VERSION=3 glutMenuStatus added.
175 |
176 | GLUT_API_VERSION=4 glutInitDisplayString, glutWarpPointer,
177 | glutBitmapLength, glutStrokeLength, glutWindowStatusFunc, dynamic
178 | video resize subAPI, glutPostWindowRedisplay, glutKeyboardUpFunc,
179 | glutSpecialUpFunc, glutIgnoreKeyRepeat, glutSetKeyRepeat,
180 | glutJoystickFunc, glutForceJoystickFunc (NOT FINALIZED!).
181 | **/
182 | #ifndef GLUT_API_VERSION /* allow this to be overriden */
183 | #define GLUT_API_VERSION 3
184 | #endif
185 |
186 | /**
187 | GLUT implementation revision history:
188 |
189 | GLUT_XLIB_IMPLEMENTATION is updated to reflect both GLUT
190 | API revisions and implementation revisions (ie, bug fixes).
191 |
192 | GLUT_XLIB_IMPLEMENTATION=1 mjk's first public release of
193 | GLUT Xlib-based implementation. 11/29/94
194 |
195 | GLUT_XLIB_IMPLEMENTATION=2 mjk's second public release of
196 | GLUT Xlib-based implementation providing GLUT version 2
197 | interfaces.
198 |
199 | GLUT_XLIB_IMPLEMENTATION=3 mjk's GLUT 2.2 images. 4/17/95
200 |
201 | GLUT_XLIB_IMPLEMENTATION=4 mjk's GLUT 2.3 images. 6/?/95
202 |
203 | GLUT_XLIB_IMPLEMENTATION=5 mjk's GLUT 3.0 images. 10/?/95
204 |
205 | GLUT_XLIB_IMPLEMENTATION=7 mjk's GLUT 3.1+ with glutWarpPoitner. 7/24/96
206 |
207 | GLUT_XLIB_IMPLEMENTATION=8 mjk's GLUT 3.1+ with glutWarpPoitner
208 | and video resize. 1/3/97
209 |
210 | GLUT_XLIB_IMPLEMENTATION=9 mjk's GLUT 3.4 release with early GLUT 4 routines.
211 |
212 | GLUT_XLIB_IMPLEMENTATION=11 Mesa 2.5's GLUT 3.6 release.
213 |
214 | GLUT_XLIB_IMPLEMENTATION=12 mjk's GLUT 3.6 release with early GLUT 4 routines + signal handling.
215 |
216 | GLUT_XLIB_IMPLEMENTATION=13 mjk's GLUT 3.7 beta with GameGLUT support.
217 |
218 | GLUT_XLIB_IMPLEMENTATION=14 mjk's GLUT 3.7 beta with f90gl friend interface.
219 |
220 | GLUT_XLIB_IMPLEMENTATION=15 mjk's GLUT 3.7 beta sync'ed with Mesa
221 | **/
222 | #ifndef GLUT_XLIB_IMPLEMENTATION /* Allow this to be overriden. */
223 | #define GLUT_XLIB_IMPLEMENTATION 15
224 | #endif
225 |
226 | /* Display mode bit masks. */
227 | #define GLUT_RGB 0
228 | #define GLUT_RGBA GLUT_RGB
229 | #define GLUT_INDEX 1
230 | #define GLUT_SINGLE 0
231 | #define GLUT_DOUBLE 2
232 | #define GLUT_ACCUM 4
233 | #define GLUT_ALPHA 8
234 | #define GLUT_DEPTH 16
235 | #define GLUT_STENCIL 32
236 | #if (GLUT_API_VERSION >= 2)
237 | #define GLUT_MULTISAMPLE 128
238 | #define GLUT_STEREO 256
239 | #endif
240 | #if (GLUT_API_VERSION >= 3)
241 | #define GLUT_LUMINANCE 512
242 | #endif
243 |
244 | /* Mouse buttons. */
245 | #define GLUT_LEFT_BUTTON 0
246 | #define GLUT_MIDDLE_BUTTON 1
247 | #define GLUT_RIGHT_BUTTON 2
248 |
249 | /* Mouse button state. */
250 | #define GLUT_DOWN 0
251 | #define GLUT_UP 1
252 |
253 | #if (GLUT_API_VERSION >= 2)
254 | /* function keys */
255 | #define GLUT_KEY_F1 1
256 | #define GLUT_KEY_F2 2
257 | #define GLUT_KEY_F3 3
258 | #define GLUT_KEY_F4 4
259 | #define GLUT_KEY_F5 5
260 | #define GLUT_KEY_F6 6
261 | #define GLUT_KEY_F7 7
262 | #define GLUT_KEY_F8 8
263 | #define GLUT_KEY_F9 9
264 | #define GLUT_KEY_F10 10
265 | #define GLUT_KEY_F11 11
266 | #define GLUT_KEY_F12 12
267 | /* directional keys */
268 | #define GLUT_KEY_LEFT 100
269 | #define GLUT_KEY_UP 101
270 | #define GLUT_KEY_RIGHT 102
271 | #define GLUT_KEY_DOWN 103
272 | #define GLUT_KEY_PAGE_UP 104
273 | #define GLUT_KEY_PAGE_DOWN 105
274 | #define GLUT_KEY_HOME 106
275 | #define GLUT_KEY_END 107
276 | #define GLUT_KEY_INSERT 108
277 | #endif
278 |
279 | /* Entry/exit state. */
280 | #define GLUT_LEFT 0
281 | #define GLUT_ENTERED 1
282 |
283 | /* Menu usage state. */
284 | #define GLUT_MENU_NOT_IN_USE 0
285 | #define GLUT_MENU_IN_USE 1
286 |
287 | /* Visibility state. */
288 | #define GLUT_NOT_VISIBLE 0
289 | #define GLUT_VISIBLE 1
290 |
291 | /* Window status state. */
292 | #define GLUT_HIDDEN 0
293 | #define GLUT_FULLY_RETAINED 1
294 | #define GLUT_PARTIALLY_RETAINED 2
295 | #define GLUT_FULLY_COVERED 3
296 |
297 | /* Color index component selection values. */
298 | #define GLUT_RED 0
299 | #define GLUT_GREEN 1
300 | #define GLUT_BLUE 2
301 |
302 | #if defined(_WIN32)
303 | /* Stroke font constants (use these in GLUT program). */
304 | #define GLUT_STROKE_ROMAN ((void*)0)
305 | #define GLUT_STROKE_MONO_ROMAN ((void*)1)
306 |
307 | /* Bitmap font constants (use these in GLUT program). */
308 | #define GLUT_BITMAP_9_BY_15 ((void*)2)
309 | #define GLUT_BITMAP_8_BY_13 ((void*)3)
310 | #define GLUT_BITMAP_TIMES_ROMAN_10 ((void*)4)
311 | #define GLUT_BITMAP_TIMES_ROMAN_24 ((void*)5)
312 | #if (GLUT_API_VERSION >= 3)
313 | #define GLUT_BITMAP_HELVETICA_10 ((void*)6)
314 | #define GLUT_BITMAP_HELVETICA_12 ((void*)7)
315 | #define GLUT_BITMAP_HELVETICA_18 ((void*)8)
316 | #endif
317 | #else
318 | /* Stroke font opaque addresses (use constants instead in source code). */
319 | GLUTAPI void *glutStrokeRoman;
320 | GLUTAPI void *glutStrokeMonoRoman;
321 |
322 | /* Stroke font constants (use these in GLUT program). */
323 | #define GLUT_STROKE_ROMAN (&glutStrokeRoman)
324 | #define GLUT_STROKE_MONO_ROMAN (&glutStrokeMonoRoman)
325 |
326 | /* Bitmap font opaque addresses (use constants instead in source code). */
327 | GLUTAPI void *glutBitmap9By15;
328 | GLUTAPI void *glutBitmap8By13;
329 | GLUTAPI void *glutBitmapTimesRoman10;
330 | GLUTAPI void *glutBitmapTimesRoman24;
331 | GLUTAPI void *glutBitmapHelvetica10;
332 | GLUTAPI void *glutBitmapHelvetica12;
333 | GLUTAPI void *glutBitmapHelvetica18;
334 |
335 | /* Bitmap font constants (use these in GLUT program). */
336 | #define GLUT_BITMAP_9_BY_15 (&glutBitmap9By15)
337 | #define GLUT_BITMAP_8_BY_13 (&glutBitmap8By13)
338 | #define GLUT_BITMAP_TIMES_ROMAN_10 (&glutBitmapTimesRoman10)
339 | #define GLUT_BITMAP_TIMES_ROMAN_24 (&glutBitmapTimesRoman24)
340 | #if (GLUT_API_VERSION >= 3)
341 | #define GLUT_BITMAP_HELVETICA_10 (&glutBitmapHelvetica10)
342 | #define GLUT_BITMAP_HELVETICA_12 (&glutBitmapHelvetica12)
343 | #define GLUT_BITMAP_HELVETICA_18 (&glutBitmapHelvetica18)
344 | #endif
345 | #endif
346 |
347 | /* glutGet parameters. */
348 | #define GLUT_WINDOW_X ((GLenum) 100)
349 | #define GLUT_WINDOW_Y ((GLenum) 101)
350 | #define GLUT_WINDOW_WIDTH ((GLenum) 102)
351 | #define GLUT_WINDOW_HEIGHT ((GLenum) 103)
352 | #define GLUT_WINDOW_BUFFER_SIZE ((GLenum) 104)
353 | #define GLUT_WINDOW_STENCIL_SIZE ((GLenum) 105)
354 | #define GLUT_WINDOW_DEPTH_SIZE ((GLenum) 106)
355 | #define GLUT_WINDOW_RED_SIZE ((GLenum) 107)
356 | #define GLUT_WINDOW_GREEN_SIZE ((GLenum) 108)
357 | #define GLUT_WINDOW_BLUE_SIZE ((GLenum) 109)
358 | #define GLUT_WINDOW_ALPHA_SIZE ((GLenum) 110)
359 | #define GLUT_WINDOW_ACCUM_RED_SIZE ((GLenum) 111)
360 | #define GLUT_WINDOW_ACCUM_GREEN_SIZE ((GLenum) 112)
361 | #define GLUT_WINDOW_ACCUM_BLUE_SIZE ((GLenum) 113)
362 | #define GLUT_WINDOW_ACCUM_ALPHA_SIZE ((GLenum) 114)
363 | #define GLUT_WINDOW_DOUBLEBUFFER ((GLenum) 115)
364 | #define GLUT_WINDOW_RGBA ((GLenum) 116)
365 | #define GLUT_WINDOW_PARENT ((GLenum) 117)
366 | #define GLUT_WINDOW_NUM_CHILDREN ((GLenum) 118)
367 | #define GLUT_WINDOW_COLORMAP_SIZE ((GLenum) 119)
368 | #if (GLUT_API_VERSION >= 2)
369 | #define GLUT_WINDOW_NUM_SAMPLES ((GLenum) 120)
370 | #define GLUT_WINDOW_STEREO ((GLenum) 121)
371 | #endif
372 | #if (GLUT_API_VERSION >= 3)
373 | #define GLUT_WINDOW_CURSOR ((GLenum) 122)
374 | #endif
375 | #define GLUT_SCREEN_WIDTH ((GLenum) 200)
376 | #define GLUT_SCREEN_HEIGHT ((GLenum) 201)
377 | #define GLUT_SCREEN_WIDTH_MM ((GLenum) 202)
378 | #define GLUT_SCREEN_HEIGHT_MM ((GLenum) 203)
379 | #define GLUT_MENU_NUM_ITEMS ((GLenum) 300)
380 | #define GLUT_DISPLAY_MODE_POSSIBLE ((GLenum) 400)
381 | #define GLUT_INIT_WINDOW_X ((GLenum) 500)
382 | #define GLUT_INIT_WINDOW_Y ((GLenum) 501)
383 | #define GLUT_INIT_WINDOW_WIDTH ((GLenum) 502)
384 | #define GLUT_INIT_WINDOW_HEIGHT ((GLenum) 503)
385 | #define GLUT_INIT_DISPLAY_MODE ((GLenum) 504)
386 | #if (GLUT_API_VERSION >= 2)
387 | #define GLUT_ELAPSED_TIME ((GLenum) 700)
388 | #endif
389 | #if (GLUT_API_VERSION >= 4 || GLUT_XLIB_IMPLEMENTATION >= 13)
390 | #define GLUT_WINDOW_FORMAT_ID ((GLenum) 123)
391 | #endif
392 |
393 | #if (GLUT_API_VERSION >= 2)
394 | /* glutDeviceGet parameters. */
395 | #define GLUT_HAS_KEYBOARD ((GLenum) 600)
396 | #define GLUT_HAS_MOUSE ((GLenum) 601)
397 | #define GLUT_HAS_SPACEBALL ((GLenum) 602)
398 | #define GLUT_HAS_DIAL_AND_BUTTON_BOX ((GLenum) 603)
399 | #define GLUT_HAS_TABLET ((GLenum) 604)
400 | #define GLUT_NUM_MOUSE_BUTTONS ((GLenum) 605)
401 | #define GLUT_NUM_SPACEBALL_BUTTONS ((GLenum) 606)
402 | #define GLUT_NUM_BUTTON_BOX_BUTTONS ((GLenum) 607)
403 | #define GLUT_NUM_DIALS ((GLenum) 608)
404 | #define GLUT_NUM_TABLET_BUTTONS ((GLenum) 609)
405 | #endif
406 | #if (GLUT_API_VERSION >= 4 || GLUT_XLIB_IMPLEMENTATION >= 13)
407 | #define GLUT_DEVICE_IGNORE_KEY_REPEAT ((GLenum) 610)
408 | #define GLUT_DEVICE_KEY_REPEAT ((GLenum) 611)
409 | #define GLUT_HAS_JOYSTICK ((GLenum) 612)
410 | #define GLUT_OWNS_JOYSTICK ((GLenum) 613)
411 | #define GLUT_JOYSTICK_BUTTONS ((GLenum) 614)
412 | #define GLUT_JOYSTICK_AXES ((GLenum) 615)
413 | #define GLUT_JOYSTICK_POLL_RATE ((GLenum) 616)
414 | #endif
415 |
416 | #if (GLUT_API_VERSION >= 3)
417 | /* glutLayerGet parameters. */
418 | #define GLUT_OVERLAY_POSSIBLE ((GLenum) 800)
419 | #define GLUT_LAYER_IN_USE ((GLenum) 801)
420 | #define GLUT_HAS_OVERLAY ((GLenum) 802)
421 | #define GLUT_TRANSPARENT_INDEX ((GLenum) 803)
422 | #define GLUT_NORMAL_DAMAGED ((GLenum) 804)
423 | #define GLUT_OVERLAY_DAMAGED ((GLenum) 805)
424 |
425 | #if (GLUT_API_VERSION >= 4 || GLUT_XLIB_IMPLEMENTATION >= 9)
426 | /* glutVideoResizeGet parameters. */
427 | #define GLUT_VIDEO_RESIZE_POSSIBLE ((GLenum) 900)
428 | #define GLUT_VIDEO_RESIZE_IN_USE ((GLenum) 901)
429 | #define GLUT_VIDEO_RESIZE_X_DELTA ((GLenum) 902)
430 | #define GLUT_VIDEO_RESIZE_Y_DELTA ((GLenum) 903)
431 | #define GLUT_VIDEO_RESIZE_WIDTH_DELTA ((GLenum) 904)
432 | #define GLUT_VIDEO_RESIZE_HEIGHT_DELTA ((GLenum) 905)
433 | #define GLUT_VIDEO_RESIZE_X ((GLenum) 906)
434 | #define GLUT_VIDEO_RESIZE_Y ((GLenum) 907)
435 | #define GLUT_VIDEO_RESIZE_WIDTH ((GLenum) 908)
436 | #define GLUT_VIDEO_RESIZE_HEIGHT ((GLenum) 909)
437 | #endif
438 |
439 | /* glutUseLayer parameters. */
440 | #define GLUT_NORMAL ((GLenum) 0)
441 | #define GLUT_OVERLAY ((GLenum) 1)
442 |
443 | /* glutGetModifiers return mask. */
444 | #define GLUT_ACTIVE_SHIFT 1
445 | #define GLUT_ACTIVE_CTRL 2
446 | #define GLUT_ACTIVE_ALT 4
447 |
448 | /* glutSetCursor parameters. */
449 | /* Basic arrows. */
450 | #define GLUT_CURSOR_RIGHT_ARROW 0
451 | #define GLUT_CURSOR_LEFT_ARROW 1
452 | /* Symbolic cursor shapes. */
453 | #define GLUT_CURSOR_INFO 2
454 | #define GLUT_CURSOR_DESTROY 3
455 | #define GLUT_CURSOR_HELP 4
456 | #define GLUT_CURSOR_CYCLE 5
457 | #define GLUT_CURSOR_SPRAY 6
458 | #define GLUT_CURSOR_WAIT 7
459 | #define GLUT_CURSOR_TEXT 8
460 | #define GLUT_CURSOR_CROSSHAIR 9
461 | /* Directional cursors. */
462 | #define GLUT_CURSOR_UP_DOWN 10
463 | #define GLUT_CURSOR_LEFT_RIGHT 11
464 | /* Sizing cursors. */
465 | #define GLUT_CURSOR_TOP_SIDE 12
466 | #define GLUT_CURSOR_BOTTOM_SIDE 13
467 | #define GLUT_CURSOR_LEFT_SIDE 14
468 | #define GLUT_CURSOR_RIGHT_SIDE 15
469 | #define GLUT_CURSOR_TOP_LEFT_CORNER 16
470 | #define GLUT_CURSOR_TOP_RIGHT_CORNER 17
471 | #define GLUT_CURSOR_BOTTOM_RIGHT_CORNER 18
472 | #define GLUT_CURSOR_BOTTOM_LEFT_CORNER 19
473 | /* Inherit from parent window. */
474 | #define GLUT_CURSOR_INHERIT 100
475 | /* Blank cursor. */
476 | #define GLUT_CURSOR_NONE 101
477 | /* Fullscreen crosshair (if available). */
478 | #define GLUT_CURSOR_FULL_CROSSHAIR 102
479 | #endif
480 |
481 | /* GLUT initialization sub-API. */
482 | GLUTAPI void APIENTRY glutInit(int *argcp, char **argv);
483 | #if defined(_WIN32) && !defined(GLUT_DISABLE_ATEXIT_HACK)
484 | GLUTAPI void APIENTRY __glutInitWithExit(int *argcp, char **argv, void (__cdecl *exitfunc)(int));
485 | #ifndef GLUT_BUILDING_LIB
486 | static void APIENTRY glutInit_ATEXIT_HACK(int *argcp, char **argv) { __glutInitWithExit(argcp, argv, exit); }
487 | #define glutInit glutInit_ATEXIT_HACK
488 | #endif
489 | #endif
490 | GLUTAPI void APIENTRY glutInitDisplayMode(unsigned int mode);
491 | #if (GLUT_API_VERSION >= 4 || GLUT_XLIB_IMPLEMENTATION >= 9)
492 | GLUTAPI void APIENTRY glutInitDisplayString(const char *string);
493 | #endif
494 | GLUTAPI void APIENTRY glutInitWindowPosition(int x, int y);
495 | GLUTAPI void APIENTRY glutInitWindowSize(int width, int height);
496 | GLUTAPI void APIENTRY glutMainLoop(void);
497 |
498 | /* GLUT window sub-API. */
499 | GLUTAPI int APIENTRY glutCreateWindow(const char *title);
500 | #if defined(_WIN32) && !defined(GLUT_DISABLE_ATEXIT_HACK)
501 | GLUTAPI int APIENTRY __glutCreateWindowWithExit(const char *title, void (__cdecl *exitfunc)(int));
502 | #ifndef GLUT_BUILDING_LIB
503 | static int APIENTRY glutCreateWindow_ATEXIT_HACK(const char *title) { return __glutCreateWindowWithExit(title, exit); }
504 | #define glutCreateWindow glutCreateWindow_ATEXIT_HACK
505 | #endif
506 | #endif
507 | GLUTAPI int APIENTRY glutCreateSubWindow(int win, int x, int y, int width, int height);
508 | GLUTAPI void APIENTRY glutDestroyWindow(int win);
509 | GLUTAPI void APIENTRY glutPostRedisplay(void);
510 | #if (GLUT_API_VERSION >= 4 || GLUT_XLIB_IMPLEMENTATION >= 11)
511 | GLUTAPI void APIENTRY glutPostWindowRedisplay(int win);
512 | #endif
513 | GLUTAPI void APIENTRY glutSwapBuffers(void);
514 | GLUTAPI int APIENTRY glutGetWindow(void);
515 | GLUTAPI void APIENTRY glutSetWindow(int win);
516 | GLUTAPI void APIENTRY glutSetWindowTitle(const char *title);
517 | GLUTAPI void APIENTRY glutSetIconTitle(const char *title);
518 | GLUTAPI void APIENTRY glutPositionWindow(int x, int y);
519 | GLUTAPI void APIENTRY glutReshapeWindow(int width, int height);
520 | GLUTAPI void APIENTRY glutPopWindow(void);
521 | GLUTAPI void APIENTRY glutPushWindow(void);
522 | GLUTAPI void APIENTRY glutIconifyWindow(void);
523 | GLUTAPI void APIENTRY glutShowWindow(void);
524 | GLUTAPI void APIENTRY glutHideWindow(void);
525 | #if (GLUT_API_VERSION >= 3)
526 | GLUTAPI void APIENTRY glutFullScreen(void);
527 | GLUTAPI void APIENTRY glutSetCursor(int cursor);
528 | #if (GLUT_API_VERSION >= 4 || GLUT_XLIB_IMPLEMENTATION >= 9)
529 | GLUTAPI void APIENTRY glutWarpPointer(int x, int y);
530 | #endif
531 |
532 | /* GLUT overlay sub-API. */
533 | GLUTAPI void APIENTRY glutEstablishOverlay(void);
534 | GLUTAPI void APIENTRY glutRemoveOverlay(void);
535 | GLUTAPI void APIENTRY glutUseLayer(GLenum layer);
536 | GLUTAPI void APIENTRY glutPostOverlayRedisplay(void);
537 | #if (GLUT_API_VERSION >= 4 || GLUT_XLIB_IMPLEMENTATION >= 11)
538 | GLUTAPI void APIENTRY glutPostWindowOverlayRedisplay(int win);
539 | #endif
540 | GLUTAPI void APIENTRY glutShowOverlay(void);
541 | GLUTAPI void APIENTRY glutHideOverlay(void);
542 | #endif
543 |
544 | /* GLUT menu sub-API. */
545 | GLUTAPI int APIENTRY glutCreateMenu(void (GLUTCALLBACK *func)(int));
546 | #if defined(_WIN32) && !defined(GLUT_DISABLE_ATEXIT_HACK)
547 | GLUTAPI int APIENTRY __glutCreateMenuWithExit(void (GLUTCALLBACK *func)(int), void (__cdecl *exitfunc)(int));
548 | #ifndef GLUT_BUILDING_LIB
549 | static int APIENTRY glutCreateMenu_ATEXIT_HACK(void (GLUTCALLBACK *func)(int)) { return __glutCreateMenuWithExit(func, exit); }
550 | #define glutCreateMenu glutCreateMenu_ATEXIT_HACK
551 | #endif
552 | #endif
553 | GLUTAPI void APIENTRY glutDestroyMenu(int menu);
554 | GLUTAPI int APIENTRY glutGetMenu(void);
555 | GLUTAPI void APIENTRY glutSetMenu(int menu);
556 | GLUTAPI void APIENTRY glutAddMenuEntry(const char *label, int value);
557 | GLUTAPI void APIENTRY glutAddSubMenu(const char *label, int submenu);
558 | GLUTAPI void APIENTRY glutChangeToMenuEntry(int item, const char *label, int value);
559 | GLUTAPI void APIENTRY glutChangeToSubMenu(int item, const char *label, int submenu);
560 | GLUTAPI void APIENTRY glutRemoveMenuItem(int item);
561 | GLUTAPI void APIENTRY glutAttachMenu(int button);
562 | GLUTAPI void APIENTRY glutDetachMenu(int button);
563 |
564 | /* GLUT window callback sub-API. */
565 | GLUTAPI void APIENTRY glutDisplayFunc(void (GLUTCALLBACK *func)(void));
566 | GLUTAPI void APIENTRY glutReshapeFunc(void (GLUTCALLBACK *func)(int width, int height));
567 | GLUTAPI void APIENTRY glutKeyboardFunc(void (GLUTCALLBACK *func)(unsigned char key, int x, int y));
568 | GLUTAPI void APIENTRY glutMouseFunc(void (GLUTCALLBACK *func)(int button, int state, int x, int y));
569 | GLUTAPI void APIENTRY glutMotionFunc(void (GLUTCALLBACK *func)(int x, int y));
570 | GLUTAPI void APIENTRY glutPassiveMotionFunc(void (GLUTCALLBACK *func)(int x, int y));
571 | GLUTAPI void APIENTRY glutEntryFunc(void (GLUTCALLBACK *func)(int state));
572 | GLUTAPI void APIENTRY glutVisibilityFunc(void (GLUTCALLBACK *func)(int state));
573 | GLUTAPI void APIENTRY glutIdleFunc(void (GLUTCALLBACK *func)(void));
574 | GLUTAPI void APIENTRY glutTimerFunc(unsigned int millis, void (GLUTCALLBACK *func)(int value), int value);
575 | GLUTAPI void APIENTRY glutMenuStateFunc(void (GLUTCALLBACK *func)(int state));
576 | #if (GLUT_API_VERSION >= 2)
577 | GLUTAPI void APIENTRY glutSpecialFunc(void (GLUTCALLBACK *func)(int key, int x, int y));
578 | GLUTAPI void APIENTRY glutSpaceballMotionFunc(void (GLUTCALLBACK *func)(int x, int y, int z));
579 | GLUTAPI void APIENTRY glutSpaceballRotateFunc(void (GLUTCALLBACK *func)(int x, int y, int z));
580 | GLUTAPI void APIENTRY glutSpaceballButtonFunc(void (GLUTCALLBACK *func)(int button, int state));
581 | GLUTAPI void APIENTRY glutButtonBoxFunc(void (GLUTCALLBACK *func)(int button, int state));
582 | GLUTAPI void APIENTRY glutDialsFunc(void (GLUTCALLBACK *func)(int dial, int value));
583 | GLUTAPI void APIENTRY glutTabletMotionFunc(void (GLUTCALLBACK *func)(int x, int y));
584 | GLUTAPI void APIENTRY glutTabletButtonFunc(void (GLUTCALLBACK *func)(int button, int state, int x, int y));
585 | #if (GLUT_API_VERSION >= 3)
586 | GLUTAPI void APIENTRY glutMenuStatusFunc(void (GLUTCALLBACK *func)(int status, int x, int y));
587 | GLUTAPI void APIENTRY glutOverlayDisplayFunc(void (GLUTCALLBACK *func)(void));
588 | #if (GLUT_API_VERSION >= 4 || GLUT_XLIB_IMPLEMENTATION >= 9)
589 | GLUTAPI void APIENTRY glutWindowStatusFunc(void (GLUTCALLBACK *func)(int state));
590 | #endif
591 | #if (GLUT_API_VERSION >= 4 || GLUT_XLIB_IMPLEMENTATION >= 13)
592 | GLUTAPI void APIENTRY glutKeyboardUpFunc(void (GLUTCALLBACK *func)(unsigned char key, int x, int y));
593 | GLUTAPI void APIENTRY glutSpecialUpFunc(void (GLUTCALLBACK *func)(int key, int x, int y));
594 | GLUTAPI void APIENTRY glutJoystickFunc(void (GLUTCALLBACK *func)(unsigned int buttonMask, int x, int y, int z), int pollInterval);
595 | #endif
596 | #endif
597 | #endif
598 |
599 | /* GLUT color index sub-API. */
600 | GLUTAPI void APIENTRY glutSetColor(int, GLfloat red, GLfloat green, GLfloat blue);
601 | GLUTAPI GLfloat APIENTRY glutGetColor(int ndx, int component);
602 | GLUTAPI void APIENTRY glutCopyColormap(int win);
603 |
604 | /* GLUT state retrieval sub-API. */
605 | GLUTAPI int APIENTRY glutGet(GLenum type);
606 | GLUTAPI int APIENTRY glutDeviceGet(GLenum type);
607 | #if (GLUT_API_VERSION >= 2)
608 | /* GLUT extension support sub-API */
609 | GLUTAPI int APIENTRY glutExtensionSupported(const char *name);
610 | #endif
611 | #if (GLUT_API_VERSION >= 3)
612 | GLUTAPI int APIENTRY glutGetModifiers(void);
613 | GLUTAPI int APIENTRY glutLayerGet(GLenum type);
614 | #endif
615 |
616 | /* GLUT font sub-API */
617 | GLUTAPI void APIENTRY glutBitmapCharacter(void *font, int character);
618 | GLUTAPI int APIENTRY glutBitmapWidth(void *font, int character);
619 | GLUTAPI void APIENTRY glutStrokeCharacter(void *font, int character);
620 | GLUTAPI int APIENTRY glutStrokeWidth(void *font, int character);
621 | #if (GLUT_API_VERSION >= 4 || GLUT_XLIB_IMPLEMENTATION >= 9)
622 | GLUTAPI int APIENTRY glutBitmapLength(void *font, const unsigned char *string);
623 | GLUTAPI int APIENTRY glutStrokeLength(void *font, const unsigned char *string);
624 | #endif
625 |
626 | /* GLUT pre-built models sub-API */
627 | GLUTAPI void APIENTRY glutWireSphere(GLdouble radius, GLint slices, GLint stacks);
628 | GLUTAPI void APIENTRY glutSolidSphere(GLdouble radius, GLint slices, GLint stacks);
629 | GLUTAPI void APIENTRY glutWireCone(GLdouble base, GLdouble height, GLint slices, GLint stacks);
630 | GLUTAPI void APIENTRY glutSolidCone(GLdouble base, GLdouble height, GLint slices, GLint stacks);
631 | GLUTAPI void APIENTRY glutWireCube(GLdouble size);
632 | GLUTAPI void APIENTRY glutSolidCube(GLdouble size);
633 | GLUTAPI void APIENTRY glutWireTorus(GLdouble innerRadius, GLdouble outerRadius, GLint sides, GLint rings);
634 | GLUTAPI void APIENTRY glutSolidTorus(GLdouble innerRadius, GLdouble outerRadius, GLint sides, GLint rings);
635 | GLUTAPI void APIENTRY glutWireDodecahedron(void);
636 | GLUTAPI void APIENTRY glutSolidDodecahedron(void);
637 | GLUTAPI void APIENTRY glutWireTeapot(GLdouble size);
638 | GLUTAPI void APIENTRY glutSolidTeapot(GLdouble size);
639 | GLUTAPI void APIENTRY glutWireOctahedron(void);
640 | GLUTAPI void APIENTRY glutSolidOctahedron(void);
641 | GLUTAPI void APIENTRY glutWireTetrahedron(void);
642 | GLUTAPI void APIENTRY glutSolidTetrahedron(void);
643 | GLUTAPI void APIENTRY glutWireIcosahedron(void);
644 | GLUTAPI void APIENTRY glutSolidIcosahedron(void);
645 |
646 | #if (GLUT_API_VERSION >= 4 || GLUT_XLIB_IMPLEMENTATION >= 9)
647 | /* GLUT video resize sub-API. */
648 | GLUTAPI int APIENTRY glutVideoResizeGet(GLenum param);
649 | GLUTAPI void APIENTRY glutSetupVideoResizing(void);
650 | GLUTAPI void APIENTRY glutStopVideoResizing(void);
651 | GLUTAPI void APIENTRY glutVideoResize(int x, int y, int width, int height);
652 | GLUTAPI void APIENTRY glutVideoPan(int x, int y, int width, int height);
653 |
654 | /* GLUT debugging sub-API. */
655 | GLUTAPI void APIENTRY glutReportErrors(void);
656 | #endif
657 |
658 | #if (GLUT_API_VERSION >= 4 || GLUT_XLIB_IMPLEMENTATION >= 13)
659 | /* GLUT device control sub-API. */
660 | /* glutSetKeyRepeat modes. */
661 | #define GLUT_KEY_REPEAT_OFF 0
662 | #define GLUT_KEY_REPEAT_ON 1
663 | #define GLUT_KEY_REPEAT_DEFAULT 2
664 |
665 | /* Joystick button masks. */
666 | #define GLUT_JOYSTICK_BUTTON_A 1
667 | #define GLUT_JOYSTICK_BUTTON_B 2
668 | #define GLUT_JOYSTICK_BUTTON_C 4
669 | #define GLUT_JOYSTICK_BUTTON_D 8
670 |
671 | GLUTAPI void APIENTRY glutIgnoreKeyRepeat(int ignore);
672 | GLUTAPI void APIENTRY glutSetKeyRepeat(int repeatMode);
673 | GLUTAPI void APIENTRY glutForceJoystickFunc(void);
674 |
675 | /* GLUT game mode sub-API. */
676 | /* glutGameModeGet. */
677 | #define GLUT_GAME_MODE_ACTIVE ((GLenum) 0)
678 | #define GLUT_GAME_MODE_POSSIBLE ((GLenum) 1)
679 | #define GLUT_GAME_MODE_WIDTH ((GLenum) 2)
680 | #define GLUT_GAME_MODE_HEIGHT ((GLenum) 3)
681 | #define GLUT_GAME_MODE_PIXEL_DEPTH ((GLenum) 4)
682 | #define GLUT_GAME_MODE_REFRESH_RATE ((GLenum) 5)
683 | #define GLUT_GAME_MODE_DISPLAY_CHANGED ((GLenum) 6)
684 |
685 | GLUTAPI void APIENTRY glutGameModeString(const char *string);
686 | GLUTAPI int APIENTRY glutEnterGameMode(void);
687 | GLUTAPI void APIENTRY glutLeaveGameMode(void);
688 | GLUTAPI int APIENTRY glutGameModeGet(GLenum mode);
689 | #endif
690 |
691 | #ifdef __cplusplus
692 | }
693 |
694 | #endif
695 |
696 | #ifdef GLUT_APIENTRY_DEFINED
697 | # undef GLUT_APIENTRY_DEFINED
698 | # undef APIENTRY
699 | #endif
700 |
701 | #ifdef GLUT_WINGDIAPI_DEFINED
702 | # undef GLUT_WINGDIAPI_DEFINED
703 | # undef WINGDIAPI
704 | #endif
705 |
706 | #ifdef GLUT_DEFINED___CDECL
707 | # undef GLUT_DEFINED___CDECL
708 | # undef __cdecl
709 | #endif
710 |
711 | #ifdef GLUT_DEFINED__CRTIMP
712 | # undef GLUT_DEFINED__CRTIMP
713 | # undef _CRTIMP
714 | #endif
715 |
716 | #endif /* __glut_h__ */
717 |
--------------------------------------------------------------------------------
/GRAPHULATOR_Source/main.cpp:
--------------------------------------------------------------------------------
1 | #include
2 |
3 | #ifndef __APPLE__
4 | #include
5 | #endif
6 |
7 | #include "glut.h"
8 | #include
9 | #include
10 | #include
11 | #include
12 |
13 | #include "expression/expressions.h"
14 |
15 | const int gWidth = 1200;
16 | const int gHeight = 800;
17 |
18 | float gXAngle = 45.0f;
19 | float gYAngle = 0.0f;
20 | int gXOrigin = -1;
21 | int gYOrigin = -1;
22 |
23 | bool gDoZooming = false;
24 | float gZoom = 1.0f;
25 |
26 | int gFrame=0,gTime,gTimebase=0;
27 | char gFrameString[50];
28 | char gZoomString[50] = "Zoom: 100%";
29 | char gPointString[50] = "Point Size: 1";
30 | char gFunctionString[1024] = "Function 1: ln(x^2) + ln(y) = z";
31 | char main_name[50]= "GRAPHULATOR";
32 |
33 | float gGraphRes = 300;
34 | float gGraphBounds = 300;
35 | int gFrameScaling = gGraphRes/100+1;
36 | int gFrameSpacing = 10;
37 | float* gPointCache = 0;
38 | bool gDrawGrid = true;
39 | bool gDrawNegatives = false;
40 | int gPointSize = 1;
41 |
42 |
43 | int gFunctionID = 0;
44 | bool gFunctionChanged = true;
45 | BaseExpression* gCustomFunction;
46 |
47 | //Window Ko ID
48 | static int gWinID;
49 |
50 | //Strings haru lai render garcha yesle
51 | void renderCharacters(float pX, float pY, float pZ, void *pFont, char *pCharArray)
52 | {
53 | //Position yaha set huncha
54 | glRasterPos3f(pX, pY, pZ);
55 |
56 | //'\0'samma array loop render garcha
57 | for ( char* lChar = pCharArray; *lChar != '\0'; lChar++)
58 | {
59 | glutBitmapCharacter(pFont, *lChar);
60 | }
61 | }
62 |
63 | //Axes haru lai RGB color scheme ma render garne
64 | void renderAxisFrame()
65 | {
66 | //Transparency ko chatak(ramro dekhauna)
67 | glEnable(GL_BLEND);
68 | glBlendFunc(GL_SRC_ALPHA,GL_ONE);
69 |
70 | //X wala grid(YZ Plane)
71 | glBegin(GL_LINES);
72 | for(int i=0;i<=gFrameSpacing;i++)
73 | {
74 | glColor4f(0.8,0.8,0.8,0.5);
75 | //Grid Render yaha huncha
76 | glVertex3f((gFrameSpacing/2-i)*gFrameScaling,0,-gFrameSpacing/2*gFrameScaling);
77 | glVertex3f((gFrameSpacing/2-i)*gFrameScaling,0,gFrameSpacing/2*gFrameScaling);
78 | glVertex3f(-gFrameSpacing/2*gFrameScaling,0,(gFrameSpacing/2-i)*gFrameScaling);
79 | glVertex3f(gFrameSpacing/2*gFrameScaling,0,(gFrameSpacing/2-i)*gFrameScaling);
80 |
81 | }
82 | glEnd();
83 |
84 |
85 | //Y wala grid(XZ Plane)
86 | glBegin(GL_LINES);
87 | for(int i=0;i<=gFrameSpacing;i++)
88 | {
89 | glColor4f(0.8,0.8,0.8,0.5);
90 |
91 | //Render yaha
92 | glVertex3f(0,(gFrameSpacing/2-i)*gFrameScaling,-gFrameSpacing/2*gFrameScaling);
93 | glVertex3f(0,(gFrameSpacing/2-i)*gFrameScaling,gFrameSpacing/2*gFrameScaling);
94 | glVertex3f(0,-gFrameSpacing/2*gFrameScaling,(gFrameSpacing/2-i)*gFrameScaling);
95 | glVertex3f(0,gFrameSpacing/2*gFrameScaling,(gFrameSpacing/2-i)*gFrameScaling);
96 | }
97 | glEnd();
98 |
99 | //Z wala grid(XY Plane)
100 | glBegin(GL_LINES);
101 | for(int i=0;i<=gFrameSpacing;i++)
102 | {
103 | glColor4f(0.8,0.8,0.8,0.5);
104 |
105 | //Render yaha
106 | glVertex3f(-gFrameSpacing/2*gFrameScaling,(gFrameSpacing/2-i)*gFrameScaling,0);
107 | glVertex3f(gFrameSpacing/2*gFrameScaling,(gFrameSpacing/2-i)*gFrameScaling,0);
108 | glVertex3f((gFrameSpacing/2-i)*gFrameScaling,-gFrameSpacing/2*gFrameScaling,0);
109 | glVertex3f((gFrameSpacing/2-i)*gFrameScaling,gFrameSpacing/2*gFrameScaling,0);
110 | }
111 | glEnd();
112 |
113 | //Transparency wala chatak udaideko
114 | glDisable(GL_BLEND);
115 | }
116 |
117 |
118 | //UI render garne yaha bata (chittika parna)
119 | void renderUI()
120 | {
121 | //FPS pani dekham na vanera display ko frame rate taaneko
122 | gFrame++;
123 | gTime = glutGet(GLUT_ELAPSED_TIME);
124 |
125 | //Harek sec ma calculate garcha
126 | if (gTime - gTimebase > 1000)
127 | {
128 | //FPS vaneko eti vanera dekhaune yesle
129 | sprintf(gFrameString,"FPS:%4.2f", gFrame*1000.0/(gTime-gTimebase));
130 | gTimebase = gTime;
131 | gFrame = 0;
132 | }
133 |
134 | //Suru ko frame rate ko lagi text color
135 | glColor3f(1.0f,1.0f,1.0f);
136 |
137 | //GL ko camera lai 2D orthogonal plane ma render garna set gareko
138 | glMatrixMode(GL_PROJECTION);
139 | glPushMatrix();
140 | glLoadIdentity();
141 | gluOrtho2D(0, gWidth, gHeight, 0);
142 | //Go back the model view
143 | glMatrixMode(GL_MODELVIEW);
144 | glLoadIdentity();
145 |
146 | //Frame rate render garne
147 | renderCharacters(5,20,0,GLUT_BITMAP_HELVETICA_18,gFrameString);
148 |
149 | //Information wala text render garne
150 | //Helvetica font use garechu ramro cha
151 | renderCharacters(5,60,0,GLUT_BITMAP_HELVETICA_18, gZoomString);
152 | renderCharacters(5,80,0,GLUT_BITMAP_HELVETICA_18, gPointString);
153 | renderCharacters(5,170,0,GLUT_BITMAP_HELVETICA_18,"Instructions:");
154 | renderCharacters(5,200,0,GLUT_BITMAP_HELVETICA_12,"Camera: Hold left-mouse and pan");
155 | renderCharacters(5,220,0,GLUT_BITMAP_HELVETICA_12,"Zoom: Hold right-mouse and pan");
156 | renderCharacters(5,240,0,GLUT_BITMAP_HELVETICA_12,"Next function: s");
157 | renderCharacters(5,260,0,GLUT_BITMAP_HELVETICA_12,"Previous function: w");
158 | renderCharacters(5,280,0,GLUT_BITMAP_HELVETICA_12,"Add custom function in console: c");
159 | renderCharacters(5,300,0,GLUT_BITMAP_HELVETICA_12,"Toggle axis frame: t");
160 | renderCharacters(5,320,0,GLUT_BITMAP_HELVETICA_12,"Toggle inverted negatives: n");
161 | renderCharacters(5,340,0,GLUT_BITMAP_HELVETICA_12,"Increase/decease point size: -/+");
162 | renderCharacters(5,360,0,GLUT_BITMAP_HELVETICA_12, "Quit: q");
163 | renderCharacters(gWidth-300,gHeight-60,0,GLUT_BITMAP_HELVETICA_12,"Created by: Anusandhan, Ashish & Pujan");
164 | renderCharacters((gWidth - strlen(main_name)*8)/2,25,0,GLUT_BITMAP_HELVETICA_18, main_name);
165 | //Render the function name
166 | renderCharacters((gWidth - strlen(gFunctionString)*8)/2,gHeight-20,0,GLUT_BITMAP_HELVETICA_18, gFunctionString);
167 |
168 | glPopMatrix();
169 | }
170 |
171 | /*Yaha chai function render hune main kaam huncha
172 | function lai point haru ko cloud jasto dataset ma render garcha
173 | */
174 | void renderPoints()
175 | {
176 | //Agi projection load garejastai yaha model view matrix mode load garcha
177 | glMatrixMode(GL_MODELVIEW);
178 | glLoadIdentity();
179 |
180 | //Aba points haru render huna suru vaio
181 | glBegin(GL_POINTS);
182 |
183 |
184 | int index = 0;
185 | /*
186 | Yaha chai x,y,z coordinates haru plot huncha function chai z=f(x,y) ko form ma huna paryo
187 | Coordinate plot garni bela max kati ota plot garne vanne tha hunna so k garne vanda graph ko resolution jati cha teskai over loop garera points haru banaune
188 | Jastai hamro default graph ko resolution 300 cha vanesi hamle -150 to 150 samma loop lagayera points plot garchau
189 | Yesle garda k faida huncha vane zoom in/out garda hamro graph pani change huncha with respect to the grid
190 | */
191 | for(float i =-gGraphRes/2.0f; ievaluate(i,j);
212 | strcpy(gFunctionString, "Custom Function");
213 | break;
214 | case 0:
215 | y = log(i*i) + log(j);
216 | strcpy(gFunctionString,"Function 1: ln(x^2) + ln(y) = z");
217 | break;
218 |
219 | case 1:
220 | y = (i*i + (j * j))/200;
221 | strcpy(gFunctionString,"Function 2: (x^2 + y^2)/200 = z");
222 | break;
223 |
224 | case 2:
225 | y = pow((i*i+j*j),0.5);
226 | strcpy(gFunctionString,"Function 3: z=(x^2+y^2)^0.5");
227 | break;
228 |
229 | case 3:
230 | y= cos(i*0.03f)*10 + sin(j*0.03f)*10;
231 | strcpy(gFunctionString,"Function 4: 10cos(0.03x) + 10sin(0.03y) = z");
232 | break;
233 |
234 | case 4:
235 | y= 1-std::abs(i+j)-std::abs(j-i);
236 |
237 | strcpy(gFunctionString,"Function 5: z=1-abs(x+y)-abs(y-x)");
238 | break;
239 |
240 | case 5:
241 | y = ((i*i)-(j*j));
242 | strcpy(gFunctionString,"Function 6: x^2 - y^2 = z");
243 | break;
244 |
245 | default:
246 | y = ((j*0.01*j*i + i * i)/300);
247 | strcpy(gFunctionString,"Function 7: 0.01y^3 + x^2 = z ");
248 | break;
249 | }
250 |
251 |
252 | gPointCache[index] = y;
253 | index++;
254 | }
255 | else
256 | {
257 | y = gPointCache[index];
258 | index++;
259 | }
260 | /*
261 | yaha chai gradient haleko cha, gradient kati halne(2 ta colors) vanne chai mathi bata aako i ra j ko value bata calculate gareko cha
262 | tesle garda point aanusar farak farak color shades aaucha ani color blend vajasto dekincha (zoom out huda)
263 | */
264 | float xPartial = (i)/1200.0f;
265 | float yPartial = (j)/1200.0f;
266 | float gradient = xPartial*xPartial + yPartial * yPartial;
267 | gradient = sqrt(gradient);
268 |
269 | if(y<0 && gDrawNegatives)
270 | glColor3f(0.1,gradient*4,(gradient*4+0.05));
271 | else
272 | glColor3f((gradient*4+0.25),gradient*4,0.1);
273 |
274 | glVertex3f(j*0.1f,y*0.1f,i*0.1f);
275 |
276 | }
277 | }
278 |
279 | /*Ek choti banaisakesi feri banauna naparos vanera arko choti tyo function ko case aauda cache bata load huncha*/
280 | gFunctionChanged = false;
281 |
282 | glEnd();
283 | }
284 |
285 | //Scene Render hune main loop
286 | void renderScene()
287 | {
288 | //Color ra Depth data lai clear gareko suru ma
289 | glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
290 |
291 | //glMatrixMode feri projection mode ma lageko(reset gareko)
292 | glMatrixMode(GL_PROJECTION);
293 | glLoadIdentity();
294 |
295 | //suru ma 45 degree ko field of view, aspect ratio window ko (width/height), ani near to far range 0.1 to 1000 units ko rakhera hercha
296 | //3D view ko 2D perspective view nikaleko
297 | //gluPerspective(45.0f*gZoom,(GLfloat)gWidth/(GLfloat)gHeight,0.1f,1000.0f);
298 | glOrtho(-25*gZoom*(GLfloat)gWidth/(GLfloat)gHeight, 25*gZoom*(GLfloat)gWidth/(GLfloat)gHeight, -25*gZoom, 25*gZoom, 0.1f, 1000.0f);
299 |
300 | //origi lai chai (0,50,-35) vanne point bata herne
301 | //desired axis ko around ma rotate garni ani
302 | gluLookAt(0, 50*gGraphRes/gGraphBounds, -35*gGraphRes/gGraphBounds, 0, 0, 0, 0, 1, 0);
303 | glRotatef(gXAngle,0,1,0);
304 |
305 | //The axis we rotate on for the vertical component depends on our angle around the vertical. The vector around which we rotate is therefore defined
306 | //by x = cos(angle) and z = sin(angle), as per the trig unit circle
307 | glRotatef(-gYAngle,cos(gXAngle*3.14159/180.0f),0,sin(gXAngle*3.14159/180.0f)); //radian to degree
308 |
309 | //Rendering the function now
310 | renderPoints();
311 |
312 | //Render the axis frame if needed
313 | if(gDrawGrid)
314 | renderAxisFrame();
315 |
316 | //Render the UI
317 | renderUI();
318 |
319 | //Swap the buffers and prepare to render again
320 | glutSwapBuffers();
321 | glutPostRedisplay();
322 | }
323 |
324 |
325 | //Keyboard ko input yaha handle huncha
326 | void keyboard (unsigned char pKey, int pX, int pY)
327 | {
328 | //s thichyo vane esle function ko id lai increment gardincha
329 | //last ko function id ma pugesi chai jati s thiche ni static nai rahancha
330 | if ((pKey=='s' || pKey =='s') && gFunctionID < 6)
331 | {
332 | gFunctionID++;
333 | gFunctionChanged = true;
334 | }
335 | //w thichyo vane esle function ko id lai decrement gardincha
336 | //first ko function id ma pugesi chai jati w thiche ni static nai rahancha
337 | else if((pKey =='w' || pKey == 'W') && gFunctionID > 0)
338 | {
339 | gFunctionID--;
340 | gFunctionChanged = true;
341 | }
342 | else if(pKey == 'c' || pKey == 'C')
343 | {
344 | std::string lString;
345 | getline (std::cin,lString);
346 |
347 | gCustomFunction = processString(lString);
348 | gFunctionID = -1;
349 | gFunctionChanged = true;
350 | }
351 | else if(pKey == 't' || pKey == 'T')
352 | {
353 | gDrawGrid = !gDrawGrid; //Grid on/off toggle gareko
354 | }
355 | else if(pKey == 'n' || pKey == 'N')
356 | {
357 | gDrawNegatives = !gDrawNegatives; //negative planes ko lai chuttyaune on/off gareko
358 | }
359 | //point ko size badhaune
360 | else if(pKey == '=' || pKey == '+')
361 | {
362 | if(gPointSize < 10)
363 | glPointSize(++gPointSize);
364 |
365 | sprintf(gPointString,"Point Size: %i",gPointSize); //gPointString vanne string ma print garcha
366 | }
367 | //point ko size ghataune
368 | else if(pKey == '-' || pKey == '_')
369 | {
370 | if(gPointSize > 1)
371 | {
372 | glPointSize(--gPointSize);
373 | }
374 |
375 | sprintf(gPointString,"Point Size: %i",gPointSize);
376 | }
377 | else if(pKey == 'q' || pKey == 'Q')
378 | {
379 | glutDestroyWindow(gWinID); // Window destroy garne
380 | delete gPointCache; //Memory sarsafai gareko
381 | delete gCustomFunction;
382 | exit(0);
383 | }
384 | }
385 |
386 | //Mouse ko motion yaha handle huncha
387 | void mouseMove(int pX, int pY)
388 | {
389 | if(gDoZooming)
390 | {
391 | if(gXOrigin - pX > 0 && gZoom <= 2)
392 | gZoom += 0.03;
393 | else if(gZoom >= 0.1 && (gXOrigin - pX) < 0)
394 | gZoom -= 0.03;
395 |
396 | gXOrigin = pX;
397 | sprintf(gZoomString,"Zoom: %4.2f%%", 100.0f/gZoom);
398 | }
399 | else
400 | {
401 | //Mouse le tyakka click garesi origin set huncha ani hamle rotate garchau
402 | if (gXOrigin >= 0)
403 | {
404 | //angle milaune kaam (on the basis of x delta)
405 | gXAngle += (pX - gXOrigin) * 0.25f;
406 |
407 | //Reset the origin
408 | gXOrigin = pX;
409 | }
410 |
411 | //Y position ko lagi ni same
412 | if(gYOrigin >= 0)
413 | {
414 | gYAngle += (pY - gYOrigin) * 0.25f;
415 | gYOrigin = pY;
416 | }
417 | }
418 | }
419 |
420 | //Yaha chai mouse ko button ko events haru handle huncha
421 | void mouseButton(int pButton, int pState, int pX, int pY)
422 | {
423 | //Left button click garecha vane
424 | if (pButton == GLUT_LEFT_BUTTON)
425 | {
426 | //left button thichirakheko cha vane gXOrigin ra gYOrigin lai mouse ko point ko value set garne
427 | //natra button release garesi origin clear gardine
428 | if (pState == GLUT_UP)
429 | {
430 | gXOrigin = -1;
431 | gYOrigin = -1;
432 | }
433 | else
434 | {
435 | gXOrigin = pX;
436 | gYOrigin = pY;
437 | }
438 | }
439 | //Right Button Click Garda Ko Kura
440 | else if(pButton == GLUT_RIGHT_BUTTON)
441 | {
442 | //Zoom garne nagarne yaha decide huncha
443 | if(pState == GLUT_UP)
444 | {
445 | gDoZooming = false;
446 | }
447 | else
448 | {
449 | gDoZooming = true;
450 | gXOrigin = pX;
451 | }
452 | }
453 |
454 | }
455 |
456 | int main(int argc, char **argv)
457 | {
458 |
459 | //Glut init
460 | glutInit(&argc, argv);
461 |
462 | //Display mode yaha
463 | glutInitDisplayMode(GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGBA);
464 |
465 | //Window ko settings
466 | glutInitWindowPosition(100,100);
467 | glutInitWindowSize(gWidth,gHeight);
468 | gWinID = glutCreateWindow("Graphulator"); //Window ko name
469 |
470 | //Keyboard/Mouse input handlers
471 | glutKeyboardFunc(keyboard);
472 | glutMouseFunc(mouseButton);
473 | glutMotionFunc(mouseMove);
474 |
475 | //Display/Render calls haru handle garne function
476 | glutDisplayFunc(renderScene);
477 |
478 | //Main canvas ko color ra depth
479 | glClearColor(0.15f, 0.15f, 0.15f, 0.1f);//R,G,B ra alpha
480 | glClearDepth(1.0f);
481 |
482 | //Smooth Banaune ninja technique :D
483 | glShadeModel(GL_SMOOTH);
484 | glEnable(GL_POINT_SMOOTH); //Point smooth banayena vane cube ko dhikka jasto aaucha
485 | glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
486 | glPointSize(gPointSize);
487 |
488 | //GL ko depth test enable gareko
489 | glEnable(GL_DEPTH_TEST);
490 | glDepthFunc(GL_LEQUAL);
491 |
492 | //Yo chai cache ko lagi memory allocate gareko
493 | gPointCache = (float*)malloc(gGraphRes * gGraphRes * sizeof(float));
494 |
495 | TrigExpression *t = new TrigExpression(new LogExpression(new AddExpression(XVAR,new NumberExpression(10.5)), 0),eCos);
496 |
497 | //GL ko main loop start garne, until window is closed.
498 | glutMainLoop();
499 |
500 | //Memory ra Cache Clean Gardeko
501 | if(gCustomFunction)
502 | delete gCustomFunction;
503 |
504 | delete gPointCache;
505 |
506 | //La sakkiyo
507 | return 0;
508 | }
509 |
--------------------------------------------------------------------------------
/GRAPHULATOR_Source/md_res/five.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CRLannister/Graphical-Calculator-OpenGL-CPlusPlus/24937f685051a89fa71f015c1dd779eaf1710b9b/GRAPHULATOR_Source/md_res/five.png
--------------------------------------------------------------------------------
/GRAPHULATOR_Source/md_res/four.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CRLannister/Graphical-Calculator-OpenGL-CPlusPlus/24937f685051a89fa71f015c1dd779eaf1710b9b/GRAPHULATOR_Source/md_res/four.png
--------------------------------------------------------------------------------
/GRAPHULATOR_Source/md_res/one.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CRLannister/Graphical-Calculator-OpenGL-CPlusPlus/24937f685051a89fa71f015c1dd779eaf1710b9b/GRAPHULATOR_Source/md_res/one.png
--------------------------------------------------------------------------------
/GRAPHULATOR_Source/md_res/three.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CRLannister/Graphical-Calculator-OpenGL-CPlusPlus/24937f685051a89fa71f015c1dd779eaf1710b9b/GRAPHULATOR_Source/md_res/three.png
--------------------------------------------------------------------------------
/GRAPHULATOR_Source/md_res/two.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CRLannister/Graphical-Calculator-OpenGL-CPlusPlus/24937f685051a89fa71f015c1dd779eaf1710b9b/GRAPHULATOR_Source/md_res/two.png
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2019 Ashish Agarwal
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Sem11OOP
2 |
3 | ## 3rd semester OOP Project on Graphulator.
4 | > It is aimed to process all the calculating processes along with the Graphical presentation.
5 |
6 | ## Languages and Technologies Used
7 |
8 | - Programming Language: C++
9 | - Graphics: OpenGL
10 |
11 | ## Key Features
12 |
13 | - Calculation Processes: Efficient handling and processing of mathematical and computational tasks.
14 | - Graphical Presentation: Visual representation of calculations using OpenGL.
15 |
16 | ## Languages used:C++ and Graphics is targeted to use OpenGl specification.
17 |
18 | 
19 |
20 | 
21 |
22 | 
23 |
24 | 
25 |
26 | 
27 |
28 |
29 | The Sem11OOP project, Graphulator, combines the power of C++ for processing calculations with the graphical capabilities of OpenGL to deliver a robust and visually appealing computational tool. This project not only strengthens understanding of OOP principles but also provides practical experience in integrating complex calculations with graphical outputs.
30 |
31 |
--------------------------------------------------------------------------------
/Report/DOCUMENTATION-1final.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CRLannister/Graphical-Calculator-OpenGL-CPlusPlus/24937f685051a89fa71f015c1dd779eaf1710b9b/Report/DOCUMENTATION-1final.pdf
--------------------------------------------------------------------------------
/Report/DOCUMENTATION.docx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CRLannister/Graphical-Calculator-OpenGL-CPlusPlus/24937f685051a89fa71f015c1dd779eaf1710b9b/Report/DOCUMENTATION.docx
--------------------------------------------------------------------------------
/Report/Presentation.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CRLannister/Graphical-Calculator-OpenGL-CPlusPlus/24937f685051a89fa71f015c1dd779eaf1710b9b/Report/Presentation.pdf
--------------------------------------------------------------------------------
/Report/Presentation.pptx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CRLannister/Graphical-Calculator-OpenGL-CPlusPlus/24937f685051a89fa71f015c1dd779eaf1710b9b/Report/Presentation.pptx
--------------------------------------------------------------------------------
/build.sh:
--------------------------------------------------------------------------------
1 | mkdir build
2 | cd build
3 | cmake ../GRAPHULATOR_Source/
4 | make
5 | ./GRAPHULATOR
6 |
--------------------------------------------------------------------------------
/todo.readme:
--------------------------------------------------------------------------------
1 | #Graphulator
2 |
3 | #Source Compilation
4 | For Windows
5 | Project GRAPHULATOR_Source could be compiled(if needed) by Clion IDE as cmake files are pre-written.
6 |
7 | For Linux
8 | make build.sh executable
9 | run build.sh
10 |
11 | #Executables
12 | binaries or Executables for windows_64 and linux distro are available in executables directory.
13 |
14 | #INFO
15 | Detail project information and its use, area of utilization,limitations etc. are included in reports directory.
16 |
17 | #Developers
18 | -Anusandhan Pokhrel (073BCT507)
19 | -Ashish Agarwal (073BCT509)
20 | -Pujan Karki (073BCT549)
21 |
--------------------------------------------------------------------------------