1 /***************************************************************************
2  * opengl.h is part of Math Graphic Library
3  * Copyright (C) 2007-2016 Alexey Balakin <mathgl.abalakin@gmail.ru>       *
4  *                                                                         *
5  *   This program is free software; you can redistribute it and/or modify  *
6  *   it under the terms of the GNU Lesser General Public License  as       *
7  *   published by the Free Software Foundation; either version 3 of the    *
8  *   License, or (at your option) any later version.                       *
9  *                                                                         *
10  *   This program is distributed in the hope that it will be useful,       *
11  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
12  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
13  *   GNU General Public License for more details.                          *
14  *                                                                         *
15  *   You should have received a copy of the GNU Lesser General Public     *
16  *   License along with this program; if not, write to the                 *
17  *   Free Software Foundation, Inc.,                                       *
18  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
19  ***************************************************************************/
20 #ifndef MGL_CANVAS_GL_H
21 #define MGL_CANVAS_GL_H
22 //-----------------------------------------------------------------------------
23 #include "mgl2/canvas.h"
24 //-----------------------------------------------------------------------------
25 class MGL_EXPORT mglCanvasGL : public mglCanvas
26 {
27 public:
28 	mglCanvasGL();
29 	virtual ~mglCanvasGL();
30 
31 	void SetQuality(int =0)	{	Quality=2;	}
32 	void Finish();
33 	void SetSize(int ,int ,bool clf=true)	{	if(clf)	Clf();	}
34 	void View(mreal tetX,mreal tetY,mreal tetZ);
35 	void Zoom(mreal x1, mreal y1, mreal x2, mreal y2);
36 /*	int NewFrame();
37 	void EndFrame();
38 	void DelFrame(long ){}*/
39 
40 	bool Alpha(bool enable);
41 	void Fog(mreal d, mreal dz=0.25);
42 	bool Light(bool enable);
43 	void Light(int n, bool enable);
44 	void AddLight(int n,mglPoint r,mglPoint d, char c='w', mreal bright=0.5, mreal ap=0);
45 	void Clf(mglColor Back=NC);
46 	void Clf(const char *col);
47 
48 protected:
49 	// provide fastest variant for usual points (not glyphs or marks)
50 	void line_draw(long n1, long n2);
51 	void trig_draw(long n1, long n2, long n3);
52 	void quad_draw(long n1, long n2, long n3, long n4);
53 	// variant for glyphs or marks
54 	void line_draw(const mglPnt &p1, const mglPnt &p2, const mglDrawReg *d);
55 	void trig_draw(const mglPnt &p1, const mglPnt &p2, const mglPnt &p3, bool anorm, const mglDrawReg *d);
56 	void quad_draw(const mglPnt &p1, const mglPnt &p2, const mglPnt &p3, const mglPnt &p4, const mglDrawReg *d);
57 	void pnt_draw(const mglPnt &p, const mglDrawReg *d);
58 	void mark_draw(const mglPnt &q, char type, mreal size, mglDrawReg *d);
59 	void glyph_fill(mreal phi, const mglPnt &p, mreal f, const mglGlyph &g, const mglDrawReg *d);
60 
61 	unsigned char **GetRGBLines(long &w, long &h, unsigned char *&f, bool solid=true);
62 	void LightScale(const mglMatrix *M);
63 
64 	void gl_clf(mglColor Back=WC);
65 };
66 //-----------------------------------------------------------------------------
67 #endif
68 
69