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

SDL_DROPFILE event does not trigger #3

Open
D1dii opened this issue Oct 29, 2024 · 1 comment
Open

SDL_DROPFILE event does not trigger #3

D1dii opened this issue Oct 29, 2024 · 1 comment

Comments

@D1dii
Copy link

D1dii commented Oct 29, 2024

Hi @pepcots,

Sorry to bother you again, but for some reason my SDL events are not triggering my SDL_DROPFILE event. I don't know why is this happening because this worked a few hours ago and I didnt touch anything related to this (only the code inside the case but this should'nt affect)

Thanks

while (window.processEvents(&gui) && window.isOpen()) {
const auto t0 = hrclock::now();
handleKeyboardInput();
display_func();
gui.render();
window.swapBuffers();
const auto t1 = hrclock::now();
const auto dt = t1 - t0;
if (dt < FRAME_DT) this_thread::sleep_for(FRAME_DT - dt);
while (SDL_PollEvent(&event))
{
gui.processEvent(event);
window.processEvents(&gui);
switch (event.type) {
case SDL_DROPFILE:
dropped_filePath = event.drop.file;
extension = getFileExtension(dropped_filePath);
if (extension == "obj" || extension == "fbx" || extension == "dae") {
mesh->LoadFile(dropped_filePath);
GameObject go;
scene.emplaceChild(go);
}
else if (extension == "png" || extension == "jpg" || extension == "bmp") {
int mouseX, mouseY;
SDL_GetMouseState(&mouseX, &mouseY);
for (auto& child : scene.children()) {
if (isMouseOverGameObject(child, mouseX, mouseY)) {
imageTexture->LoadTexture(dropped_filePath);
child.setTextureImage(imageTexture);
}
}
}
else {
std::cerr << "Unsupported file extension: " << extension << std::endl;
}
SDL_free(dropped_filePath);
//Hasta aquí
break;

@pepcots
Copy link
Member

pepcots commented Oct 29, 2024

This line inside Window class is removing all events from queue.

while (SDL_PollEvent(&e)) {

Have you tried to implement your own IEventProcessor?
BTW: drag and drop is not super important, is just something that make sit easier to test your editor. Don't focus on this if you are not done with the important part: loading and rendering geometry

@pepcots pepcots assigned D1dii and unassigned D1dii Oct 31, 2024
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

No branches or pull requests

2 participants