Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Luis Penaranda
panoramic
Commits
6aa451bd
Commit
6aa451bd
authored
Mar 06, 2013
by
Luis Penaranda
Browse files
more windows compatibility
parent
3b709df8
Changes
2
Hide whitespace changes
Inline
Side-by-side
openglcanvas.cpp
View file @
6aa451bd
...
...
@@ -6,21 +6,34 @@
#include
<cmath>
#include
<sys/types.h>
// for fstat, getpwuid, getuid
#include
<sys/stat.h>
// for fstat
#ifndef _WIN32
# include <pwd.h> // for getpwuid (TODO: windows?)
#ifdef _WIN32
#include
<stdlib.h>
// for getenv (TODO: use getenv_s)
#else
#include
<pwd.h>
// for getpwuid
#endif
#include
<cstdio>
// for fopen, fclose, getc
#include
<cstring>
#ifdef _
WIN32
#ifdef _
MSC_VER
#include
<direct.h>
#define GET_WORKDIR _getcwd
#define OPEN_FILE _open
#define LSEEK_FD _lseek
#define FOPEN_RO(_descriptor,_filename) \
if(fopen_s(&(_descriptor),_filename,"r")){ \
fprintf(stderr,"unable to open file '%s'\n",_filename); \
exit(-1); \
}
#else
// unistd was included above
#define GET_WORKDIR getcwd
#define OPEN_FILE open
#define LSEEK_FD lseek
#define FOPEN_RO(_descriptor,_filename) \
(_descriptor=fopen(_filename,"r")); \
if((_descriptor)==NULL) \
fprintf(stderr,"unable to open file '%s'\n",_filename); \
exit(-1); \
}
#endif
#define PROGNAME "pano_interface"
...
...
@@ -195,22 +208,19 @@ void OpenGLCanvas::change_visualization(QString name){
// This function reads the contents of the ~/.panorc file and stores the
// options in private variables.
// TODO: windows
void
OpenGLCanvas
::
read_config_file
(){
#ifdef _WIN32
char
*
envvar
=
(
char
*
)
malloc
(
12
*
sizeof
(
char
));
strcpy
(
envvar
,
"USERPROFILE
\0
"
);
char
*
filepath
=
(
char
*
)
malloc
(
512
*
sizeof
(
char
));
if
(
!
GET_WORKDIR
(
filepath
,
512
)){
fprintf
(
stderr
,
"error reading config file
\n
"
);
exit
(
-
1
);
}
strcat
(
filepath
,
"/panorc"
);
// TODO
strcpy
(
filepath
,
getenv
(
envvar
));
free
(
envvar
);
strcat
(
filepath
,
"
\\
.panorc"
);
#else
struct
passwd
*
pw
=
getpwuid
(
getuid
());
char
*
filepath
=
pw
->
pw_dir
;
strcat
(
filepath
,
"/.panorc"
);
#endif
fprintf
(
stderr
,
"the user config file is %s
\n
"
,
filepath
);
shader_dir
=
(
char
*
)
malloc
(
512
*
sizeof
(
char
));
shader_dir
[
0
]
=
'\0'
;
input_image_file
=
(
char
*
)
malloc
(
512
*
sizeof
(
char
));
...
...
@@ -218,9 +228,10 @@ void OpenGLCanvas::read_config_file(){
char
*
read_line
=
(
char
*
)
malloc
(
64
*
sizeof
(
char
));
struct
stat
testbuf
;
if
(
stat
(
filepath
,
&
testbuf
)){
fprintf
(
stderr
,
"
~/.panorc
does not exist
\n
"
);
fprintf
(
stderr
,
"
%s
does not exist
\n
"
,
filepath
);
}
else
{
FILE
*
rcfile
=
fopen
(
filepath
,
"r"
);
FILE
*
rcfile
;
FOPEN_RO
(
rcfile
,
filepath
);
char
c
;
char
*
line
=
(
char
*
)
malloc
(
512
*
sizeof
(
char
));
while
((
c
=
getc
(
rcfile
))
!=
EOF
){
...
...
@@ -262,6 +273,9 @@ void OpenGLCanvas::read_config_file(){
}
fclose
(
rcfile
);
}
#ifdef _WIN32
free
(
filepath
);
#endif
emit
fov_changed
((
int
)
fov
);
emit
max_fov_changed
((
int
)
fov_max
);
}
...
...
@@ -545,11 +559,8 @@ int OpenGLCanvas::getTextureSize(const char * const progname, const char * textu
{
struct
pam
inpam
;
pm_init
(
progname
,
0
);
FILE
*
in_file
=
fopen
(
texturePath
,
"r"
);
if
(
in_file
==
NULL
){
fprintf
(
stderr
,
"ERROR in getTextureSize: unable to open specified file
\n
"
);
return
-
1
;
}
FILE
*
in_file
;
FOPEN_RO
(
in_file
,
texturePath
)
#ifdef PAM_STRUCT_SIZE
pnm_readpaminit
(
in_file
,
&
inpam
,
PAM_STRUCT_SIZE
(
tuple_type
));
...
...
@@ -577,7 +588,8 @@ void OpenGLCanvas::readTextureBytes(const char * const progname,
int
row
;
pm_init
(
progname
,
0
);
FILE
*
in_file
=
fopen
(
texturePath
,
"r"
);
FILE
*
in_file
;
FOPEN_RO
(
in_file
,
texturePath
);
#ifdef PAM_STRUCT_SIZE
pnm_readpaminit
(
in_file
,
&
inpam
,
PAM_STRUCT_SIZE
(
tuple_type
));
...
...
@@ -622,14 +634,15 @@ char * OpenGLCanvas::textFileRead(char *fn) {
count
=
LSEEK_FD
(
f
,
0
,
SEEK_END
);
// close(f);
if
(
fn
!=
NULL
)
{
fp
=
fopen
(
fn
,
"rt"
);
//fp = fopen(fn,"rt");
FOPEN_RO
(
fp
,
fn
);
if
(
fp
!=
NULL
)
{
if
(
count
>
0
)
{
content
=
(
char
*
)
malloc
(
sizeof
(
char
)
*
(
count
+
1
));
count
=
fread
(
content
,
sizeof
(
char
),
count
,
fp
);
content
[
count
]
=
'\0'
;
}
fclose
(
fp
);
fclose
(
fp
);
// maybe this line must be outside the {}
}
}
return
content
;
...
...
pano_interface_1.pro
View file @
6aa451bd
...
...
@@ -26,12 +26,16 @@ DEFINES += GLEW_STATIC
DEFINES
+=
_CRT_SECURE_NO_WARNINGS
INCLUDEPATH
+=
"C:/Program Files (x86)/glew-1.5.2/include"
DEPENDPATH
+=
"C:/Program Files (x86)/glew-1.5.2/include"
INCLUDEPATH
+=
"C:/Program Files (x86)/freeglut/include"
DEPENDPATH
+=
"C:/Program Files (x86)/freeglut/include"
INCLUDEPATH
+=
"C:/Program Files (x86)/GnuWin32/include"
DEPENDPATH
+=
"C:/Program Files (x86)/GnuWin32/include"
LIBS
+=
"/nodefaultlib:LIBCMT"
LIBS
+=
-
L
"C:/Program Files (x86)/freeglut/lib"
LIBS
+=
-
L
"C:/Program Files (x86)/GnuWin32/lib"
LIBS
+=
-
lglu32
-
lopengl32
-
lfreeglut
-
llibnetpbm10
LIBS
+=
-
L
"C:/Program Files (x86)/GnuWin32/bin"
LIBS
+=
-
L
"C:/Program Files (x86)/glew-1.5.2/lib"
LIBS
+=
-
lglew32s
LIBS
+=
-
lfreeglut
-
lglu32
-
lopengl32
-
llibnetpbm10
-
lglew32s
}
TARGET
=
pano_interface_1
...
...
Write
Preview
Supports
Markdown
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