-
Notifications
You must be signed in to change notification settings - Fork 1.1k
error in sdl native #837
base: master
Are you sure you want to change the base?
error in sdl native #837
Conversation
I still get this same error
|
When I would change background i get secmentation 11 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your effort - I'm glad we'll finally have a "pure" SDL backend in the repo. Just to maintain the absolute minimal code quality, please take a look at the comments.
One more question - why did you add a submodule (Submodule nuklear added at 576ab0
) in this pull? There shouldn't be any need for that.
demo/sdl_native/nuklear_sdl.h
Outdated
sdl.ttf_font = TTF_OpenFont(file_name, font_size); | ||
if (sdl.ttf_font == NULL) { | ||
fprintf(stdout, "Unable to load font file: %s\n", file_name); | ||
return NULL; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return NULL;
-> return;
as it's a void
function
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm glad we'll finally have a "pure" SDL backend in the repo.
In main repo noexist SDL2 native
Your code working? Please change the background color in demo program
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure whether I understand you correctly. Which background color on which line in the source code in which demo program and why?
TTF_Font *ttf_font; | ||
struct nk_user_font *user_font; | ||
int font_height; | ||
} sdl; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd like to merge this commit, but because we prefer thread safe code, we should avoid global variables. Do you want to change the APIs to accept struct nk_sdl
as argument? If not, I might accept it with global variable to have at least something in the repo.
demo/sdl_native/nuklear_sdl.h
Outdated
as nuklear uses variable size buffers and al_get_text_width doesn't | ||
accept a length, it infers length from null-termination | ||
(which is unsafe API design by allegro devs!) */ | ||
char strcpy[len+1]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please don't use variable names conflicting with C standard library names (see man strcpy
).
demo/sdl_native/nuklear_sdl.h
Outdated
nk_input_key(ctx, NK_KEY_TEXT_WORD_RIGHT, down); | ||
else nk_input_key(ctx, NK_KEY_RIGHT, down); | ||
} else return 0; | ||
return 1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the purpose of this return? Or alternatively the purpose of the return on the previous line?
cc main.c -std=c99 -pedantic -O2 -o main -lSDL2 -lm
In file included from main.c:22:
./nuklear_sdl.h:63:9: error: void function 'nk_sdl_font_create_from_file' should not return a value [-Wreturn-type]
return NULL;
^ ~~~~
./nuklear_sdl.h:198:35: warning: incompatible pointer types passing 'const float *' to parameter of type 'const Sint16 *'
(aka 'const short ') [-Wincompatible-pointer-types]
sdl_draw_polyline((const float)&vertices, (2 * sizeof(float)),(int)p->point_count, p->color);
^~~~~~~~~~~~~~~~~~~~~~~
./nuklear_sdl.h:124:38: note: passing argument to parameter 'vx' here
void sdl_draw_polyline(const Sint16 *vx, const Sint16 *vy, int n, struct nk_color color) {
^
./nuklear_sdl.h:198:60: warning: incompatible integer to pointer conversion passing 'unsigned long' to parameter of type 'const Sint16 *'
(aka 'const short ') [-Wint-conversion]
sdl_draw_polyline((const float)&vertices, (2 * sizeof(float)),(int)p->point_count, p->color);
^~~~~~~~~~~~~~~~~~~
./nuklear_sdl.h:124:56: note: passing argument to parameter 'vy' here
void sdl_draw_polyline(const Sint16 *vx, const Sint16 *vy, int n, struct nk_color color) {
^
./nuklear_sdl.h:209:41: warning: incompatible pointer types passing 'const float *' to parameter of type 'const Sint16 '
(aka 'const short ') [-Wincompatible-pointer-types]
sdl_draw_filled_polygon((const float)&verticesx, (const float)&verticesy,
^~~~~~~~~~~~~~~~~~~~~~~~
./nuklear_sdl.h:132:44: note: passing argument to parameter 'vx' here
void sdl_draw_filled_polygon(const Sint16 *vx, const Sint16 *vy, int n, struct nk_color color) {
^
./nuklear_sdl.h:209:67: warning: incompatible pointer types passing 'const float *' to parameter of type 'const Sint16 '
(aka 'const short ') [-Wincompatible-pointer-types]
sdl_draw_filled_polygon((const float)&verticesx, (const float)&verticesy,
^~~~~~~~~~~~~~~~~~~~~~~~
./nuklear_sdl.h:132:62: note: passing argument to parameter 'vy' here
void sdl_draw_filled_polygon(const Sint16 *vx, const Sint16 *vy, int n, struct nk_color color) {
^
./nuklear_sdl.h:226:32: warning: passing 'const struct nk_image *' to parameter of type 'struct nk_image *' discards qualifiers
[-Wincompatible-pointer-types-discards-qualifiers]
sdl_draw_image(&i->img, i->x, i->y, i->w, i->h);
^~~~~~~
./nuklear_sdl.h:136:38: note: passing argument to parameter 'img' here
void sdl_draw_image(struct nk_image *img, int x, int y, int w, int h) {
^
./nuklear_sdl.h:280:26: warning: incompatible pointer types initializing 'struct nk_user_font *' with an expression of type
'struct nk_user_font **'; remove & [-Wincompatible-pointer-types]
struct nk_user_font *font = &sdl.user_font;
^ ~~~~~~~~~~~~~~
6 warnings and 1 error generated.
make: *** [main] Error 1