Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
ac64b4b
FBX load, texture load & camera
didacpema Oct 30, 2024
79c1b22
drag FBX & PNG, detection bug
didacpema Nov 2, 2024
0899274
handleDropFiles done
didacpema Nov 3, 2024
301020c
Importer
didacpema Nov 3, 2024
86fab57
GameObject & Modular system
didacpema Nov 3, 2024
cbc70aa
CheckerTexture
didacpema Nov 4, 2024
3660ed0
GUI windows
didacpema Nov 4, 2024
e63bd2b
Console GUI
didacpema Nov 4, 2024
3f8df43
movimiento de la camara arreglado
miguelturmo Nov 4, 2024
5dd7e12
nombres en jerarquia
miguelturmo Nov 4, 2024
cdc0a03
Jerarquia & Inspector + ResolutionFix
didacpema Nov 5, 2024
56e23d3
Inspector scale & rotation
didacpema Nov 5, 2024
656efdb
Ventana fix
Adri1714 Nov 6, 2024
b92d53e
camera shift speed
miguelturmo Nov 6, 2024
c32b282
Grid
didacpema Nov 6, 2024
6dcd4d2
Merge branch 'main' of https://github.com/didacpema/Oyuki_Engine
didacpema Nov 6, 2024
1af2e80
fps mostrados
miguelturmo Nov 6, 2024
30cc209
Grid fix
didacpema Nov 6, 2024
a3d27ae
Merge branch 'main' of https://github.com/didacpema/Oyuki_Engine
didacpema Nov 6, 2024
531951a
Dockers(ventanas adaptativas)
Adri1714 Nov 6, 2024
ba219a8
Merge branch 'main' of https://github.com/didacpema/Oyuki_Engine
Adri1714 Nov 6, 2024
893a1a8
memory info
miguelturmo Nov 6, 2024
13bdddf
Merge branch 'main' of https://github.com/didacpema/Oyuki_Engine
miguelturmo Nov 6, 2024
fcb32d8
CheckerTexture Fix
didacpema Nov 6, 2024
61d323c
F para orbitar objeto y JerarquiaFix
didacpema Nov 6, 2024
a6e8195
cubo y esfera añadidos
miguelturmo Nov 6, 2024
219bf8f
UI fixes
didacpema Nov 6, 2024
a54eac1
Windows Colors (dark purple)
Adri1714 Nov 7, 2024
5555abb
pantalla completa
didacpema Nov 8, 2024
ed80e9c
Checker On/Off
Adri1714 Nov 9, 2024
bea04cd
Casita al inicio, texture component fix, & checkerFix
didacpema Nov 9, 2024
afcc7a6
path shape y about
miguelturmo Nov 9, 2024
348ff12
ajustes
miguelturmo Nov 10, 2024
19c22f3
loadFbx fix
didacpema Nov 10, 2024
abf1f20
intento sceneWindow
didacpema Nov 13, 2024
e4691aa
dockingDone & sceneWindow
didacpema Nov 20, 2024
e1b35b7
no esta bien
Adri1714 Nov 20, 2024
44c6c74
import from files
Adri1714 Nov 20, 2024
e8c7390
Different Window files, no va bien ahun
Adri1714 Nov 25, 2024
fa5f504
Config.cpp y .h funcionan!
Adri1714 Nov 27, 2024
9a2952e
Jerarquia, Escena, Inspector windows done
Adri1714 Dec 3, 2024
3b6758e
FileExplorer separeted
Adri1714 Dec 4, 2024
cc59b59
fixMemoryLeaks
didacpema Dec 4, 2024
ed92209
Merge branch 'main' of https://github.com/didacpema/Oyuki_Engine
didacpema Dec 4, 2024
1abae24
DragAndDrop funciona pero raro
Adri1714 Dec 4, 2024
25f4179
drag and checkerTexture
Adri1714 Dec 9, 2024
994f755
arreglito on/Off
Adri1714 Dec 9, 2024
5d5758d
priemra parte
miguelturmo Dec 11, 2024
3d47cea
Revert "priemra parte"
miguelturmo Dec 18, 2024
89cf284
jerarquia parcialmente funcionando
miguelturmo Dec 21, 2024
db9bf00
borrar hijos
miguelturmo Dec 23, 2024
117f751
jerarquia terminada
miguelturmo Dec 24, 2024
a678d36
errase objects from library
miguelturmo Dec 27, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<AdditionalIncludeDirectories>..\..\sdl2_simple_example\sdl2_simple_example\</AdditionalIncludeDirectories>
<LanguageStandard>stdcpp20</LanguageStandard>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
Expand Down
103 changes: 103 additions & 0 deletions sdl2_simple_example/sdl2_simple_example/Config.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
#include "Config.h"


Config::Config(MyWindow* window) : _myWindow(window) {}
Config::~Config() {}

void Config::draw(SDL_Window* _window, Renderer renderer, float fps) {
ImGui::Begin("Config");
ImGui::Text("Configuracion general del sistema");

// Secci�n de resoluci�n de pantalla
ImGui::Text("Resoluci�n de pantalla:");

struct ResolutionItem {
ivec2 resolution;
std::string name;
};

std::vector<ResolutionItem> resolutions = {
{ {800, 600}, "800 x 600" },
{ {1024, 768}, "1024 x 768" },
{ {1280, 720}, "1280 x 720" },
{ {1360, 768}, "1360 x 768" },
{ {1366, 768}, "1366 x 768" },
{ {1440, 900}, "1440 x 900" },
{ {1600, 900}, "1600 x 900" },
{ {1920, 1080}, "1920 x 1080" }
};

static int selectedResolutionIndex = 0;
if (ImGui::Combo("Resolucion", &selectedResolutionIndex, [](void* data, int idx, const char** out_text) {
const std::vector<ResolutionItem>* resolutions = static_cast<const std::vector<ResolutionItem>*>(data);
*out_text = resolutions->at(idx).name.c_str(); // Return resolution name
return true;
}, (void*)&resolutions, resolutions.size())) {
selectedResolution = resolutions[selectedResolutionIndex].resolution;

// Update window size
SDL_SetWindowSize(_window, selectedResolution.x, selectedResolution.y);

// Ensure we apply the new projection and viewport
if (!isFullscreen) {
renderer.applyProjectionAndViewport(selectedResolution); // Aplica la resoluci�n seleccionada
}
}

// Secci�n de pantalla completa
if (ImGui::Checkbox("Pantalla completa", &isFullscreen)) {
if (isFullscreen) {
SDL_SetWindowFullscreen(_window, SDL_WINDOW_FULLSCREEN_DESKTOP);
_myWindow->logMessage("Pantalla completa activada.");
}
else {
SDL_SetWindowFullscreen(_window, 0); // 0 means windowed mode
_myWindow->logMessage("Pantalla completa desactivada.");
}

// Get the current window size dynamically after changing fullscreen mode
int windowWidth, windowHeight;
SDL_GetWindowSize(_window, &windowWidth, &windowHeight);

// Apply the new window size for projection and viewport
renderer.applyProjectionAndViewport(ivec2(windowWidth, windowHeight));
}

ImGui::Text("Grafico FPS");
static float values[90] = {};
static int values_offset = 0;
values[values_offset] = fps; // Ejemplo fijo de FPS
values_offset = (values_offset + 1) % 90;
char fpsText[16];
sprintf_s(fpsText, "%d fps", static_cast<int>(fps));
ImGui::PlotLines("FPS", values, IM_ARRAYSIZE(values), values_offset, fpsText, 0.0f, 100.0f, ImVec2(0, 80));

ImGui::Text("Consumo de Memoria: ");
try {
MemoryInfo memInfo = MemoryUsage::getMemoryInfo();
ImGui::Separator();
ImGui::Text("Consumo de Memoria:");
ImGui::Text("Memoria Total: %llu MB", memInfo.totalMemory);
ImGui::Text("Memoria Libre: %llu MB", memInfo.freeMemory);
ImGui::Text("Memoria Usada: %llu MB", memInfo.usedMemory);
static float totalMemoryValues[90];
static float freeMemoryValues[90];
static float usedMemoryValues[90];
static int memValuesOffset = 0;

totalMemoryValues[memValuesOffset] = memInfo.totalMemory;
freeMemoryValues[memValuesOffset] = memInfo.freeMemory;
usedMemoryValues[memValuesOffset] = memInfo.usedMemory;
memValuesOffset = (values_offset + 1) % 90;

ImGui::PlotLines("TotalMem", totalMemoryValues, IM_ARRAYSIZE(totalMemoryValues), memValuesOffset, "TotalMem", 0.0f, 100.0f, ImVec2(0, 80));
ImGui::PlotLines("freeMem", freeMemoryValues, IM_ARRAYSIZE(freeMemoryValues), memValuesOffset, "FreeMem", 0.0f, 100.0f, ImVec2(0, 80));
ImGui::PlotLines("UsedMem", usedMemoryValues, IM_ARRAYSIZE(usedMemoryValues), memValuesOffset, "UsedMem", 0.0f, 100.0f, ImVec2(0, 80));
}
catch (const std::exception& e) {
ImGui::Text("Error obteniendo memoria: %s", e.what());
}
ImGui::Text("Deteccion de maquinaria i versions de programario:");
ImGui::Text("SDL, OpenGL, DevIL");
ImGui::End();
}
25 changes: 25 additions & 0 deletions sdl2_simple_example/sdl2_simple_example/Config.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#pragma once
#ifndef CONFIG_H
#define CONFIG_H

#include <string>
#include <vector>
#include <imgui.h>
#include "MyWindow.h"
#include "MemoryUsage.h"


class Config {
public:
Config(MyWindow* window);
~Config();

void draw(SDL_Window* _window, Renderer renderer, float fps);
private:
MyWindow* _myWindow;
glm::ivec2 selectedResolution;
bool isFullscreen = false;
};


#endif // CONFIG_H
12 changes: 12 additions & 0 deletions sdl2_simple_example/sdl2_simple_example/Consola.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#include "Consola.h"

Consola::Consola(){}
Consola::~Consola(){}

void Consola::draw(std::vector<std::string> logMessage) {
ImGui::Begin("Consola");
for (const auto& msg : logMessage) {
ImGui::Text("%s", msg.c_str());
}
ImGui::End();
}
19 changes: 19 additions & 0 deletions sdl2_simple_example/sdl2_simple_example/Consola.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#pragma once
#ifndef CONSOLA_H
#define CONSOLA_H

#include <string>
#include <vector>
#include <imgui.h>

class Consola {
public:
Consola();
~Consola();

static void draw(std::vector<std::string> logMessage);
private:

};

#endif // CONSOLA_H
42 changes: 42 additions & 0 deletions sdl2_simple_example/sdl2_simple_example/CustomFormatUtils.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#pragma once
#include <vector>
#include <string>
#include <fstream>

void saveCustomFormat(const std::string& path, const std::vector<float>& vertices, const std::vector<float>& uvs, const std::vector<unsigned int>& indices) {
std::ofstream file(path, std::ios::binary);

size_t vertexCount = vertices.size();
size_t uvCount = uvs.size();
size_t indexCount = indices.size();

file.write(reinterpret_cast<const char*>(&vertexCount), sizeof(size_t));
file.write(reinterpret_cast<const char*>(vertices.data()), vertices.size() * sizeof(float));

file.write(reinterpret_cast<const char*>(&uvCount), sizeof(size_t));
file.write(reinterpret_cast<const char*>(uvs.data()), uvs.size() * sizeof(float));

file.write(reinterpret_cast<const char*>(&indexCount), sizeof(size_t));
file.write(reinterpret_cast<const char*>(indices.data()), indices.size() * sizeof(unsigned int));

file.close();
}

void loadCustomFormat(const std::string& path, std::vector<float>& vertices, std::vector<float>& uvs, std::vector<unsigned int>& indices) {
std::ifstream file(path, std::ios::binary);

size_t vertexCount, uvCount, indexCount;
file.read(reinterpret_cast<char*>(&vertexCount), sizeof(size_t));
vertices.resize(vertexCount);
file.read(reinterpret_cast<char*>(vertices.data()), vertexCount * sizeof(float));

file.read(reinterpret_cast<char*>(&uvCount), sizeof(size_t));
uvs.resize(uvCount);
file.read(reinterpret_cast<char*>(uvs.data()), uvCount * sizeof(float));

file.read(reinterpret_cast<char*>(&indexCount), sizeof(size_t));
indices.resize(indexCount);
file.read(reinterpret_cast<char*>(indices.data()), indexCount * sizeof(unsigned int));

file.close();
}
24 changes: 24 additions & 0 deletions sdl2_simple_example/sdl2_simple_example/Escena.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#include "Escena.h"

extern Renderer renderer;

Escena::Escena(){}
Escena::~Escena(){}

void Escena::draw(GLuint textureColorbuffer) {
ImGui::Begin("Scene");
if (textureColorbuffer) {

ImGui::Image((void*)(intptr_t)textureColorbuffer, ImVec2(renderer._WINDOW_SIZE.x, renderer._WINDOW_SIZE.y));

if (ImGui::BeginDragDropTarget()) {
if (const ImGuiPayload* payload = ImGui::AcceptDragDropPayload("FILE_PATH")) {
const char* filePath = (const char*)payload->Data;

handleFileDrop(filePath); // Procesar archivo arrastrado
}
ImGui::EndDragDropTarget();
}
}
ImGui::End();
}
18 changes: 18 additions & 0 deletions sdl2_simple_example/sdl2_simple_example/Escena.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#pragma once
#ifndef ESCENA_H
#define ESCENA_H

#include <imgui.h>
#include "MyWindow.h"


class Escena {
public:
Escena();
~Escena();
static void draw(GLuint texturecolorbuffer);
private:

};

#endif // ESCENA_H
111 changes: 111 additions & 0 deletions sdl2_simple_example/sdl2_simple_example/FileExplorer.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
#include "FileExplorer.h"

Explorer::Explorer(){}
Explorer::~Explorer(){}


void Explorer::UpdateDirectoryContents() {
try {
directoryContents.clear();

if (fs::exists(currentDirectory) && fs::is_directory(currentDirectory)) {
for (const auto& entry : fs::directory_iterator(currentDirectory)) {
directoryContents.push_back(entry.path().string());
}
// Asegurarnos de que el �ndice seleccionado sea v�lido
if (selectedFileIndex >= directoryContents.size()) {
selectedFileIndex = -1;
}
}
}
catch (const fs::filesystem_error& e) {
std::cerr << "Error listing directory: " << e.what() << std::endl;
selectedFileIndex = -1;
}
}
void Explorer::deleteSelectedFile() {
if (selectedFileIndex < 0 || selectedFileIndex >= directoryContents.size()) {
return;
}

try {
std::string filePath = directoryContents[selectedFileIndex];
if (!fs::is_directory(filePath) && fs::exists(filePath)) {
if (fs::remove(filePath)) {
selectedFileIndex = -1;
UpdateDirectoryContents();
}
}
}
catch (const fs::filesystem_error& e) {
std::cerr << "Error deleting file: " << e.what() << std::endl;
}
}
void Explorer::draw() {
ImGui::Begin("File Explorer");

// Mostrar directorio actual
ImGui::Text("Current Directory: %s", currentDirectory.c_str());

// Bot�n para subir un nivel
if (ImGui::Button(".. (Go Up)")) {
try {
fs::path parent = fs::path(currentDirectory).parent_path();
if (fs::exists(parent)) {
currentDirectory = parent.string();
selectedFileIndex = -1; // Reset selection when changing directory
UpdateDirectoryContents();
}
}
catch (const fs::filesystem_error& e) {
std::cerr << "Error accessing parent directory: " << e.what() << std::endl;
}
}

// Lista de archivos y directorios
ImGui::BeginChild("Files", ImVec2(0, -30), true);
for (size_t i = 0; i < directoryContents.size(); ++i) {
try {
fs::path entry(directoryContents[i]);
if (!fs::exists(entry)) continue; // Skip if file no longer exists

std::string displayName = FileSystemUtils::getFileName(entry.string());
bool isSelected = (i == selectedFileIndex);

if (fs::is_directory(entry)) {
// Directorios como botones
if (ImGui::Button(displayName.c_str())) {
currentDirectory = entry.string();
selectedFileIndex = -1;
UpdateDirectoryContents();
}
}
else {
// Archivos como seleccionables
if (ImGui::Selectable(displayName.c_str(), isSelected)) {
selectedFileIndex = i;
}

// Drag & Drop solo para archivos
if (ImGui::BeginDragDropSource(ImGuiDragDropFlags_None)) {
const char* filePath = entry.string().c_str();
ImGui::SetDragDropPayload("FILE_PATH", filePath, strlen(filePath) + 1);
ImGui::Text("Dragging: %s", displayName.c_str());
ImGui::EndDragDropSource();
}
}
}
catch (const fs::filesystem_error& e) {
std::cerr << "Error processing file: " << e.what() << std::endl;
}
}
ImGui::EndChild();

// Manejar borrado con tecla Delete
if (ImGui::IsKeyPressed(ImGuiKey_Delete) && selectedFileIndex >= 0) {
deleteSelectedFile();
}

ImGui::End();
}

Loading