Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
ISC_123 - Travail Pratique 001 - Simulation Système Planétaire
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
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
florian.burgener
ISC_123 - Travail Pratique 001 - Simulation Système Planétaire
Commits
2149b27a
Commit
2149b27a
authored
3 years ago
by
Florian Burgener
Browse files
Options
Downloads
Patches
Plain Diff
Anti-aliasing
parent
db18d756
No related branches found
No related tags found
No related merge requests found
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
.gitignore
+1
-0
1 addition, 0 deletions
.gitignore
Makefile
+10
-3
10 additions, 3 deletions
Makefile
PlanetarySystem.c
+3
-3
3 additions, 3 deletions
PlanetarySystem.c
PlanetarySystem.h
+2
-2
2 additions, 2 deletions
PlanetarySystem.h
Vector2.c
+2
-2
2 additions, 2 deletions
Vector2.c
main.c
+4
-3
4 additions, 3 deletions
main.c
with
22 additions
and
13 deletions
.gitignore
+
1
−
0
View file @
2149b27a
*.o
*.o
main
main
main.exe
.vscode
.vscode
This diff is collapsed.
Click to expand it.
Makefile
+
10
−
3
View file @
2149b27a
TARGET
=
main
TARGET
=
main
CC
:=
gcc
# CCFLAGS
CC
=
gcc
# CFLAGS:=-g -Ofast -Wall -Wextra -fsanitize=address -fsanitize=leak -std=gnu11
# CFLAGS:=-g -Ofast -Wall -Wextra -fsanitize=address -fsanitize=leak -std=gnu11
# CFLAGS:=-fsanitize=address
# CFLAGS:=-fsanitize=address
CFLAGS
:=
-g
-O3
-Wall
-Wextra
-std
=
gnu11
CFLAGS
=
-g
-O3
-Wall
-Wextra
-std
=
gnu11
LDFLAGS
:=
-lm
-lGL
-lGLU
-lglut
LDFLAGS
=
-lm
ifeq
($(OS),Windows_NT)
LDFLAGS
+=
-lopengl32
-lglu32
-lfreeglut
else
LDFLAGS
+=
-lGL
-lGLU
-lglut
endif
%.o
:
%.c $(HEADERS)
%.o
:
%.c $(HEADERS)
$(
CC
)
$(
CFLAGS
)
-c
$<
-o
$@
$(
CC
)
$(
CFLAGS
)
-c
$<
-o
$@
...
...
This diff is collapsed.
Click to expand it.
PlanetarySystem.c
+
3
−
3
View file @
2149b27a
...
@@ -10,8 +10,8 @@
...
@@ -10,8 +10,8 @@
#include
"Vector2.h"
#include
"Vector2.h"
#include
"drawing.h"
#include
"drawing.h"
const
uint32_t
SCREEN_WIDTH
=
10
00
;
const
uint32_t
SCREEN_WIDTH
=
8
00
;
const
uint32_t
SCREEN_HEIGHT
=
10
00
;
const
uint32_t
SCREEN_HEIGHT
=
8
00
;
const
double
G
=
6
.
67430
*
1E-11
;
const
double
G
=
6
.
67430
*
1E-11
;
...
@@ -112,7 +112,7 @@ void planetary_system_update(PlanetarySystem *planetary_system, double interval)
...
@@ -112,7 +112,7 @@ void planetary_system_update(PlanetarySystem *planetary_system, double interval)
int32_t
length
=
object
->
points_length
;
int32_t
length
=
object
->
points_length
;
if
(
length
>
0
&&
vector2_norm
(
vector2_substract
(
object
->
points
[
0
],
object
->
current_position
))
<
1E9
*
1
.
5
)
if
(
length
>
0
&&
vector2_norm
(
vector2_substract
(
object
->
points
[
0
],
object
->
current_position
))
<
1E9
)
continue
;
continue
;
for
(
int32_t
j
=
(
length
==
200
)
?
length
-
1
:
length
;
j
>=
1
;
j
-=
1
)
{
for
(
int32_t
j
=
(
length
==
200
)
?
length
-
1
:
length
;
j
>=
1
;
j
-=
1
)
{
object
->
points
[
j
]
=
object
->
points
[
j
-
1
];
object
->
points
[
j
]
=
object
->
points
[
j
-
1
];
...
...
This diff is collapsed.
Click to expand it.
PlanetarySystem.h
+
2
−
2
View file @
2149b27a
...
@@ -5,8 +5,8 @@
...
@@ -5,8 +5,8 @@
#include
"CelestialObject.h"
#include
"CelestialObject.h"
const
uint32_t
SCREEN_WIDTH
;
extern
const
uint32_t
SCREEN_WIDTH
;
const
uint32_t
SCREEN_HEIGHT
;
extern
const
uint32_t
SCREEN_HEIGHT
;
typedef
struct
PlanetarySystem
{
typedef
struct
PlanetarySystem
{
int32_t
objects_length
;
int32_t
objects_length
;
...
...
This diff is collapsed.
Click to expand it.
Vector2.c
+
2
−
2
View file @
2149b27a
...
@@ -51,8 +51,8 @@ bool vector2_is_similiar(Vector2 a, Vector2 b, double epsilon) {
...
@@ -51,8 +51,8 @@ bool vector2_is_similiar(Vector2 a, Vector2 b, double epsilon) {
}
}
Vector2
vector2_fit_canvas
(
Vector2
v
,
uint32_t
width
,
uint32_t
height
)
{
Vector2
vector2_fit_canvas
(
Vector2
v
,
uint32_t
width
,
uint32_t
height
)
{
double
x
=
round
((
width
-
1
)
/
2
.
0
+
v
.
x
*
(
width
-
1
)
/
2
.
0
);
double
x
=
width
/
2
.
0
*
(
1
+
v
.
x
);
double
y
=
round
((
height
-
1
)
/
2
.
0
+
v
.
y
*
(
height
-
1
)
/
2
.
0
);
double
y
=
height
/
2
.
0
*
(
1
+
v
.
y
);
return
vector2_create
(
x
,
y
);
return
vector2_create
(
x
,
y
);
}
}
...
...
This diff is collapsed.
Click to expand it.
main.c
+
4
−
3
View file @
2149b27a
...
@@ -52,7 +52,7 @@ void draw() {
...
@@ -52,7 +52,7 @@ void draw() {
if
(
elapsed_time
%
REFRESH_RATE
==
0
&&
elapsed_time
!=
0
)
{
if
(
elapsed_time
%
REFRESH_RATE
==
0
&&
elapsed_time
!=
0
)
{
char
title
[
100
];
char
title
[
100
];
sprintf
(
title
,
"Solar System (%d : %ld)"
,
elapsed_time
/
REFRESH_RATE
,
(
time
(
NULL
)
-
true_time_shift
)
%
1000
);
sprintf
(
title
,
"Solar System (%d : %
l
ld)"
,
elapsed_time
/
REFRESH_RATE
,
(
time
(
NULL
)
-
true_time_shift
)
%
1000
);
glutSetWindowTitle
(
title
);
glutSetWindowTitle
(
title
);
}
}
...
@@ -62,7 +62,7 @@ void draw() {
...
@@ -62,7 +62,7 @@ void draw() {
sprintf
(
text
,
"Simulation Speed : %d days per second"
,
time_elasping_per_second
/
86400
);
sprintf
(
text
,
"Simulation Speed : %d days per second"
,
time_elasping_per_second
/
86400
);
draw_text
(
text
,
vector2_create
(
8
,
32
));
draw_text
(
text
,
vector2_create
(
8
,
32
));
gl
Flush
();
gl
utSwapBuffers
();
}
}
void
handle_keyboard_input
(
unsigned
char
key
,
int
UNUSED
(
x
),
int
UNUSED
(
y
))
{
void
handle_keyboard_input
(
unsigned
char
key
,
int
UNUSED
(
x
),
int
UNUSED
(
y
))
{
...
@@ -118,7 +118,8 @@ int main(int argc, char *argv[]) {
...
@@ -118,7 +118,8 @@ int main(int argc, char *argv[]) {
planetary_system
=
planetary_system_create
();
planetary_system
=
planetary_system_create
();
glutInit
(
&
argc
,
argv
);
glutInit
(
&
argc
,
argv
);
glutInitDisplayMode
(
GLUT_SINGLE
|
GLUT_RGB
);
glutSetOption
(
GLUT_MULTISAMPLE
,
16
);
glutInitDisplayMode
(
GLUT_DOUBLE
|
GLUT_RGBA
|
GLUT_DEPTH
|
GLUT_MULTISAMPLE
);
glutInitWindowSize
(
SCREEN_WIDTH
,
SCREEN_HEIGHT
);
glutInitWindowSize
(
SCREEN_WIDTH
,
SCREEN_HEIGHT
);
glutCreateWindow
(
WINDOW_NAME
);
glutCreateWindow
(
WINDOW_NAME
);
...
...
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