• R/O
  • SSH
  • HTTPS

systemfugen: Commit


Commit MetaInfo

Revision34 (tree)
Time2019-02-16 11:58:48
Authorsystemfugen

Log Message

(empty log message)

Change Summary

Incremental Difference

--- MGCL/MGCLDLLV10/src/mg/mgcl.cpp (revision 33)
+++ MGCL/MGCLDLLV10/src/mg/mgcl.cpp (revision 34)
@@ -117,11 +117,6 @@
117117 return rounded2;
118118 }
119119
120-///グローバルmin/max関数
121-inline double max(double a, double b){return a >= b ? a : b;}
122-inline double min(double a, double b){return a <= b ? a : b;}
123-inline int max(int a, int b){return a >= b ? a : b;}
124-inline int min(int a, int b){return a <= b ? a : b;}
125120
126121 }
127122
--- MGCL/MGCLDLLV10/src/mgGL/OpenglView3.cpp (nonexistent)
+++ MGCL/MGCLDLLV10/src/mgGL/OpenglView3.cpp (revision 34)
@@ -0,0 +1,527 @@
1+/********************************************************************/
2+/* Copyright (c) 2017 System fugen G.K. and Yuzi Mizuno */
3+/* All rights reserved. */
4+/********************************************************************/
5+// MGOpenGLView.cpp : インプリメンテーション ファイル
6+//
7+#include "StdAfx.h"
8+#include "mg/Tolerance.h"
9+#include "mg/Position.h"
10+#include "mg/AttribedGel.h"
11+#include "mg/DnameControl.h"
12+#include "mg/Group.h"
13+#include "mg/GelPositions.h"
14+#include "mg/CParam_list.h"
15+#include "mgGL/OpenGLView.h"
16+#include "mgGL/GLAttrib.h"
17+#include "mgGL/SysGLList.h"
18+#include "mgGL/glViewAttrib.h"
19+#include "mgGL/VBO.h"
20+#include "mgGL/glslprogram.h"
21+#include "topo/Edge.h"
22+#include "topo/Loop.h"
23+#include "topo/Face.h"
24+#include "topo/Shell.h"
25+
26+using namespace std;
27+
28+#if defined(_DEBUG)
29+#define new DEBUG_NEW
30+#undef THIS_FILE
31+static char THIS_FILE[] = __FILE__;
32+#endif
33+
34+namespace {
35+ GLuint glErr;
36+ const glm::vec3 ORIGIN(0., 0., 0.);
37+};
38+
39+///Set up drawing environment.
40+void MGOpenGLView::setupDrawEnv(
41+ const MGColor& backColor,//When pick mode, backColor is not used.
42+ const float* centrApertr //centrApertu = nullptr means standard draw,
43+ //and centrApertu != null means selection mode.
44+){
45+ glEnable(GL_DEPTH_TEST);
46+ glDepthFunc(GL_LEQUAL);
47+ const float* Bcolr = backColor.color();
48+ glClearColor(Bcolr[0], Bcolr[1], Bcolr[2], Bcolr[3]);
49+ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
50+
51+ if (centrApertr) {
52+ glDisable(GL_BLEND);
53+ }else{
54+ glEnable(GL_BLEND);
55+ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
56+ }
57+ glClearDepth(1.0);
58+ glEnable(GL_POLYGON_OFFSET_FILL);// ポリゴンオフセットフィルを設定
59+ glPolygonOffset(1., 1.);
60+
61+ mgGLSLProgram* glsl = mgGLSLProgram::getCurrentGLSLProgram();
62+
63+ ///Set Projection matrix to the member m_projMat.
64+ get_projection_matrix(m_viewPort, m_projMat);
65+ if(centrApertr){
66+ glm::vec2 c2(centrApertr[0], centrApertr[1]);
67+ glm::vec2 delta2(centrApertr[2], centrApertr[3]);
68+ glm::ivec4 vpOld(m_viewPort[0], m_viewPort[1], m_viewPort[2], m_viewPort[3]);
69+ m_projMat = glm::pickMatrix(c2, delta2, vpOld)*m_projMat;
70+ }
71+ glsl->setUniform(mgGLSLProgram::projMatrix, m_projMat);
72+
73+ //Set Model_View and Projection matrix of OpenGL.
74+ get_model_matrix(m_viewAttrib.m_modelViewMat);
75+ glsl->setUniform(mgGLSLProgram::modelViewMatrix, m_viewAttrib.m_modelViewMat);
76+
77+ // Normal Matrix ModelViewMatrixとNormalMatrixはセットです。
78+ glm::mat3 normalMatrix = glm::mat3(m_viewAttrib.m_modelViewMat);
79+ glsl->setUniform(mgGLSLProgram::normalMatrix, normalMatrix);
80+
81+ ///Set ProjModelView matrix to GLSL using setUniform();
82+ glm::mat4 ProjModelView = m_projMat * m_viewAttrib.m_modelViewMat;
83+ glsl->setUniform(mgGLSLProgram::modelViewProjMatrix, ProjModelView);
84+
85+ // Anchor Point変換用の係数設定
86+ float widthHalf = float(m_viewPort[2])*0.5f;
87+ float heightHalf = float(m_viewPort[3])*0.5f;
88+ glm::vec3 scaleFactor(1.0f / widthHalf, 1.0f / heightHalf, 1.0f);
89+ glm::mat4 ndcMtx = glm::scale(
90+ glm::translate(glm::mat4(), glm::vec3(-widthHalf, -heightHalf, 0.0f)),
91+ scaleFactor);
92+ glsl->setUniform(mgGLSLProgram::ndcMarix, ndcMtx);
93+
94+ glm::mat3 ndcScaleMtx = glm::mat3(ndcMtx);
95+ glsl->setUniform(mgGLSLProgram::ndcScaleMatrix, ndcScaleMtx);
96+
97+ // output
98+ float func = m_dpi / 72.0f;
99+ glsl->setUniform(mgGLSLProgram::dpiFactor, func);
100+}
101+
102+void MGOpenGLView::execDefaultStaticAttrib() {
103+ glDisable(GL_CULL_FACE);// 両面を描画
104+ mgGLSL::execStaticColorAttrib(Gcolor());
105+ mgGLSL::execStaticLineWidth(1.f);
106+ mgGLSL::execStaticLineStipple(0, 0);
107+ mgGLSL::execLightMode(0);//Light Off
108+}
109+
110+///Constructglm::lookAtMatrix from eye_position() and view_up_vector().
111+void MGOpenGLView::setLookAtMat() {
112+ const MGPosition& eyeP = eye_position(); glm::vec3 eye(eyeP[0], eyeP[1], eyeP[2]);
113+ const MGVector& upP = view_up_vector(); glm::vec3 up(upP[0], upP[1], upP[2]);
114+ m_lookAtMat = glm::lookAt(eye, ORIGIN, up);
115+}
116+
117+//get ModelView matrix of OpenGL.
118+void MGOpenGLView::get_model_matrix(
119+ glm::mat4& modelMat //double modelMat[16] ///<OpenGL's model matrix
120+)const {
121+ glm::mat4 viewMat = m_lookAtMat * m_viewAttrib.m_modelViewMat;
122+ const MGPosition& cntr = center(); glm::vec3 cntr2(-cntr[0], -cntr[1], -cntr[2]);
123+ modelMat = glm::translate(viewMat, cntr2)*m_viewAttrib.m_PreCenterMat;//glTranslated;
124+}
125+
126+///get projection matrix, given the viewport data
127+void MGOpenGLView::get_projection_matrix(
128+ const int vp[4],///<viewport data ={left, bottom, widht, height}
129+ glm::mat4& projMat ///<OpenGL's projection matrix
130+)const {
131+ double height2 = view_volume_height()*.5;
132+ double wide2 = height2 * double(vp[2]) / double(vp[3]);
133+ float left = float(m_viewAttrib.m_cx - wide2), right = float(m_viewAttrib.m_cx + wide2),
134+ bottom = float(m_viewAttrib.m_cy - height2), top = float(m_viewAttrib.m_cy + height2);
135+
136+ float znear = (float)view_volume_near(), zfar = (float)view_volume_far();
137+ if (is_perspective()) {
138+ projMat = glm::frustum(left, right, bottom, top, znear, zfar);
139+ }else {
140+ projMat = glm::ortho(left, right, bottom, top, znear, zfar);
141+ }
142+}
143+
144+//Update the center and the scale of the view.
145+///The pespectiveness and the cplane are unchanged.
146+void MGOpenGLView::updateCenterScalle(
147+ const MGPosition& center,
148+ double diameter///<diameter of the view. This is set to m_diameter.
149+ ///<diameter of the sphere that sorround the model.
150+ ///<If diameter<=0. the current diameter is not updated.
151+) {
152+ for (int i = 0; i < 3; i++)
153+ m_center_current[i] = (float)center[i];
154+ if (diameter <= 0.)
155+ diameter = m_viewAttrib.diameter();
156+ m_viewAttrib.compute_viewing_environment(center, diameter);
157+ setLookAtMat();
158+}
159+
160+static const MGColor NullColor(0., 0., 0., 0.);
161+//Function's return value is the number of hit objects.
162+int MGOpenGLView::pick_to_select_buf(
163+ const float centrApertr[4],
164+ ///<Screen coordinates. (left, bottom) is (0,0) and (aperturex, aperturey).
165+ mgVBO* display_list, //display list that includes pick objects.
166+ std::set<unsigned>& selected///Selected data will be returned. This data consist of
167+ ///the data set by selectName.
168+){
169+ float width=centrApertr[2], height=centrApertr[3];
170+ int viewport[4] ={int(centrApertr[0]-width/2.+.5),int(centrApertr[1]-height/2.+.5),
171+ int(width), int(height)};
172+ int& x = viewport[0]; int& y = viewport[1];//(left, bottom)
173+ int& w = viewport[2]; int& h = viewport[3];//(width, height)
174+
175+ int numHit = 0;
176+ if(h > 0 && w > 0){
177+ int xOld = m_viewPort[0]; int yOld = m_viewPort[1];
178+ int wOld = m_viewPort[2]; int hOld = m_viewPort[3];
179+
180+ if (x < xOld)
181+ x = xOld;
182+ if ((x + w) > (xOld + wOld))
183+ w = xOld + wOld - x;
184+ if (y < yOld)
185+ y = yOld;
186+ if ((y + h) > (yOld + hOld))
187+ h = yOld + hOld - y;
188+ if(h&&w){
189+ //Save the before pick state.
190+ glm::mat4 projMatSave=m_projMat;//Save
191+ glm::mat4 modelViewMatSave=m_viewAttrib.m_modelViewMat;//Save
192+
193+ //Set the target selection viewport.
194+ glViewport(x, y, w, h);
195+ glDrawBuffer(GL_BACK);
196+ float cAper[4]={float(x+w*.5), float(y+h*.5), float(w), float(h)};
197+ setupDrawEnv(NullColor, cAper);
198+
199+ //Target objects drawing
200+ display_list->selectionDraw(viewMode());
201+ glReadBuffer(GL_BACK);
202+ extractSelected(viewport, selected);
203+ numHit = (int)selected.size();
204+
205+ //Restore the state before pick operation.
206+ m_viewAttrib.m_modelViewMat = modelViewMatSave;//Restore.
207+ m_projMat = projMatSave;
208+ }
209+ }
210+ return numHit;
211+}
212+
213+//Pick objects in the display list generated by make_display_list.
214+//Function's return value is MGPickObject vector in m_CurrentObjects member data.
215+//All the objects which were inside the pick aperture will be output.
216+//This data can be accessed using current_object(), or current_PickObject().
217+//pick will invoke makeRCCurrent();
218+MGPickObjects MGOpenGLView::pick_glv(
219+ const float centrApertr[4],///<specifies pick center and aperture.
220+ const MGAbstractGels& objtypes
221+) {
222+ MGPickObjects pobjs;
223+ if (!has_display_list())
224+ return pobjs;
225+
226+ std::set<unsigned> selected;
227+ makeRCCurrent();
228+ mgVBO* vbo = display_list();
229+ int objnum = pick_to_select_buf(centrApertr, vbo, selected);
230+ if (!objnum)
231+ return pobjs;
232+
233+ MGDNameControl& dnc = getDNameControlInstance();
234+ std::vector<MGPickObject> shels;//To exclude the same shell picking, shell's pickObject are stored.
235+
236+ std::set<unsigned>::iterator i = selected.begin(), iend = selected.end();
237+ for (; i != iend; i++) {
238+ mgVBO* pickedi = dnc.VBO_from_dlistName(*i);
239+ if (!pickedi)
240+ continue;
241+ MGAttribedGel* objA = pickedi->gel();//Lowest name is MGObject.
242+ if (!objA)
243+ continue;
244+ MGObject* obj = dynamic_cast<MGObject*>(objA);//Lowest object pointer.
245+ if (!obj)
246+ continue;//This must not happen(Lowest name is MGObject).
247+
248+ std::vector<mgVBO*> vbos;
249+ if (!pickedi->buildVBOHierarchy(*vbo, vbos))
250+ continue;//This must not happen.
251+
252+ size_t n = vbos.size(); assert(n >= 2);
253+ MGAttribedGel* grpA = vbo->gel(); assert(grpA);
254+ MGGroup* grp = static_cast<MGGroup*>(grpA);//Top MGGroup.
255+ MGPickObject pobj(grp, obj);
256+ for (size_t k = 1; k <= n - 2; k++) {
257+ mgVBO* vbok = vbos[k];
258+ MGAttribedGel* gl = vbok->gel();//Lower gel is MGGroup or MGShell.
259+ pobj.append_lower_gel(gl);
260+ }
261+ if (!pobj.is_shell_face()) {
262+ if (obj->type_is(objtypes))
263+ pobjs.push_back(pobj);
264+ }
265+ else {
266+ //When is_shell_face.
267+ MGShell* shelli = pobj.get_shell_of_shell_face();
268+ if (!shelli->type_is(objtypes))
269+ continue;
270+
271+ //Exclude the same shell and employ the 1st face in the shell.
272+ int nzs = (int)shels.size(), j;
273+ for (j = 0; j < nzs; j++)
274+ if (shels[j].get_shell_of_shell_face() == shelli)
275+ break;
276+ if (j == nzs)//if the same shell not found
277+ shels.push_back(pobj);
278+ else//if found
279+ continue;
280+ }
281+ }
282+ size_t nshel = shels.size();
283+ for (size_t j = 0; j < nshel; j++)
284+ pobjs.push_back(shels[j]);
285+
286+ return pobjs;
287+}
288+
289+class mgPerimeterSelection : public mgVBO {
290+public:
291+ const MGSurface& m_surf;
292+ const MGDrawParam& m_dparam;
293+ mgPerimeterSelection(const MGSurface& surf, const MGDrawParam& para)
294+ :m_surf(surf), m_dparam(para) {};
295+
296+ ///m_gelの描画データ作成のみをおこなう。
297+ ///すでに作成済みであっても強制的に再作成を行う。
298+ ///m_gel=0のときはなにもしない。
299+ void make_display_list(MGCL::VIEWMODE viewMode = MGCL::DONTCARE);
300+
301+ ///描画関数selectionDraw()は、Object選択のための表示処理をする。
302+ ///通常のdrawとの相違:///Colorとしてm_bufferIDを用い、size処理以外の
303+ ///attributesの処理(normal, texture, color)をしない。
304+ void selectionDraw(MGCL::VIEWMODE viewMode = MGCL::DONTCARE);
305+};
306+
307+void mgPerimeterSelection::make_display_list(MGCL::VIEWMODE viewMode) {
308+ clearElements(mgVBO::BOTH);
309+
310+ int nperi = m_surf.perimeter_num();
311+ int ldensity = m_dparam.line_desity_wire_face();
312+ for (int i = 0; i < nperi; i++) {
313+ std::unique_ptr<MGCurve> peri(m_surf.perimeter_curve(i));
314+ peri->drawWire(*this, ldensity);
315+ }
316+ setDirty(false);
317+}
318+void mgPerimeterSelection::selectionDraw(MGCL::VIEWMODE viewMode) {
319+ if (!is_made())
320+ make_display_list();
321+
322+ mgGLSLProgram* glsl = mgGLSLProgram::getCurrentGLSLProgram();
323+ glsl->setFuncType(mgGLSL::Select);
324+
325+ execModelTypeAttrib();
326+
327+ size_t n = m_elements.size();
328+ for (unsigned i = 0; i < n; i++) {
329+ mgGLSL::setColorAsSelectionName(i + 1);
330+ mgVBOElement* elmi = m_elements[i];
331+ elmi->selectionDraw(MGCL::WIRE);
332+ }
333+}
334+
335+//Pick a perimeter of the surface surf. That is, obtain the perimeter number
336+//that passes input (sx,sy) when drawn in the current view matrix.
337+//Function's return value is perimeter number picked.
338+//When no perimeters are picked, -1 will be returned.
339+int MGOpenGLView::pick_perimeter_glv(
340+ const MGSurface& surf,
341+ int sx, int sy, ///<Screen coordinates. (left, bottom) is (0,0).
342+ MGPosition* uv, //surface parameter (u,v) nearest to (sx,sy) will be returned.
343+ float aperturex,//specifies pick aperture of x and y.
344+ float aperturey//When <=0. value is specified, default value(the value
345+ //obtained by pick_aperture() will be used.
346+) {
347+ mgPerimeterSelection periSel(surf, draw_param());
348+
349+ int perimeter = -1;
350+ if (aperturex <= 0.) aperturex = pick_aperture();
351+ if (aperturey <= 0.) aperturey = pick_aperture();
352+ std::set<unsigned> selected;
353+ float centrApertr[4] = { (float)sx,(float)sy, aperturex,aperturey };
354+ pick_to_select_buf(centrApertr, &periSel, selected);
355+ int objnum = (int)selected.size();
356+ if (objnum > 0) {
357+ perimeter = *(selected.begin()) - 1;
358+ if (uv) { // if parameter is needed
359+ double t;
360+ std::unique_ptr<MGCurve> peri(surf.perimeter_curve(perimeter));
361+ get_near_position(peri.get(), centrApertr, t);
362+ *uv = surf.perimeter_uv(perimeter, t);
363+ }
364+ }
365+ return perimeter;
366+}
367+
368+class mgEdgeSelection : public mgVBO {
369+public:
370+ const MGLoop& m_loop;
371+ const MGDrawParam& m_dparam;
372+ mgEdgeSelection(const MGLoop& loop, const MGDrawParam& para)
373+ :m_loop(loop), m_dparam(para) {};
374+
375+ ///m_gelの描画データ作成のみをおこなう。
376+ ///すでに作成済みであっても強制的に再作成を行う。
377+ ///m_gel=0のときはなにもしない。
378+ void make_display_list(MGCL::VIEWMODE viewMode = MGCL::DONTCARE);
379+
380+ ///描画関数selectionDraw()は、Object選択のための表示処理をする。
381+ ///通常のdrawとの相違:///Colorとしてm_bufferIDを用い、size処理以外の
382+ ///attributesの処理(normal, texture, color)をしない。
383+ void selectionDraw(MGCL::VIEWMODE viewMode = MGCL::DONTCARE);
384+};
385+void mgEdgeSelection::make_display_list(MGCL::VIEWMODE viewMode) {
386+ int ldensity = m_dparam.line_desity_wire_face();
387+ int nedge = m_loop.number_of_edges();
388+ for (int j = 0; j < nedge; j++) {
389+ const MGEdge* edge2 = m_loop.edge(j);
390+ MGEdge& be = *(edge2->make_binder_with_curve());
391+ MGTrimmedCurve cij = be.trimmed_curve();
392+ cij.drawWire(*this, ldensity);
393+ }
394+ setDirty(false);
395+}
396+void mgEdgeSelection::selectionDraw(MGCL::VIEWMODE viewMode) {
397+ if (!is_made())
398+ make_display_list();
399+
400+ mgGLSLProgram* glsl = mgGLSLProgram::getCurrentGLSLProgram();
401+ glsl->setFuncType(mgGLSL::Select);
402+
403+ execModelTypeAttrib();
404+
405+ size_t n = m_elements.size();
406+ for (unsigned i = 0; i < n; i++) {
407+ mgGLSL::setColorAsSelectionName(i + 1);
408+ mgVBOElement* elmi = m_elements[i];
409+ elmi->selectionDraw(MGCL::WIRE);
410+ }
411+}
412+
413+//Pick an edge of the face f. That is, obtain the edge number
414+//that passes input (sx,sy) when drawn in the current view matrix.
415+//Function's return value is the edge pointer picked.
416+//When no edges are picked, null will be returned.
417+const MGEdge* MGOpenGLView::pick_edge_glv(
418+ const MGFace& f,
419+ int sx, int sy, ///<Screen coordinates. (left, bottom) is (0,0).
420+ MGPosition* uv, //surface parameter (u,v) nearest to (sx,sy) will be returned.
421+ float aperturex,//specifies pick aperture of x and y.
422+ float aperturey//When <=0. value is specified, default value(the value
423+ //obtained by pick_aperture() will be used.
424+) {
425+ const MGEdge* edge = 0;
426+ if (aperturex <= 0.) aperturex = pick_aperture();
427+ if (aperturey <= 0.) aperturey = pick_aperture();
428+
429+ glm::ivec4 viewport(m_viewPort[0], m_viewPort[1], m_viewPort[2], m_viewPort[3]);
430+ float centrApertr[4] = { float(sx),float(sy),aperturex, aperturey};
431+ glm::vec2 c2(centrApertr[0], centrApertr[1]);
432+ glm::vec2 aperture(aperturex, aperturey);
433+ m_projMat = glm::pickMatrix(c2, aperture, viewport);
434+
435+ int nloop = f.number_of_loops();
436+ for (int i = 0; i < nloop; i++) {
437+ const MGLoop& li = *(f.loop(i));
438+ mgEdgeSelection edgeSel(li, draw_param());
439+ std::set<unsigned> selected;
440+ pick_to_select_buf(centrApertr, &edgeSel, selected);
441+ size_t objnum = selected.size();
442+ if (objnum) {
443+ edge = li.edge(*selected.begin() - 1);
444+ if (uv) {
445+ MGEdge& be = *(edge->make_binder_with_curve());
446+ MGTrimmedCurve cij = be.trimmed_curve();
447+ double t;
448+ get_near_position(&cij, centrApertr, t);
449+ *uv = edge->eval(be.param_pcell(t));
450+ }
451+ break;
452+ }
453+ }
454+ return edge;
455+}
456+
457+//Determine if screen coordinate (sx,sy) is closer to the start point or to the end
458+//of the curve curve.
459+//Functin's return value is 0: if start point, 1: if end point.
460+int MGOpenGLView::pick_start_end_glv(
461+ const MGCurve& curve,
462+ int sx, int sy //Screen coordinates. (left, bottom) is (0,0).
463+) {
464+ MGStraight sl;
465+ unproject_to_sl_glv(sx, sy, sl);
466+ MGPosition P0 = curve.start_point(), P1 = curve.end_point();
467+ if (sl.distance(P0) <= sl.distance(P1))
468+ return 0;
469+ return 1;
470+}
471+
472+///Extract selectionName data from the frame buffer drawn by selectionDraw();
473+void MGOpenGLView::extractSelected(
474+ const int viewport[4],///Viewport of the selection target window.
475+ std::set<unsigned>& selected///Selected name data will be returned.
476+ /// This data consist of the data set by selectionDraw.
477+){
478+ GLint x = viewport[0], y = viewport[1];
479+ GLsizei width = viewport[2], height = viewport[3];
480+ int numPixels = width * height;
481+ unsigned* pixels = new unsigned[numPixels];
482+ glReadPixels(x, y, width, height, GL_RGBA, GL_UNSIGNED_BYTE, pixels);
483+ //if((glErr=glGetError()) != GL_NO_ERROR){
484+ // CString msg(gluErrorString(glErr));
485+ // COUT<<"MGOpenGLView::extractSelected::glReadPixels::"<<(TCAST)msg<<std::endl;
486+ //}
487+ for (int i = 0; i < numPixels; i++) {
488+ mgGLSLProgram::SELECT_NAME nub;
489+ nub.uiName = pixels[i];
490+ unsigned pixeli = nub.uiName;//unsigned pixeli=pixels[i];
491+ if (pixeli != 0) {
492+ selected.insert(pixeli);
493+ }
494+ }
495+ delete[] pixels;
496+}
497+
498+//Project world coordinates to OpenGL's screen coordinates.
499+//If modelMat, projMat, or vp is not input, project will ask OpenGL to get them.
500+//Generally, users of project are recommended to get modelMat, projlMat, or
501+//vp, and input them to project if continuous multiple use of project will take place.
502+//If one of modelMat, projlMat, or vp is not input, makeRCCurrent() must be invoked
503+//before use of project.
504+void MGOpenGLView::project(
505+ const MGPosition& world,
506+ MGPosition& screen,
507+ const glm::mat4* modelMat, //OpenGL's model matrix
508+ const glm::mat4* projlMat //OpenGL's projection matrix
509+) const {
510+ const glm::mat4* model = modelMat;
511+ const glm::mat4* proj = projlMat;
512+ glm::mat4 modelM, projM;
513+
514+ if (!proj) {
515+ proj = &projM;
516+ get_projection_matrix(m_viewPort, projM);
517+ }
518+ if (!model) {
519+ model = &modelM;
520+ get_model_matrix(modelM);
521+ }
522+
523+ glm::vec3 obj(world[0], world[1], world[2]);
524+ glm::ivec4 vp2(m_viewPort[0],m_viewPort[1],m_viewPort[2],m_viewPort[3]);
525+ glm::vec3 v = glm::project(obj, *model, *proj, vp2);
526+ screen = MGPosition(v[0], v[1], v[2]);
527+}
--- MGCL/MGCLDLLV10/src/mgGL/glslprogram.cpp (revision 33)
+++ MGCL/MGCLDLLV10/src/mgGL/glslprogram.cpp (revision 34)
@@ -345,8 +345,8 @@
345345 void mgGLSL::dumpGLInfo(bool dumpExtensions) {
346346 CString renderer(glGetString( GL_RENDERER ));
347347 CString vendor(glGetString( GL_VENDOR ));
348- CString version = glGetString( GL_VERSION );
349- CString glslVersion = glGetString( GL_SHADING_LANGUAGE_VERSION );
348+ CString version(glGetString( GL_VERSION ));
349+ CString glslVersion(glGetString( GL_SHADING_LANGUAGE_VERSION ));
350350
351351 GLint major, minor;
352352 glGetIntegerv(GL_MAJOR_VERSION, &major);
Show on old repository browser