2nd ui colors
This commit is contained in:
51
src/main.c
51
src/main.c
@@ -30,6 +30,9 @@
|
|||||||
float *generate_data_surface(unsigned int, unsigned char *);
|
float *generate_data_surface(unsigned int, unsigned char *);
|
||||||
float *generate_normals_surface(float *, unsigned char);
|
float *generate_normals_surface(float *, unsigned char);
|
||||||
|
|
||||||
|
float graph_color[3] = {1.0f, 1.0f, 1.0f}; // Inicialización al blanco
|
||||||
|
|
||||||
|
|
||||||
const char *wname = "manigraph: manifold grapher";
|
const char *wname = "manigraph: manifold grapher";
|
||||||
|
|
||||||
struct projection projection = {.x = 0, .y = 1, .z = 2, .w = 3};
|
struct projection projection = {.x = 0, .y = 1, .z = 2, .w = 3};
|
||||||
@@ -142,6 +145,10 @@ int main(void)
|
|||||||
nk_glfw3_font_stash_end(&glfw);
|
nk_glfw3_font_stash_end(&glfw);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Variable para el color */
|
||||||
|
static struct nk_colorf picked_color = {1.0f, 1.0f, 1.0f, 1.0f}; // Blanco en formato flotante
|
||||||
|
|
||||||
|
|
||||||
mlog("[MAIN LOOP] Inicializando...\n");
|
mlog("[MAIN LOOP] Inicializando...\n");
|
||||||
while (is_open_window(window))
|
while (is_open_window(window))
|
||||||
{
|
{
|
||||||
@@ -166,28 +173,31 @@ int main(void)
|
|||||||
#endif
|
#endif
|
||||||
draw_mesh(m_surface);
|
draw_mesh(m_surface);
|
||||||
|
|
||||||
/* Drawind nuklear */
|
/* Dibujando interfaz gráfica */
|
||||||
{
|
{
|
||||||
nk_glfw3_new_frame(&glfw);
|
nk_glfw3_new_frame(&glfw);
|
||||||
|
|
||||||
if (nk_begin(context, "Nuklear Window", nk_rect(0, 0, 500, 500),
|
if (nk_begin(context, "Nuklear Window", nk_rect(0, 0, 500, 500),
|
||||||
NK_WINDOW_BORDER | NK_WINDOW_TITLE | NK_WINDOW_MINIMIZABLE | NK_WINDOW_MOVABLE | NK_WINDOW_SCALABLE)) {
|
NK_WINDOW_BORDER | NK_WINDOW_TITLE | NK_WINDOW_MINIMIZABLE | NK_WINDOW_MOVABLE | NK_WINDOW_SCALABLE)) {
|
||||||
// Añadir texto
|
|
||||||
nk_layout_row_static(context, 30, 200, 1); // Configuración de fila (altura: 30, ancho: 200, elementos: 1)
|
// Color Picker
|
||||||
nk_label(context, "MANIGRAPH", NK_TEXT_ALIGN_LEFT);
|
nk_layout_row_dynamic(context, 120, 1); // Crear espacio para el selector de color
|
||||||
|
picked_color = nk_color_picker(context, picked_color, NK_RGBA);
|
||||||
|
|
||||||
// Añadir botón
|
// Aplicar el color seleccionado al gráfico
|
||||||
nk_layout_row_static(context, 30, 200, 1); // Configuración de fila
|
graph_color[0] = picked_color.r; // Rojo
|
||||||
if (nk_button_label(context, "Presióname")) {
|
graph_color[1] = picked_color.g; // Verde
|
||||||
// Acción cuando el botón es presionado
|
graph_color[2] = picked_color.b; // Azul
|
||||||
printf("¡Botón presionado!\n");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
nk_end(context);
|
glUseProgram(shader);
|
||||||
nk_glfw3_render(&glfw, NK_ANTI_ALIASING_ON, MAX_VERTEX_BUFFER, MAX_ELEMENT_BUFFER);
|
glUniform3fv(glGetUniformLocation(shader, "uColor"), 1, graph_color);
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
nk_end(context);
|
||||||
|
nk_glfw3_render(&glfw, NK_ANTI_ALIASING_ON, MAX_VERTEX_BUFFER, MAX_ELEMENT_BUFFER);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
mlog("[MAIN LOOP] Terminando...\n");
|
mlog("[MAIN LOOP] Terminando...\n");
|
||||||
|
|
||||||
@@ -205,22 +215,15 @@ int main(void)
|
|||||||
close_window(window);
|
close_window(window);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
mlog("[MESH] Destruyendo...\n");
|
|
||||||
destroy_mesh(m_axis);
|
|
||||||
error_mesh_axis:
|
error_mesh_axis:
|
||||||
mlog("[MESH] Destruyendo...\n");
|
|
||||||
destroy_mesh(m_surface);
|
destroy_mesh(m_surface);
|
||||||
error_mesh_surface:
|
error_mesh_surface:
|
||||||
mlog("[SHADER] Destruyendo...\n");
|
|
||||||
destroy_shader(shader_plain);
|
destroy_shader(shader_plain);
|
||||||
error_shader_plain:
|
error_shader_plain:
|
||||||
mlog("[SHADER] Destruyendo...\n");
|
|
||||||
destroy_shader(shader);
|
destroy_shader(shader);
|
||||||
error_shader:
|
error_shader:
|
||||||
mlog("[TEXTURE] Destruyendo...\n");
|
|
||||||
destroy_texture(texture);
|
destroy_texture(texture);
|
||||||
error_context:
|
error_context:
|
||||||
mlog("[WINDOW] Destruyendo...\n");
|
|
||||||
close_window(window);
|
close_window(window);
|
||||||
error_window:
|
error_window:
|
||||||
return 1;
|
return 1;
|
||||||
|
|||||||
Reference in New Issue
Block a user