Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
mandelbrot-explorer
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Ильин Владимир Александрович
mandelbrot-explorer
Commits
c297970b
Commit
c297970b
authored
Feb 17, 2025
by
Ильин Владимир Александрович
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
segfault fixed
parent
ec1169ab
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
24 additions
and
24 deletions
+24
-24
Makefile
Makefile
+4
-5
mouse.o
build/mouse.o
+0
-0
ui.o
build/ui.o
+0
-0
gmon.out
gmon.out
+0
-0
mandelbrot
mandelbrot
+0
-0
mandelbrot.c
src/mandelbrot.c
+19
-18
mouse.c
src/mouse.c
+1
-1
No files found.
Makefile
View file @
c297970b
CFLAGS
=
-Wno-unused-command-line-argument
-Wno-missing-field-initializers
-Wall
-Wextra
-Wpedantic
-lm
-fopenmp
DEBUG_CFLAGS
=
-g
-DDEBUG
DEBUG_CFLAGS
=
-g
-DDEBUG
-pg
-O0
LDLIBS
=
$(
shell
pkg-config
--libs
sdl2 SDL2_ttf
)
CFLAGS
:=
$(CFLAGS)
-O3
CFLAGS
:=
$(CFLAGS)
-pg
#CFLAGS := $(CFLAGS) -O3
CFLAGS
:=
$(CFLAGS)
$(DEBUG_CFLAGS)
SRCDIR
=
src
BIULDDIR
=
build
# compiler
CC
=
gcc
#
CC = clang
#
CC = gcc
CC
=
clang
OBJS
=
$(BIULDDIR)
/mouse.o
$(BIULDDIR)
/ui.o
...
...
build/mouse.o
View file @
c297970b
No preview for this file type
build/ui.o
View file @
c297970b
No preview for this file type
gmon.out
View file @
c297970b
No preview for this file type
mandelbrot
View file @
c297970b
No preview for this file type
src/mandelbrot.c
View file @
c297970b
...
...
@@ -44,6 +44,7 @@ typedef struct {
void
calculate_set
(
Array
*
arr
,
int
height
,
int
width
,
ViewInfo
view
)
{
//printf("arr size: %d, screen %d\n", arr->size, height * width);
for
(
int
x
=
0
;
x
<
width
;
x
++
)
{
for
(
int
y
=
0
;
y
<
height
;
y
++
)
{
double
real
=
view
.
x_min
+
(
x
*
(
view
.
x_max
-
view
.
x_min
))
/
width
;
...
...
@@ -53,16 +54,15 @@ calculate_set(Array *arr, int height, int width, ViewInfo view)
int
iterations
=
mandelbrot
(
c
);
if
(
iterations
==
MAX_ITERATIONS
){
arr
->
pointer
[
x
*
width
+
y
].
r
=
0
;
arr
->
pointer
[
x
*
width
+
y
].
g
=
0
;
arr
->
pointer
[
x
*
width
+
y
].
b
=
0
;
arr
->
pointer
[
x
*
height
+
y
].
r
=
0
;
arr
->
pointer
[
x
*
height
+
y
].
g
=
0
;
arr
->
pointer
[
x
*
height
+
y
].
b
=
0
;
}
else
{
double
t
=
(
double
)
iterations
/
MAX_ITERATIONS
;
t
=
0
.
5
+
0
.
5
*
cos
(
log
(
t
+
0
.
0001
)
*
3
.
0
);
arr
->
pointer
[
x
*
width
+
y
].
r
=
255
*
t
;
arr
->
pointer
[
x
*
width
+
y
].
g
=
255
*
t
*
0
.
4
;
arr
->
pointer
[
x
*
width
+
y
].
b
=
255
*
t
*
0
.
2
;
arr
->
pointer
[
x
*
height
+
y
].
r
=
255
*
t
;
arr
->
pointer
[
x
*
height
+
y
].
g
=
255
*
t
*
0
.
4
;
arr
->
pointer
[
x
*
height
+
y
].
b
=
255
*
t
*
0
.
2
;
}
}
}
...
...
@@ -74,18 +74,18 @@ render_cl(Array *arr, App *app, ViewInfo view, int start_x, int start_y) {
SDL_SetRenderDrawColor
(
app
->
renderer
,
0
,
0
,
50
,
255
);
SDL_RenderClear
(
app
->
renderer
);
if
(
arr
->
size
<
app
->
win_height
*
app
->
win_width
){
if
(
arr
->
size
<
app
->
win_height
*
app
->
win_width
*
sizeof
(
Color
)
){
arr
->
pointer
=
realloc
(
arr
->
pointer
,
app
->
win_height
*
app
->
win_width
*
sizeof
(
Color
));
arr
->
size
=
app
->
win_height
*
app
->
win_width
;
arr
->
size
=
app
->
win_height
*
app
->
win_width
*
sizeof
(
Color
)
;
}
calculate_set
(
arr
,
app
->
win_height
,
app
->
win_width
,
view
);
for
(
int
x
=
0
;
x
<
app
->
win_width
;
x
++
)
{
for
(
int
y
=
0
;
y
<
app
->
win_height
;
y
++
)
{
SDL_SetRenderDrawColor
(
app
->
renderer
,
arr
->
pointer
[
x
*
app
->
win_
width
+
y
].
r
,
arr
->
pointer
[
x
*
app
->
win_
width
+
y
].
g
,
arr
->
pointer
[
x
*
app
->
win_
width
+
y
].
b
,
arr
->
pointer
[
x
*
app
->
win_
height
+
y
].
r
,
arr
->
pointer
[
x
*
app
->
win_
height
+
y
].
g
,
arr
->
pointer
[
x
*
app
->
win_
height
+
y
].
b
,
255
);
SDL_RenderDrawPoint
(
app
->
renderer
,
x
,
y
);
}
...
...
@@ -170,7 +170,7 @@ main(int argc, char *argv[])
Array
screen
=
{
malloc
(
app
.
win_height
*
app
.
win_width
*
sizeof
(
Color
)),
app
.
win_height
*
app
.
win_width
app
.
win_height
*
app
.
win_width
*
sizeof
(
Color
)
};
...
...
@@ -189,7 +189,7 @@ main(int argc, char *argv[])
case
SDL_WINDOWEVENT
:
if
(
event
.
window
.
event
==
SDL_WINDOWEVENT_RESIZED
){
SDL_GetWindowSize
(
app
.
window
,
&
app
.
win_width
,
&
app
.
win_height
);
}
}
break
;
case
SDL_KEYDOWN
:
switch
(
event
.
key
.
keysym
.
scancode
)
...
...
@@ -225,12 +225,12 @@ main(int argc, char *argv[])
break
;
}
}
SDL_SetRenderDrawColor
(
app
.
renderer
,
0xff
,
0xff
,
0xff
,
0xff
);
SDL_RenderClear
(
app
.
renderer
);
//drawing happens here
SDL_SetRenderDrawColor
(
app
.
renderer
,
0xff
,
0xff
,
0xff
,
0xff
);
SDL_RenderClear
(
app
.
renderer
);
render_cl
(
&
screen
,
&
app
,
view
,
0
,
0
);
// render(&app,
// view,
// 0, app.win_width,
...
...
@@ -244,9 +244,10 @@ main(int argc, char *argv[])
render_ui
(
&
ui
,
app
.
renderer
,
view
,
fps
);
SDL_RenderPresent
(
app
.
renderer
);
}
//SDL_FreeSurface(app.surfaceA);
free
(
screen
.
pointer
);
SDL_DestroyRenderer
(
app
.
renderer
);
SDL_DestroyWindow
(
app
.
window
);
SDL_Quit
();
...
...
src/mouse.c
View file @
c297970b
#include "mandelbrot.h"
void
void
handle_mouse
(
SDL_Event
event
,
Mouse
*
mouse
,
ViewInfo
*
view
)
{
switch
(
event
.
type
)
{
case
SDL_MOUSEBUTTONDOWN
:
...
...
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