Skip to content

Commit

Permalink
getopt
Browse files Browse the repository at this point in the history
  • Loading branch information
yekm committed Jan 13, 2023
1 parent 7161a51 commit 1540ffd
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 11 deletions.
8 changes: 5 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ cmake_minimum_required(VERSION 3.16.3)
project(imgui-cmake LANGUAGES C CXX)


set (CMAKE_CXX_FLAGS_RELEASE "-O3 -march=native")
set (CMAKE_C_FLAGS_RELEASE "-O3 -march=native")
set (CMAKE_CXX_FLAGS_DEBUG "-O0 -ggdb3 -fsanitize=address")
set (CMAKE_CXX_FLAGS_RELEASE ${CMAKE_C_FLAGS_RELEASE})
set (CMAKE_C_FLAGS_DEBUG "-O0 -ggdb3 -fsanitize=address")
set (CMAKE_CXX_FLAGS_DEBUG ${CMAKE_C_FLAGS_DEBUG})

set (CMAKE_VERBOSE_MAKEFILE TRUE)


Expand Down Expand Up @@ -35,10 +36,11 @@ target_include_directories( IMGUI
PUBLIC ${IMGUI_DIR}/backends
)

target_link_libraries(IMGUI PUBLIC ${CMAKE_DL_LIBS})
#target_link_libraries(IMGUI PUBLIC ${CMAKE_DL_LIBS})
#######################################################

find_package(glfw3)

add_subdirectory(colormap)

add_executable(cloudlife)
Expand Down
29 changes: 21 additions & 8 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include "random.h"

#include <math.h> // exp

#include <unistd.h> // getopt
#include <error.h>

#define GL_GLEXT_PROTOTYPES 1
Expand All @@ -27,7 +27,6 @@
#include <GLES2/gl2.h>
#endif
#include <GLFW/glfw3.h> // Will drag system OpenGL headers
//#include <GL/glut.h>

//////////////////////////////////////////////////////////////////////////////

Expand Down Expand Up @@ -323,11 +322,9 @@ draw_field(uint32_t *p)
(short) y *size - ry - 1,
get_color_age(pal, age));
} else {
#if 1
drawdot(p, (short) x *size - rx - 1,
(short) y *size - ry - 1,
bgc);
#endif
}
}
}
Expand Down Expand Up @@ -426,10 +423,24 @@ static void glfw_error_callback(int error, const char* description)
}


int main(int argc, char *argv[])
{
int opt;
int vsync = 1;

while ((opt = getopt(argc, argv, "s")) != -1) {
switch (opt) {
case 's':
vsync = 0;
break;
default: /* '?' */
fprintf(stderr, "Usage: %s [-s]\n",
argv[0]);
exit(EXIT_FAILURE);
}
}


int main(int, char**)
{
glfwSetErrorCallback(glfw_error_callback);
if (!glfwInit())
return 1;
Expand Down Expand Up @@ -461,7 +472,7 @@ int main(int, char**)
if (window == NULL)
return 1;
glfwMakeContextCurrent(window);
glfwSwapInterval(1); // vsync?
glfwSwapInterval(vsync);

make_pbos();
init_field();
Expand Down Expand Up @@ -494,7 +505,9 @@ int main(int, char**)

draw_gui();

ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / ImGui::GetIO().Framerate, ImGui::GetIO().Framerate);
ImGui::Text("Application average %.3f ms/frame (%.1f FPS)",
1000.0f / ImGui::GetIO().Framerate,
ImGui::GetIO().Framerate);

ImGui::End();

Expand Down

0 comments on commit 1540ffd

Please sign in to comment.