Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Sauvage
CGoGN
Commits
cfe6d910
Commit
cfe6d910
authored
Apr 20, 2011
by
Sylvain Thery
Browse files
Ajout CGoGNStream
Amelioration msg compil Shader
parent
f22dfb72
Changes
22
Hide whitespace changes
Inline
Side-by-side
Apps/Tuto/tuto4.cpp
View file @
cfe6d910
...
...
@@ -40,6 +40,7 @@
#include
"Utils/shaderSimpleColor.h"
#include
"Utils/shaderFlat.h"
#include
"Utils/cgognStream.h"
using
namespace
CGoGN
;
...
...
@@ -241,7 +242,6 @@ int main(int argc, char **argv)
dock
.
vertexEdit
->
setPlainText
(
QString
(
sqt
.
m_shader2
->
getVertexShaderSrc
()));
dock
.
fragmentEdit
->
setPlainText
(
QString
(
sqt
.
m_shader2
->
getFragmentShaderSrc
()));
dock
.
geometryEdit
->
setPlainText
(
QString
(
sqt
.
m_shader2
->
getGeometryShaderSrc
()));
// show final pour premier redraw
sqt
.
show
();
...
...
Apps/Tuto/tuto4.ui
View file @
cfe6d910
...
...
@@ -81,10 +81,10 @@
<number>
100
</number>
</property>
<property
name=
"value"
>
<number>
9
0
</number>
<number>
10
0
</number>
</property>
<property
name=
"sliderPosition"
>
<number>
9
0
</number>
<number>
10
0
</number>
</property>
<property
name=
"orientation"
>
<enum>
Qt::Horizontal
</enum>
...
...
@@ -116,7 +116,17 @@
</attribute>
<layout
class=
"QGridLayout"
name=
"gridLayout_4"
>
<item
row=
"0"
column=
"0"
>
<widget
class=
"QTextEdit"
name=
"vertexEdit"
/>
<widget
class=
"QTextEdit"
name=
"vertexEdit"
>
<property
name=
"lineWrapMode"
>
<enum>
QTextEdit::NoWrap
</enum>
</property>
<property
name=
"tabStopWidth"
>
<number>
20
</number>
</property>
<property
name=
"acceptRichText"
>
<bool>
false
</bool>
</property>
</widget>
</item>
</layout>
</widget>
...
...
@@ -126,7 +136,17 @@
</attribute>
<layout
class=
"QGridLayout"
name=
"gridLayout_2"
>
<item
row=
"0"
column=
"0"
>
<widget
class=
"QTextEdit"
name=
"fragmentEdit"
/>
<widget
class=
"QTextEdit"
name=
"fragmentEdit"
>
<property
name=
"lineWrapMode"
>
<enum>
QTextEdit::NoWrap
</enum>
</property>
<property
name=
"tabStopWidth"
>
<number>
20
</number>
</property>
<property
name=
"acceptRichText"
>
<bool>
false
</bool>
</property>
</widget>
</item>
</layout>
</widget>
...
...
@@ -143,6 +163,24 @@
<verstretch>
1
</verstretch>
</sizepolicy>
</property>
<property
name=
"verticalScrollBarPolicy"
>
<enum>
Qt::ScrollBarAsNeeded
</enum>
</property>
<property
name=
"horizontalScrollBarPolicy"
>
<enum>
Qt::ScrollBarAsNeeded
</enum>
</property>
<property
name=
"lineWrapMode"
>
<enum>
QTextEdit::NoWrap
</enum>
</property>
<property
name=
"overwriteMode"
>
<bool>
false
</bool>
</property>
<property
name=
"tabStopWidth"
>
<number>
20
</number>
</property>
<property
name=
"acceptRichText"
>
<bool>
false
</bool>
</property>
</widget>
</item>
</layout>
...
...
Apps/Tuto/tuto5.cpp
View file @
cfe6d910
...
...
@@ -47,6 +47,8 @@
#include
"Utils/pointSprite.h"
#include
"Utils/pointLine.h"
#include
"Utils/cgognStream.h"
using
namespace
CGoGN
;
...
...
@@ -81,7 +83,6 @@ void MyQT::vectors_onoff(bool x)
void
MyQT
::
text_onoff
(
bool
x
)
{
statusMsg
(
NULL
);
render_text
=
!
render_text
;
updateGL
();
}
...
...
@@ -231,12 +232,35 @@ void MyQT::cb_redraw()
}
void
MyQT
::
cb_mousePress
(
int
button
,
int
x
,
int
y
)
{
if
(
Shift
())
{
Dart
d
=
m_render_topo
->
picking
<
PFP
>
(
myMap
,
allDarts
,
x
,
getHeight
()
-
y
);
if
(
d
!=
Dart
::
nil
())
{
// std::stringstream ss;
// ss << "Dart "<< d << " clicked"<< std::endl;
// statusMsg(ss.str().c_str());
CGoGNout
<<
"Dart "
<<
d
<<
" clicked"
<<
CGoGNendl
;
}
else
{
statusMsg
(
""
);
}
}
}
int
main
(
int
argc
,
char
**
argv
)
{
position
=
myMap
.
addAttribute
<
PFP
::
VEC3
>
(
VERTEX_ORBIT
,
"position"
);
CGoGNout
<<
5.34
<<
" toto "
<<
Geom
::
Vec3f
(
2.5
,
2.2
,
4.3
)
<<
CGoGNendl
;
CGoGNout
<<
3
<<
" tutu "
<<
4
<<
CGoGNendl
;
Algo
::
Modelisation
::
Primitive3D
<
PFP
>
prim
(
myMap
,
position
);
int
nb
=
3
;
...
...
@@ -258,7 +282,17 @@ int main(int argc, char **argv)
// message d'aide
sqt
.
setHelpMsg
(
""
);
sqt
.
statusMsg
(
"3Map with topo rendering & attribute shader utilization"
);
CGoGNout
.
out2StatuBar
(
&
sqt
);
CGoGNout
<<
"CGoGNOut StatusBar"
<<
Geom
::
Vec3f
(
2.5
,
2.2
,
4.3
)
<<
CGoGNendl
;
CGoGNout
.
out2Console
(
&
sqt
);
CGoGNout
<<
"CGoGNOut dans la console"
<<
Geom
::
Vec3f
(
2.5
,
2.2
,
4.3
)
<<
CGoGNendl
;
CGoGNout
.
out2StatuBar
(
NULL
);
CGoGNout
<<
"tirelipinpon .."
<<
CGoGNendl
;
CGoGNout
<<
"ah aha ah"
<<
CGoGNendl
;
// bounding box
Geom
::
BoundingBox
<
PFP
::
VEC3
>
bb
=
Algo
::
Geometry
::
computeBoundingBox
<
PFP
>
(
myMap
,
position
);
...
...
@@ -283,7 +317,12 @@ int main(int argc, char **argv)
sqt
.
slider_vectors
(
50
);
sqt
.
slider_text
(
50
);
GLint
texSize
;
glGetIntegerv
(
GL_MAX_TEXTURE_SIZE
,
&
texSize
);
CGoGNdbg2
.
out2Console
(
&
sqt
);
CGoGNerr
.
out2Console
(
&
sqt
);
CGoGNdbg2
<<
" TextureSize "
<<
texSize
<<
CGoGNendl
;
CGoGNerr
<<
" ERROR "
<<
5
*
7
<<
CGoGNendl
;
// et on attend la fin.
return
app
.
exec
();
...
...
Apps/Tuto/tuto5.h
View file @
cfe6d910
...
...
@@ -91,6 +91,8 @@ protected:
void
cb_initGL
();
void
cb_mousePress
(
int
button
,
int
x
,
int
y
);
// slots locaux
public
slots
:
void
balls_onoff
(
bool
x
);
...
...
build/Debug/CMakeLists.txt
View file @
cfe6d910
...
...
@@ -77,6 +77,7 @@ add_library(
#)
add_definitions
(
-DSHADERPATH=
"
${
CGoGN_ROOT_DIR
}
/lib/Shaders/"
)
add_definitions
(
-DDBG_MAX_LEVEL=5
)
file
(
GLOB_RECURSE
...
...
build/Release/CMakeLists.txt
View file @
cfe6d910
...
...
@@ -77,7 +77,7 @@ add_library(
#)
add_definitions
(
-DSHADERPATH=
"
${
CGoGN_ROOT_DIR
}
/lib/Shaders/"
)
add_definitions
(
-DDBG_MAX_LEVEL=0
)
file
(
GLOB_RECURSE
...
...
include/Algo/Render/GL2/topo3Render.h
View file @
cfe6d910
...
...
@@ -63,6 +63,7 @@ protected:
* 1: vertices phi1
* 2: vertices phi2
* 3: vertices phi3
* 4: colors
*/
Utils
::
VBO
*
m_vbo0
;
Utils
::
VBO
*
m_vbo1
;
...
...
@@ -132,6 +133,24 @@ protected:
void
updateGMap3
(
typename
PFP
::
MAP
&
map
,
const
FunctorSelect
&
good
,
const
typename
PFP
::
TVEC3
&
positions
,
float
ke
,
float
kf
,
float
kv
);
/**
* save colors
*/
void
pushColors
();
/**
* restore colors
*/
void
popColors
();
/**
* pick dart with color set bey setDartsIdColor
* @param x position of mouse (x)
* @param y position of mouse (pass H-y, classic pb of origin)
* @return the dart or NIL
*/
Dart
pickColor
(
unsigned
int
x
,
unsigned
int
y
);
public:
...
...
@@ -234,16 +253,6 @@ public:
void
overdrawDart
(
Dart
d
,
float
width
,
float
r
,
float
g
,
float
b
);
/**
* save colors
*/
void
pushColors
();
/**
* restore colors
*/
void
popColors
();
/*
* store darts in color for picking
...
...
@@ -254,14 +263,19 @@ public:
void
setDartsIdColor
(
typename
PFP
::
MAP
&
map
,
const
FunctorSelect
&
good
);
/**
* pick dart with color set bey setDartsIdColor
* Do not forget to apply same transformation to scene before picking than before drawing !
* @param map the map
* @param good a dart selector
* @param x position of mouse (x)
* @param y position of mouse (pass H-y, classic pb of origin)
* @return the dart or NIL
*/
Dart
picking
(
unsigned
int
x
,
unsigned
int
y
);
template
<
typename
PFP
>
Dart
picking
(
typename
PFP
::
MAP
&
map
,
const
FunctorSelect
&
good
,
int
x
,
int
y
);
};
//template<typename MAP>
...
...
include/Algo/Render/GL2/topo3Render.hpp
View file @
cfe6d910
...
...
@@ -674,6 +674,10 @@ void Topo3RenderMapD::updateData(typename PFP::MAP& map, const FunctorSelect& go
m_vbo4
->
bind
();
glUnmapBuffer
(
GL_ARRAY_BUFFER
);
}
//
//
//
...
...
@@ -927,6 +931,18 @@ void Topo3Render::setDartsIdColor(typename PFP::MAP& map, const FunctorSelect& g
glUnmapBuffer
(
GL_ARRAY_BUFFER
);
}
template
<
typename
PFP
>
Dart
Topo3Render
::
picking
(
typename
PFP
::
MAP
&
map
,
const
FunctorSelect
&
good
,
int
x
,
int
y
)
{
pushColors
();
setDartsIdColor
<
PFP
>
(
map
,
good
);
Dart
d
=
pickColor
(
x
,
y
);
popColors
();
return
d
;
}
}
//end namespace VBO
...
...
include/Algo/Render/GL2/topoRender.h
View file @
cfe6d910
...
...
@@ -88,6 +88,9 @@ protected:
*/
float
m_topo_relation_width
;
float
*
m_color_save
;
/**
* attribut d'index dans le VBO
*/
...
...
@@ -101,6 +104,15 @@ protected:
void
dartToCol
(
Dart
d
,
float
&
r
,
float
&
g
,
float
&
b
);
Dart
pickColor
(
unsigned
int
x
,
unsigned
int
y
);
template
<
typename
PFP
>
void
setDartsIdColor
(
typename
PFP
::
MAP
&
map
,
const
FunctorSelect
&
good
);
void
pushColors
();
void
popColors
();
public:
/**
* Constructor
...
...
@@ -179,11 +191,14 @@ public:
/**
* pick dart with color set bey setDartsIdColor
* Do not forget to apply same transformation to scene before picking than before drawing !
* @param map the map in which we pick (same as drawn !)
* @param good the selector (same as used during drawing)
* @param x position of mouse (x)
* @param y position of mouse (pass H-y, classic pb of origin)
* @return the dart or NIL
*/
Dart
picking
(
unsigned
int
x
,
unsigned
int
y
);
template
<
typename
PFP
>
Dart
picking
(
typename
PFP
::
MAP
&
map
,
const
FunctorSelect
&
good
,
int
x
,
int
y
);
};
class
TopoRenderMapD
:
public
TopoRender
...
...
include/Algo/Render/GL2/topoRender.hpp
View file @
cfe6d910
...
...
@@ -338,6 +338,55 @@ void TopoRenderGMap::updateData(typename PFP::MAP& map, const typename PFP::TVEC
*/
}
template
<
typename
PFP
>
void
TopoRender
::
setDartsIdColor
(
typename
PFP
::
MAP
&
map
,
const
FunctorSelect
&
good
)
{
m_vbo3
->
bind
();
float
*
colorBuffer
=
reinterpret_cast
<
float
*>
(
glMapBuffer
(
GL_ARRAY_BUFFER
,
GL_READ_WRITE
));
unsigned
int
nb
=
0
;
for
(
Dart
d
=
map
.
begin
();
d
!=
map
.
end
();
map
.
next
(
d
))
{
if
(
nb
<
m_nbDarts
)
{
if
(
good
(
d
))
{
float
r
,
g
,
b
;
dartToCol
(
d
,
r
,
g
,
b
);
float
*
local
=
colorBuffer
+
3
*
m_attIndex
[
d
];
// get the right position in VBO
*
local
++
=
r
;
*
local
++
=
g
;
*
local
++
=
b
;
*
local
++
=
r
;
*
local
++
=
g
;
*
local
++
=
b
;
nb
++
;
}
}
else
{
std
::
cerr
<<
"Error buffer too small for color picking (change the good parameter ?)"
<<
std
::
endl
;
d
=
map
.
end
();
}
}
glUnmapBuffer
(
GL_ARRAY_BUFFER
);
}
template
<
typename
PFP
>
Dart
TopoRender
::
picking
(
typename
PFP
::
MAP
&
map
,
const
FunctorSelect
&
good
,
int
x
,
int
y
)
{
pushColors
();
setDartsIdColor
<
PFP
>
(
map
,
good
);
Dart
d
=
pickColor
(
x
,
y
);
popColors
();
return
d
;
}
}
//end namespace GL2
}
//end namespace Algo
...
...
include/Utils/GLSLShader.h
View file @
cfe6d910
...
...
@@ -97,6 +97,10 @@ protected:
*/
GLhandleARB
m_geom_shader_object
;
std
::
string
m_nameVS
;
std
::
string
m_nameFS
;
std
::
string
m_nameGS
;
/**
* handle of program
*/
...
...
include/Utils/cgognStream.h
0 → 100644
View file @
cfe6d910
/*******************************************************************************
* CGoGN: Combinatorial and Geometric modeling with Generic N-dimensional Maps *
* version 0.1 *
* Copyright (C) 2009, IGG Team, LSIIT, University of Strasbourg *
* *
* This library is free software; you can redistribute it and/or modify it *
* under the terms of the GNU Lesser General Public License as published by the *
* Free Software Foundation; either version 2.1 of the License, or (at your *
* option) any later version. *
* *
* This library is distributed in the hope that it will be useful, but WITHOUT *
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or *
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License *
* for more details. *
* *
* You should have received a copy of the GNU Lesser General Public License *
* along with this library; if not, write to the Free Software Foundation, *
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. *
* *
* Web site: https://iggservis.u-strasbg.fr/CGoGN/ *
* Contact information: cgogn@unistra.fr *
* *
*******************************************************************************/
#ifndef _CGOGNSTREAM_H_
#define _CGOGNSTREAM_H_
#ifndef DBG_MAX_LEVEL
#define DBG_MAX_LEVEL 5
#endif
#include
<string>
#include
<iostream>
#include
<sstream>
#include
<fstream>
//forward defs
namespace
CGoGN
{
namespace
Utils
{
namespace
QT
{
class
SimpleQT
;
}
}
}
class
QTextEdit
;
namespace
CGoGN
{
namespace
CGoGNStream
{
enum
drawingType
{
STDOUT
=
1
,
STDERR
=
2
,
FILEOUT
=
4
,
QTSTATUSBAR
=
8
,
QTCONSOLE
=
16
,
SSBUFFER
=
32
};
class
Special
{};
template
<
int
LEVEL
>
class
Out
{
protected:
int
m_out_mode
;
std
::
stringstream
m_buffer
;
Utils
::
QT
::
SimpleQT
*
m_sqt_bar
;
Utils
::
QT
::
SimpleQT
*
m_sqt_console
;
QTextEdit
*
m_qte
;
std
::
ofstream
*
m_ofs
;
std
::
stringstream
*
m_oss
;
int
m_code
;
public:
/**
* constructor
*/
Out
();
/**
* destructor
*/
~
Out
();
/**
* set output to standard
*/
void
out2std
(
bool
yes
=
true
);
/**
* set output to file
*/
void
out2File
(
const
std
::
string
&
filename
);
/**
* set output to status bar of Qt interface
*/
void
out2StatuBar
(
Utils
::
QT
::
SimpleQT
*
sqt
);
/**
* set output to console of Qt interface
*/
void
out2Console
(
Utils
::
QT
::
SimpleQT
*
sqt
);
/**
* set output to string stream buffer
*/
void
out2Buffer
(
std
::
stringstream
*
ss
);
/**
* recursive stream operator
*/
Out
<
LEVEL
>&
operator
<<
(
Out
&
cgstr
);
/**
* classic stream operator
*/
template
<
typename
T
>
Out
<
LEVEL
>&
operator
<<
(
const
T
&
val
);
/**
* special cases (endl) stream operator
*/
Out
<
LEVEL
>&
operator
<<
(
Special
&
os
);
/**
* for file closing
*/
void
close
();
};
/**
* output stream class for error output (replace cout by cerr)
*/
template
<
int
LEVEL
>
class
Err
:
public
Out
<
LEVEL
>
{
public:
Err
()
{
this
->
m_code
=
1
;}
};
template
<
int
LEVEL
>
class
Dbg
:
public
Out
<
LEVEL
>
{
public:
Dbg
()
{
this
->
m_code
=
100
+
LEVEL
;}
};
}
// glocal stream definitions
extern
CGoGNStream
::
Out
<
0
>
CGoGNout
;
extern
CGoGNStream
::
Err
<
0
>
CGoGNerr
;
extern
CGoGNStream
::
Dbg
<
1
>
CGoGNdbg
;
extern
CGoGNStream
::
Dbg
<
2
>
CGoGNdbg2
;
extern
CGoGNStream
::
Dbg
<
3
>
CGoGNdbg3
;
extern
CGoGNStream
::
Special
CGoGNendl
;
}
#include
"Utils/cgognStream.hpp"
#endif
/* CGOGNSTREAM_H_ */
include/Utils/cgognStream.hpp
0 → 100644
View file @
cfe6d910
/*******************************************************************************
* CGoGN: Combinatorial and Geometric modeling with Generic N-dimensional Maps *
* version 0.1 *
* Copyright (C) 2009, IGG Team, LSIIT, University of Strasbourg *
* *
* This library is free software; you can redistribute it and/or modify it *
* under the terms of the GNU Lesser General Public License as published by the *
* Free Software Foundation; either version 2.1 of the License, or (at your *
* option) any later version. *
* *
* This library is distributed in the hope that it will be useful, but WITHOUT *
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or *
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License *
* for more details. *
* *
* You should have received a copy of the GNU Lesser General Public License *
* along with this library; if not, write to the Free Software Foundation, *
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. *
* *
* Web site: https://iggservis.u-strasbg.fr/CGoGN/ *
* Contact information: cgogn@unistra.fr *
* *
*******************************************************************************/
#include
"Utils/qtSimple.h"
#include
<QtGui/QTextEdit>
namespace
CGoGN
{
namespace
CGoGNStream
{
template
<
int
LEVEL
>
Out
<
LEVEL
>::
Out
()
:
m_out_mode
(
STDOUT
),
m_sqt_bar
(
NULL
),
m_sqt_console
(
NULL
),
m_qte
(
NULL
),