Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GL issues on macOS 11.7.2 #65

Open
fabjan opened this issue Feb 12, 2023 · 8 comments · May be fixed by #75
Open

GL issues on macOS 11.7.2 #65

fabjan opened this issue Feb 12, 2023 · 8 comments · May be fixed by #75

Comments

@fabjan
Copy link

fabjan commented Feb 12, 2023

Caveats

I don't write many graphical programs. Perhaps macOS is always a pain and you don't want to support it. Given that build.sh contains a uname check for "Darwin" though, I'm giving it a shot.

Problem

I installed the following versions of the dependencies (latest in Homebrew):

  • sdl2 2.26.3
  • freetype 2.13.0
  • glew 2.2.0_1

The build went fine without warnings or errors.

Running the first build:

❯ ./ded
GL version 3.3
ARB_draw_instanced is not supported; game may not work properly!!

I added a YOLO environment variable to skip returning 1 for all those "game may not work properly" checks, to press on and see where I got.

❯ YOLO=1 ./ded
GL version 3.3
ARB_draw_instanced is not supported; game may not work properly!!
WARNING! GLEW_ARB_debug_output is not availableERROR: could not compile GL_FRAGMENT_SHADER
ERROR: 0:6: Use of undeclared identifier 'gl_FragColor'

ERROR: failed to compile `./shaders/simple_color.frag` shader file

Is the program written for a different GL version than what macOS 11.7.2 provides perhaps?

I edited each of the shaders/simple_*.frag programs to stop using gl_FragColor and instead declare out vec4 fragColor; and use that.

Solved?

It looks like everything is working for now, with two changes:

  • make the "game may not work properly" warnings ignorable
  • stop using gl_FragColor for shader output

epic_file_browser

@fabjan
Copy link
Author

fabjan commented Feb 12, 2023

Happy to open a PR unless you prefer some other solution (or none).

@mattthhh
Copy link

ty brooo i was looking how to make it works on macOS <3

maybe u know what are shortcuts to save file and go to the file manager ?

@Swonkie
Copy link

Swonkie commented Feb 16, 2023

I installed the following versions of the dependencies (latest in Homebrew):

* sdl2 2.26.3

* freetype 2.13.0

* glew 2.2.0_1

The build went fine without warnings or errors.

Running the first build:

❯ ./ded
GL version 3.3
ARB_draw_instanced is not supported; game may not work properly!!

Same thing here on macOS 13.1

@Swonkie
Copy link

Swonkie commented Feb 16, 2023

maybe u know what are shortcuts to save file and go to the file manager ?

"The source is the documentation." (or something like that 😉 )
-- tsoding

@mattthhh
Seems to be F2 to save and F3 to open the file browser.

ded/src/main.c

Lines 181 to 350 in 759c476

case SDL_KEYDOWN: {
if (file_browser) {
switch (event.key.keysym.sym) {
case SDLK_F3: {
file_browser = false;
}
break;
case SDLK_UP: {
if (fb.cursor > 0) fb.cursor -= 1;
}
break;
case SDLK_DOWN: {
if (fb.cursor + 1 < fb.files.count) fb.cursor += 1;
}
break;
case SDLK_RETURN: {
const char *file_path = fb_file_path(&fb);
if (file_path) {
File_Type ft;
err = type_of_file(file_path, &ft);
if (err != 0) {
flash_error("Could not determine type of file %s: %s", file_path, strerror(err));
} else {
switch (ft) {
case FT_DIRECTORY: {
err = fb_change_dir(&fb);
if (err != 0) {
flash_error("Could not change directory to %s: %s", file_path, strerror(err));
}
}
break;
case FT_REGULAR: {
// TODO: before opening a new file make sure you don't have unsaved changes
// And if you do, annoy the user about it. (just like all the other editors do)
err = editor_load_from_file(&editor, file_path);
if (err != 0) {
flash_error("Could not open file %s: %s", file_path, strerror(err));
} else {
file_browser = false;
}
}
break;
case FT_OTHER: {
flash_error("%s is neither a regular file nor a directory. We can't open it.", file_path);
}
break;
default:
UNREACHABLE("unknown File_Type");
}
}
}
}
break;
}
} else {
switch (event.key.keysym.sym) {
case SDLK_BACKSPACE: {
editor_backspace(&editor);
editor.last_stroke = SDL_GetTicks();
}
break;
case SDLK_F2: {
if (editor.file_path.count > 0) {
err = editor_save(&editor);
if (err != 0) {
flash_error("Could not save file currently edited file: %s", strerror(err));
}
} else {
// TODO: ask the user for the path to save to in this situation
flash_error("No where to save the text");
}
}
break;
case SDLK_F3: {
file_browser = true;
}
break;
case SDLK_F5: {
simple_renderer_reload_shaders(&sr);
}
break;
case SDLK_RETURN: {
editor_insert_char(&editor, '\n');
editor.last_stroke = SDL_GetTicks();
}
break;
case SDLK_DELETE: {
editor_delete(&editor);
editor.last_stroke = SDL_GetTicks();
}
break;
case SDLK_a: {
if (event.key.keysym.mod & KMOD_CTRL) {
editor.selection = true;
editor.select_begin = 0;
editor.cursor = editor.data.count;
}
}
break;
case SDLK_c: {
if (event.key.keysym.mod & KMOD_CTRL) {
editor_clipboard_copy(&editor);
}
} break;
case SDLK_v: {
if (event.key.keysym.mod & KMOD_CTRL) {
editor_clipboard_paste(&editor);
}
} break;
case SDLK_UP: {
editor_update_selection(&editor, event.key.keysym.mod & KMOD_SHIFT);
editor_move_line_up(&editor);
editor.last_stroke = SDL_GetTicks();
}
break;
case SDLK_DOWN: {
editor_update_selection(&editor, event.key.keysym.mod & KMOD_SHIFT);
editor_move_line_down(&editor);
editor.last_stroke = SDL_GetTicks();
}
break;
case SDLK_LEFT: {
editor_update_selection(&editor, event.key.keysym.mod & KMOD_SHIFT);
editor_move_char_left(&editor);
editor.last_stroke = SDL_GetTicks();
}
break;
case SDLK_RIGHT: {
editor_update_selection(&editor, event.key.keysym.mod & KMOD_SHIFT);
editor_move_char_right(&editor);
editor.last_stroke = SDL_GetTicks();
}
break;
}
}
}
break;
case SDL_TEXTINPUT: {
if (file_browser) {
// TODO: file browser keys
} else {
const char *text = event.text.text;
size_t text_len = strlen(text);
for (size_t i = 0; i < text_len; ++i) {
editor_insert_char(&editor, text[i]);
}
editor.last_stroke = SDL_GetTicks();
}
}
break;
}

@fabjan
Copy link
Author

fabjan commented Feb 17, 2023

dlangui also solved the gl_FragColor by declaring a normal out variable buggins/dlangui@6cfe98a

@fabjan
Copy link
Author

fabjan commented Feb 18, 2023

Ah, the YOLO flag is not longer needed after the instancing check was removed from main.c

@ShazamHax
Copy link

ty brooo i was looking how to make it works on macOS <3

maybe u know what are shortcuts to save file and go to the file manager ?

So it works for you? How exactly did you do it???? I can't seem to decipher what "I edited each of the shader files to stop using gl_color and instead use out vec4 color" means and how to implement the solution. Please help me because this looks like a really cool editor and I would like to use it.

@fabjan
Copy link
Author

fabjan commented Apr 16, 2023

@ShazamHax see e.g. master...fabjan:ded:big-sur-workarounds
(a bit old now, not sure if it's up to date, but you should see a pattern for what is needed to be done about gl_FragColor in that diff).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants