Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
glfw
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
pirvi-public
glfw
Commits
45740358
Commit
45740358
authored
Jan 11, 2014
by
Camilla Löwy
Browse files
Options
Downloads
Patches
Plain Diff
Replaced ad-hoc argument processing with getopt.
parent
3f9117ef
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
examples/CMakeLists.txt
+1
-1
1 addition, 1 deletion
examples/CMakeLists.txt
examples/particles.c
+31
-31
31 additions, 31 deletions
examples/particles.c
with
32 additions
and
32 deletions
examples/CMakeLists.txt
+
1
−
1
View file @
45740358
...
@@ -41,7 +41,7 @@ else()
...
@@ -41,7 +41,7 @@ else()
add_executable
(
boing WIN32 boing.c
)
add_executable
(
boing WIN32 boing.c
)
add_executable
(
gears WIN32 gears.c
)
add_executable
(
gears WIN32 gears.c
)
add_executable
(
heightmap WIN32 heightmap.c
${
GETOPT
}
)
add_executable
(
heightmap WIN32 heightmap.c
${
GETOPT
}
)
add_executable
(
particles WIN32 particles.c
${
TINYCTHREAD
}
)
add_executable
(
particles WIN32 particles.c
${
TINYCTHREAD
}
${
GETOPT
}
)
add_executable
(
simple WIN32 simple.c
)
add_executable
(
simple WIN32 simple.c
)
add_executable
(
splitview WIN32 splitview.c
)
add_executable
(
splitview WIN32 splitview.c
)
add_executable
(
wave WIN32 wave.c
)
add_executable
(
wave WIN32 wave.c
)
...
...
This diff is collapsed.
Click to expand it.
examples/particles.c
+
31
−
31
View file @
45740358
...
@@ -46,6 +46,7 @@
...
@@ -46,6 +46,7 @@
#include
<GLFW/glfw3.h>
#include
<GLFW/glfw3.h>
#include
<tinycthread.h>
#include
<tinycthread.h>
#include
<getopt.h>
// Define tokens for GL_EXT_separate_specular_color if not already defined
// Define tokens for GL_EXT_separate_specular_color if not already defined
#ifndef GL_EXT_separate_specular_color
#ifndef GL_EXT_separate_specular_color
...
@@ -238,6 +239,24 @@ const GLfloat floor_shininess = 18.f;
...
@@ -238,6 +239,24 @@ const GLfloat floor_shininess = 18.f;
const
GLfloat
fog_color
[
4
]
=
{
0
.
1
f
,
0
.
1
f
,
0
.
1
f
,
1
.
f
};
const
GLfloat
fog_color
[
4
]
=
{
0
.
1
f
,
0
.
1
f
,
0
.
1
f
,
1
.
f
};
//========================================================================
// Print usage information
//========================================================================
static
void
usage
(
void
)
{
printf
(
"Usage: particles [-hbs]
\n
"
);
printf
(
"Options:
\n
"
);
printf
(
" -b Benchmark (run program for 60 seconds)
\n
"
);
printf
(
" -s Run program as single thread (default is to use two threads)
\n
"
);
printf
(
" -h Display this help
\n
"
);
printf
(
"
\n
"
);
printf
(
"Program runtime controls:
\n
"
);
printf
(
" W Toggle wireframe mode
\n
"
);
printf
(
" Esc Exit program
\n
"
);
}
//========================================================================
//========================================================================
// Initialize a new particle
// Initialize a new particle
//========================================================================
//========================================================================
...
@@ -940,7 +959,7 @@ static int physics_thread_main(void* arg)
...
@@ -940,7 +959,7 @@ static int physics_thread_main(void* arg)
int
main
(
int
argc
,
char
**
argv
)
int
main
(
int
argc
,
char
**
argv
)
{
{
int
i
,
frames
,
benchmark
;
int
i
,
ch
,
frames
,
benchmark
;
double
t0
,
t
;
double
t0
,
t
;
thrd_t
physics_thread
=
0
;
thrd_t
physics_thread
=
0
;
GLFWwindow
*
window
;
GLFWwindow
*
window
;
...
@@ -949,38 +968,19 @@ int main(int argc, char** argv)
...
@@ -949,38 +968,19 @@ int main(int argc, char** argv)
multithreading
=
1
;
multithreading
=
1
;
benchmark
=
0
;
benchmark
=
0
;
for
(
i
=
1
;
i
<
argc
;
i
++
)
while
((
ch
=
getopt
(
argc
,
argv
,
"bhs"
))
!=
-
1
)
{
{
// Use benchmarking?
switch
(
ch
)
if
(
strcmp
(
argv
[
i
],
"-b"
)
==
0
)
{
case
'b'
:
benchmark
=
1
;
benchmark
=
1
;
break
;
// Force multithreading off?
case
'h'
:
else
if
(
strcmp
(
argv
[
i
],
"-s"
)
==
0
)
usage
();
exit
(
EXIT_SUCCESS
);
case
's'
:
multithreading
=
0
;
multithreading
=
0
;
break
;
// With a Finder launch on Mac OS X we get a bogus -psn_0_46268417
// kind of argument (actual numbers vary). Ignore it.
else
if
(
strncmp
(
argv
[
i
],
"-psn_"
,
5
)
==
0
)
;
// Usage
else
{
if
(
strcmp
(
argv
[
i
],
"-?"
)
!=
0
)
printf
(
"Unknonwn option %s
\n\n
"
,
argv
[
i
]);
printf
(
"Usage: %s [options]
\n
"
,
argv
[
0
]);
printf
(
"
\n
"
);
printf
(
"Options:
\n
"
);
printf
(
" -b Benchmark (run program for 60 s)
\n
"
);
printf
(
" -s Run program as single thread (default is to use two threads)
\n
"
);
printf
(
" -? Display this text
\n
"
);
printf
(
"
\n
"
);
printf
(
"Program runtime controls:
\n
"
);
printf
(
" w Toggle wireframe mode
\n
"
);
printf
(
" ESC Exit program
\n
"
);
exit
(
EXIT_FAILURE
);
}
}
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment