Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Dave Griffiths
jellyfish
Commits
cdcd63c5
Commit
cdcd63c5
authored
Feb 23, 2015
by
Dave Griffiths
Browse files
added no window mode
parent
31bf2ee1
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
88 additions
and
29 deletions
+88
-29
experiments/sb.scm
experiments/sb.scm
+3
-5
experiments/tesst.scm
experiments/tesst.scm
+11
-3
src/engine/engine.cpp
src/engine/engine.cpp
+18
-3
src/engine/engine.h
src/engine/engine.h
+1
-0
src/engine/text_primitive.cpp
src/engine/text_primitive.cpp
+6
-3
src/engine/text_primitive.h
src/engine/text_primitive.h
+6
-6
src/main.cpp
src/main.cpp
+19
-8
src/scheme/opdefines.h
src/scheme/opdefines.h
+2
-1
src/scheme/scheme.cpp
src/scheme/scheme.cpp
+22
-0
No files found.
experiments/sb.scm
View file @
cdcd63c5
...
...
@@ -109,7 +109,7 @@
(
hint-unlit
)
;;(hint-depth-sort)
;;(texture-params 0 (list 'min 'linear 'mag 'linear))
(
texture
(
load-texture
"font.png"
(
texture
(
load-texture
"
oolite-
font.png"
;;(list 'generate-mipmaps 0 'mip-level 0)
))
(
for-each
...
...
@@ -127,9 +127,7 @@
; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
(
define
(
set-text
text
)
;;(text-params text (/ 16 256) (/ 16 256) 16 0 -0.01 0 15 -20 0.005 0.2)
0
)
(
text-params
text
(
/
16
256
)
(
/
16
256
)
16
0
-0.01
0
15
-20
0.005
0.2
)
)
(
define
(
make-brick
text
children
)
(
let*
((
atom
(
not
children
))
...
...
@@ -141,7 +139,7 @@
;;(hint-depth-sort)
(
colour
0
)
;;(texture-params 0 (list 'min 'linear 'mag 'linear))
(
texture
(
load-texture
"font.png"
(
texture
(
load-texture
"
oolite-
font.png"
;;(list 'generate-mipmaps 0 'mip-level 0)
))
(
msg
text
)
...
...
experiments/tesst.scm
View file @
cdcd63c5
...
...
@@ -69,9 +69,17 @@
(
translate
(
vector
-4
2
0
))
(
with-state
(
texture
(
load-texture
"font.png"
))
(
build-text
"hello"
))
(
define
t
(
with-state
(
hint-unlit
)
(
texture
(
load-texture
"oolite-font.png"
))
(
build-text
"hello"
)))
(
with-primitive
t
(
set-text
"xxxooo"
)
(
text-params
"world"
(
/
16
256
)
(
/
16
256
)
16
0
-0.01
0
15
-20
0.005
0.2
)
)
(
translate
(
vector
2
-6
0
))
(
texture
0
)
...
...
src/engine/engine.cpp
View file @
cdcd63c5
...
...
@@ -362,9 +362,9 @@ int engine::build_obj(obj_reader &reader)
int
engine
::
build_text
(
char
*
str
)
{
// 16*16 grid of letters
text_primitive
*
p
=
new
text_primitive
(
strlen
(
str
)
,
16
/
256.0
f
,
16
/
256.0
f
,
16
,
0
);
text_primitive
*
p
=
new
text_primitive
(
64
,
16
/
256.0
f
,
16
/
256.0
f
,
16
,
0
);
scenenode
*
n
=
new
scenenode
(
p
);
p
->
set_text
(
str
);
p
->
set_text
(
str
,
20
,
-
20
,
0
);
setup_state
(
n
);
return
m_sg
->
add
(
state_top
()
->
m_parent
,
n
);
}
...
...
@@ -421,7 +421,22 @@ void engine::text_set(const char *str)
if
(
n
&&
n
->
m_primitive
!=
NULL
)
{
// todo: check
((
text_primitive
*
)(
n
->
m_primitive
))
->
set_text
(
str
);
((
text_primitive
*
)(
n
->
m_primitive
))
->
set_text
(
str
,
20
,
-
20
,
0
);
}
}
}
// 0 1 2 3 4 5 6 7 8 9 10
void
engine
::
text_params
(
char
*
text
,
flx_real
w
,
flx_real
h
,
int
stride
,
int
wrap
,
flx_real
xoff
,
flx_real
yoff
,
flx_real
crowd
,
flx_real
width
,
flx_real
height
,
flx_real
zoom
)
{
if
(
grabbed
())
{
scenenode
*
n
=
grabbed_node
();
if
(
n
&&
n
->
m_primitive
!=
NULL
)
{
// todo: check
((
text_primitive
*
)(
n
->
m_primitive
))
->
set_text_params
(
w
,
h
,
stride
,
wrap
,
xoff
,
yoff
,
zoom
);
((
text_primitive
*
)(
n
->
m_primitive
))
->
set_text
(
text
,
crowd
,
width
,
height
);
}
}
}
...
...
src/engine/engine.h
View file @
cdcd63c5
...
...
@@ -49,6 +49,7 @@ public:
void
clear
();
void
destroy
(
int
id
);
void
text_set
(
const
char
*
str
);
void
text_params
(
char
*
text
,
flx_real
w
,
flx_real
h
,
int
stride
,
int
wrap
,
flx_real
xoff
,
flx_real
yoff
,
flx_real
crowd
,
flx_real
width
,
flx_real
height
,
flx_real
zoom
);
mat44
*
get_transform
();
mat44
get_global_transform
();
mat44
*
get_camera_transform
()
{
return
&
m_camera_tx
;
}
...
...
src/engine/text_primitive.cpp
View file @
cdcd63c5
...
...
@@ -29,12 +29,12 @@ text_primitive::text_primitive(u32 max_chars, flx_real charw, flx_real charh, in
{
}
void
text_primitive
::
set_text
(
const
char
*
str
)
void
text_primitive
::
set_text
(
const
char
*
str
,
flx_real
width
,
flx_real
height
,
flx_real
zoom
)
{
unsigned
int
length
=
strlen
(
str
);
flx_real
x
=
0
,
y
=
0
;
flx_real
w
=
m_char_width
*
20.0
f
;
flx_real
h
=
m_char_height
*
-
20.0
f
;
flx_real
w
=
m_char_width
*
width
;
flx_real
h
=
m_char_height
*
height
;
//20,-20,0.018
m_text_width
=
m_char_width
*
(
float
)
length
;
...
...
@@ -44,6 +44,9 @@ void text_primitive::set_text(const char *str)
flx_real
z
=
0
;
flx_real
zm
=
0.0001
;
m_text_width
-=
zoom
*
50.0
f
;
//??? some constant scaling to covert from texture
// coordinates to world space
for
(
u32
n
=
0
;
n
<
m_size
;
n
++
)
{
m_positions
[
n
].
x
=
0
;
...
...
src/engine/text_primitive.h
View file @
cdcd63c5
...
...
@@ -28,17 +28,17 @@ public:
/// charw,h are in _texture_ coords not pixels
text_primitive
(
u32
max_chars
,
flx_real
charw
,
flx_real
charh
,
int
charstride
,
int
wrapchars
=
0
);
~
text_primitive
()
{}
virtual
void
render
(
u32
hints
);
void
set_text
(
const
char
*
s
);
void
set_text
(
const
char
*
s
,
flx_real
width
,
flx_real
height
,
flx_real
zoom
);
flx_real
get_text_width
()
{
return
m_text_width
;
}
flx_real
get_text_height
()
{
return
m_text_height
;
}
void
set_text_params
(
flx_real
w
,
flx_real
h
,
int
stride
,
int
wrap
,
flx_real
xoff
,
flx_real
yoff
,
flx_real
crowd
);
protected:
u32
m_max_chars
;
flx_real
m_char_width
;
flx_real
m_char_height
;
...
...
@@ -48,7 +48,7 @@ protected:
u32
m_wrap_chars
;
flx_real
m_xoff
;
flx_real
m_yoff
;
flx_real
m_crowd
;
flx_real
m_crowd
;
};
#endif
src/main.cpp
View file @
cdcd63c5
...
...
@@ -185,6 +185,10 @@ void repl_loop() {
int
main
(
int
argc
,
char
*
argv
[])
{
bool
window
=
true
;
if
(
argc
>=
2
&&
!
strcmp
(
argv
[
1
],
"-nw"
))
window
=
false
;
if
(
window
)
{
#ifdef FLX_RPI
bcm_host_init
();
// Clear application state
...
...
@@ -211,16 +215,21 @@ int main(int argc, char *argv[])
glutMotionFunc
(
MotionCallback
);
glutPassiveMotionFunc
(
PassiveMotionCallback
);
#endif
}
appInit
();
initGL
();
if
(
window
)
{
initGL
();
}
appEval
((
char
*
)
LoadFile
(
string
(
ASSETS_PATH
)
+
"init.scm"
).
c_str
());
appEval
((
char
*
)
LoadFile
(
string
(
ASSETS_PATH
)
+
"boot.scm"
).
c_str
());
if
(
window
)
appEval
((
char
*
)
LoadFile
(
string
(
ASSETS_PATH
)
+
"boot.scm"
).
c_str
());
appEval
((
char
*
)
LoadFile
(
string
(
ASSETS_PATH
)
+
"lib.scm"
).
c_str
());
appEval
((
char
*
)
LoadFile
(
string
(
ASSETS_PATH
)
+
"compiler.scm"
).
c_str
());
appEval
((
char
*
)
LoadFile
(
string
(
ASSETS_PATH
)
+
"fluxa.scm"
).
c_str
());
if
(
window
)
{
// preload the textures
long
w
=
0
,
h
=
0
;
unsigned
char
*
tex
=
LoadPNG
(
string
(
ASSETS_PATH
)
+
"raspberrypi.png"
,
w
,
h
);
...
...
@@ -231,11 +240,12 @@ int main(int argc, char *argv[])
appLoadTexture
(
"bg.png"
,
w
,
h
,(
char
*
)
tex
);
tex
=
LoadPNG
(
string
(
ASSETS_PATH
)
+
"thread.png"
,
w
,
h
);
appLoadTexture
(
"thread.png"
,
w
,
h
,(
char
*
)
tex
);
tex
=
LoadPNG
(
string
(
ASSETS_PATH
)
+
"font.png"
,
w
,
h
);
appLoadTexture
(
"font.png"
,
w
,
h
,(
char
*
)
tex
);
tex
=
LoadPNG
(
string
(
ASSETS_PATH
)
+
"oolite-font.png"
,
w
,
h
);
appLoadTexture
(
"oolite-font.png"
,
w
,
h
,(
char
*
)
tex
);
}
if
(
argc
>
1
)
{
appEval
((
char
*
)
LoadFile
(
string
(
argv
[
1
])).
c_str
());
appEval
((
char
*
)
LoadFile
(
string
(
argv
[
argc
-
1
])).
c_str
());
}
// setup the repl thread
...
...
@@ -256,10 +266,11 @@ int main(int argc, char *argv[])
KeyboardUpCallback
);
//usleep(5*1000);
DisplayCallback
();
if
(
window
)
DisplayCallback
();
}
#else
glutMainLoop
();
if
(
window
)
glutMainLoop
();
else
while
(
true
)
{
sleep
(
1
);
}
#endif
return
0
;
...
...
src/scheme/opdefines.h
View file @
cdcd63c5
...
...
@@ -244,8 +244,9 @@
_OP_DEF
(
opexe_6
,
"pdata-ref"
,
2
,
2
,
0
,
OP_PDATA_REF
)
_OP_DEF
(
opexe_6
,
"pdata-set!"
,
3
,
3
,
0
,
OP_PDATA_SET
)
_OP_DEF
(
opexe_6
,
"set-text"
,
1
,
1
,
0
,
OP_SET_TEXT
)
_OP_DEF
(
opexe_6
,
"text-params"
,
11
,
11
,
0
,
OP_TEXT_PARAMS
)
_OP_DEF
(
opexe_6
,
"recalc-bb"
,
0
,
0
,
0
,
OP_RECALC_BB
)
_OP_DEF
(
opexe_6
,
"bb/point-intersect?"
,
2
,
2
,
0
,
OP_BB_POINT_INTERSECT
)
_OP_DEF
(
opexe_6
,
"bb/point-intersect?"
,
2
,
2
,
0
,
OP_BB_POINT_INTERSECT
)
_OP_DEF
(
opexe_6
,
"geo/line-intersect"
,
2
,
2
,
0
,
OP_GEO_LINE_INTERSECT
)
_OP_DEF
(
opexe_6
,
"get-line-intersect"
,
2
,
2
,
0
,
OP_GET_LINE_INTERSECT
)
_OP_DEF
(
opexe_6
,
"get-screen-size"
,
0
,
0
,
0
,
OP_GET_SCREEN_SIZE
)
...
...
src/scheme/scheme.cpp
View file @
cdcd63c5
...
...
@@ -3516,6 +3516,13 @@ int list_length(scheme *sc, pointer a) {
}
}
pointer
list_ref
(
scheme
*
sc
,
pointer
l
,
int
i
)
{
while
(
i
>
0
&&
l
!=
sc
->
NIL
)
{
l
=
cdr
(
l
);
}
return
car
(
l
);
}
static
pointer
opexe_3
(
scheme
*
sc
,
enum
scheme_opcodes
op
)
{
pointer
x
;
num
v
;
...
...
@@ -4755,6 +4762,21 @@ static pointer opexe_6(scheme *sc, enum scheme_opcodes op) {
engine
::
get
()
->
text_set
(
string_value
(
car
(
sc
->
args
)));
s_return
(
sc
,
sc
->
F
);
}
case
OP_TEXT_PARAMS
:
{
engine
::
get
()
->
text_params
(
string_value
(
list_ref
(
sc
,
sc
->
args
,
0
)),
rvalue
(
list_ref
(
sc
,
sc
->
args
,
1
)),
rvalue
(
list_ref
(
sc
,
sc
->
args
,
2
)),
ivalue
(
list_ref
(
sc
,
sc
->
args
,
3
)),
ivalue
(
list_ref
(
sc
,
sc
->
args
,
4
)),
rvalue
(
list_ref
(
sc
,
sc
->
args
,
5
)),
rvalue
(
list_ref
(
sc
,
sc
->
args
,
6
)),
rvalue
(
list_ref
(
sc
,
sc
->
args
,
7
)),
rvalue
(
list_ref
(
sc
,
sc
->
args
,
8
)),
rvalue
(
list_ref
(
sc
,
sc
->
args
,
9
)),
rvalue
(
list_ref
(
sc
,
sc
->
args
,
10
)));
s_return
(
sc
,
sc
->
F
);
}
case
OP_RECALC_BB
:
{
engine
::
get
()
->
recalc_bb
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment