Simulator now uses ImGui for stuff
This commit is contained in:
parent
1be998153a
commit
0871b2582d
9 changed files with 8101 additions and 53 deletions
3
.gitmodules
vendored
Normal file
3
.gitmodules
vendored
Normal file
|
@ -0,0 +1,3 @@
|
|||
[submodule "simulation/imgui"]
|
||||
path = simulation/imgui
|
||||
url = https://github.com/ocornut/imgui.git
|
|
@ -10,7 +10,7 @@ LIBS=-framework SDL2 -lc++ -lc -framework OpenGL
|
|||
LDFLAGS=-macosx_version_min 10.9
|
||||
|
||||
SYSINC = ~/Documents/Arduino/libraries/Filters ./include
|
||||
INCS = ../NuEVI ./include
|
||||
INCS = ../NuEVI ./include ./imgui ./gl3w
|
||||
|
||||
INCDIRS = $(addprefix -isystem ,$(SYSINC))
|
||||
INCDIRS += $(addprefix -I,$(INCS))
|
||||
|
@ -28,7 +28,14 @@ CXXFILES= ../NuEVI/menu.cpp \
|
|||
src/filters.cpp \
|
||||
src/Adafruit_GFX_sim.cpp \
|
||||
src/Adafruit_SSD1306_sim.cpp \
|
||||
src/Adafruit_MPR121_sim.cpp
|
||||
src/Adafruit_MPR121_sim.cpp \
|
||||
imgui/imgui.cpp \
|
||||
imgui/imgui_draw.cpp \
|
||||
imgui/imgui_widgets.cpp \
|
||||
imgui/examples/imgui_impl_sdl.cpp \
|
||||
imgui/examples/imgui_impl_opengl3.cpp
|
||||
|
||||
CFILES= gl3w/gl3w.c
|
||||
|
||||
OBJS=$(CXXFILES:.cpp=.o) $(CFILES:.c=.o)
|
||||
|
||||
|
|
1387
simulation/gl3w/GL/gl3w.h
Normal file
1387
simulation/gl3w/GL/gl3w.h
Normal file
File diff suppressed because it is too large
Load diff
5703
simulation/gl3w/GL/glcorearb.h
Normal file
5703
simulation/gl3w/GL/glcorearb.h
Normal file
File diff suppressed because it is too large
Load diff
841
simulation/gl3w/gl3w.c
Normal file
841
simulation/gl3w/gl3w.c
Normal file
|
@ -0,0 +1,841 @@
|
|||
/*
|
||||
|
||||
This file was generated with gl3w_gen.py, part of gl3w
|
||||
(hosted at https://github.com/skaslev/gl3w)
|
||||
|
||||
This is free and unencumbered software released into the public domain.
|
||||
|
||||
Anyone is free to copy, modify, publish, use, compile, sell, or
|
||||
distribute this software, either in source code form or as a compiled
|
||||
binary, for any purpose, commercial or non-commercial, and by any
|
||||
means.
|
||||
|
||||
In jurisdictions that recognize copyright laws, the author or authors
|
||||
of this software dedicate any and all copyright interest in the
|
||||
software to the public domain. We make this dedication for the benefit
|
||||
of the public at large and to the detriment of our heirs and
|
||||
successors. We intend this dedication to be an overt act of
|
||||
relinquishment in perpetuity of all present and future rights to this
|
||||
software under copyright law.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
||||
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
*/
|
||||
|
||||
#include <GL/gl3w.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
|
||||
|
||||
#if defined(_WIN32)
|
||||
#define WIN32_LEAN_AND_MEAN 1
|
||||
#include <windows.h>
|
||||
|
||||
static HMODULE libgl;
|
||||
static PROC (__stdcall *wgl_get_proc_address)(LPCSTR);
|
||||
|
||||
static int open_libgl(void)
|
||||
{
|
||||
libgl = LoadLibraryA("opengl32.dll");
|
||||
if (!libgl)
|
||||
return GL3W_ERROR_LIBRARY_OPEN;
|
||||
|
||||
*(void **)(&wgl_get_proc_address) = GetProcAddress(libgl, "wglGetProcAddress");
|
||||
return GL3W_OK;
|
||||
}
|
||||
|
||||
static void close_libgl(void)
|
||||
{
|
||||
FreeLibrary(libgl);
|
||||
}
|
||||
|
||||
static GL3WglProc get_proc(const char *proc)
|
||||
{
|
||||
GL3WglProc res;
|
||||
|
||||
res = (GL3WglProc)wgl_get_proc_address(proc);
|
||||
if (!res)
|
||||
res = (GL3WglProc)GetProcAddress(libgl, proc);
|
||||
return res;
|
||||
}
|
||||
#elif defined(__APPLE__)
|
||||
#include <dlfcn.h>
|
||||
|
||||
static void *libgl;
|
||||
|
||||
static int open_libgl(void)
|
||||
{
|
||||
libgl = dlopen("/System/Library/Frameworks/OpenGL.framework/OpenGL", RTLD_LAZY | RTLD_LOCAL);
|
||||
if (!libgl)
|
||||
return GL3W_ERROR_LIBRARY_OPEN;
|
||||
|
||||
return GL3W_OK;
|
||||
}
|
||||
|
||||
static void close_libgl(void)
|
||||
{
|
||||
dlclose(libgl);
|
||||
}
|
||||
|
||||
static GL3WglProc get_proc(const char *proc)
|
||||
{
|
||||
GL3WglProc res;
|
||||
|
||||
*(void **)(&res) = dlsym(libgl, proc);
|
||||
return res;
|
||||
}
|
||||
#else
|
||||
#include <dlfcn.h>
|
||||
|
||||
static void *libgl;
|
||||
static GL3WglProc (*glx_get_proc_address)(const GLubyte *);
|
||||
|
||||
static int open_libgl(void)
|
||||
{
|
||||
libgl = dlopen("libGL.so.1", RTLD_LAZY | RTLD_LOCAL);
|
||||
if (!libgl)
|
||||
return GL3W_ERROR_LIBRARY_OPEN;
|
||||
|
||||
*(void **)(&glx_get_proc_address) = dlsym(libgl, "glXGetProcAddressARB");
|
||||
return GL3W_OK;
|
||||
}
|
||||
|
||||
static void close_libgl(void)
|
||||
{
|
||||
dlclose(libgl);
|
||||
}
|
||||
|
||||
static GL3WglProc get_proc(const char *proc)
|
||||
{
|
||||
GL3WglProc res;
|
||||
|
||||
res = glx_get_proc_address((const GLubyte *)proc);
|
||||
if (!res)
|
||||
*(void **)(&res) = dlsym(libgl, proc);
|
||||
return res;
|
||||
}
|
||||
#endif
|
||||
|
||||
static struct {
|
||||
int major, minor;
|
||||
} version;
|
||||
|
||||
static int parse_version(void)
|
||||
{
|
||||
if (!glGetIntegerv)
|
||||
return GL3W_ERROR_INIT;
|
||||
|
||||
glGetIntegerv(GL_MAJOR_VERSION, &version.major);
|
||||
glGetIntegerv(GL_MINOR_VERSION, &version.minor);
|
||||
|
||||
if (version.major < 3)
|
||||
return GL3W_ERROR_OPENGL_VERSION;
|
||||
return GL3W_OK;
|
||||
}
|
||||
|
||||
static void load_procs(GL3WGetProcAddressProc proc);
|
||||
|
||||
int gl3wInit(void)
|
||||
{
|
||||
return gl3wInit2(get_proc);
|
||||
}
|
||||
|
||||
int gl3wInit2(GL3WGetProcAddressProc proc)
|
||||
{
|
||||
int res = open_libgl();
|
||||
if (res)
|
||||
return res;
|
||||
|
||||
atexit(close_libgl);
|
||||
load_procs(proc);
|
||||
return parse_version();
|
||||
}
|
||||
|
||||
int gl3wIsSupported(int major, int minor)
|
||||
{
|
||||
if (major < 3)
|
||||
return 0;
|
||||
if (version.major == major)
|
||||
return version.minor >= minor;
|
||||
return version.major >= major;
|
||||
}
|
||||
|
||||
GL3WglProc gl3wGetProcAddress(const char *proc)
|
||||
{
|
||||
return get_proc(proc);
|
||||
}
|
||||
|
||||
static const char *proc_names[] = {
|
||||
"glActiveShaderProgram",
|
||||
"glActiveTexture",
|
||||
"glAttachShader",
|
||||
"glBeginConditionalRender",
|
||||
"glBeginQuery",
|
||||
"glBeginQueryIndexed",
|
||||
"glBeginTransformFeedback",
|
||||
"glBindAttribLocation",
|
||||
"glBindBuffer",
|
||||
"glBindBufferBase",
|
||||
"glBindBufferRange",
|
||||
"glBindBuffersBase",
|
||||
"glBindBuffersRange",
|
||||
"glBindFragDataLocation",
|
||||
"glBindFragDataLocationIndexed",
|
||||
"glBindFramebuffer",
|
||||
"glBindImageTexture",
|
||||
"glBindImageTextures",
|
||||
"glBindProgramPipeline",
|
||||
"glBindRenderbuffer",
|
||||
"glBindSampler",
|
||||
"glBindSamplers",
|
||||
"glBindTexture",
|
||||
"glBindTextureUnit",
|
||||
"glBindTextures",
|
||||
"glBindTransformFeedback",
|
||||
"glBindVertexArray",
|
||||
"glBindVertexBuffer",
|
||||
"glBindVertexBuffers",
|
||||
"glBlendColor",
|
||||
"glBlendEquation",
|
||||
"glBlendEquationSeparate",
|
||||
"glBlendEquationSeparatei",
|
||||
"glBlendEquationi",
|
||||
"glBlendFunc",
|
||||
"glBlendFuncSeparate",
|
||||
"glBlendFuncSeparatei",
|
||||
"glBlendFunci",
|
||||
"glBlitFramebuffer",
|
||||
"glBlitNamedFramebuffer",
|
||||
"glBufferData",
|
||||
"glBufferStorage",
|
||||
"glBufferSubData",
|
||||
"glCheckFramebufferStatus",
|
||||
"glCheckNamedFramebufferStatus",
|
||||
"glClampColor",
|
||||
"glClear",
|
||||
"glClearBufferData",
|
||||
"glClearBufferSubData",
|
||||
"glClearBufferfi",
|
||||
"glClearBufferfv",
|
||||
"glClearBufferiv",
|
||||
"glClearBufferuiv",
|
||||
"glClearColor",
|
||||
"glClearDepth",
|
||||
"glClearDepthf",
|
||||
"glClearNamedBufferData",
|
||||
"glClearNamedBufferSubData",
|
||||
"glClearNamedFramebufferfi",
|
||||
"glClearNamedFramebufferfv",
|
||||
"glClearNamedFramebufferiv",
|
||||
"glClearNamedFramebufferuiv",
|
||||
"glClearStencil",
|
||||
"glClearTexImage",
|
||||
"glClearTexSubImage",
|
||||
"glClientWaitSync",
|
||||
"glClipControl",
|
||||
"glColorMask",
|
||||
"glColorMaski",
|
||||
"glCompileShader",
|
||||
"glCompressedTexImage1D",
|
||||
"glCompressedTexImage2D",
|
||||
"glCompressedTexImage3D",
|
||||
"glCompressedTexSubImage1D",
|
||||
"glCompressedTexSubImage2D",
|
||||
"glCompressedTexSubImage3D",
|
||||
"glCompressedTextureSubImage1D",
|
||||
"glCompressedTextureSubImage2D",
|
||||
"glCompressedTextureSubImage3D",
|
||||
"glCopyBufferSubData",
|
||||
"glCopyImageSubData",
|
||||
"glCopyNamedBufferSubData",
|
||||
"glCopyTexImage1D",
|
||||
"glCopyTexImage2D",
|
||||
"glCopyTexSubImage1D",
|
||||
"glCopyTexSubImage2D",
|
||||
"glCopyTexSubImage3D",
|
||||
"glCopyTextureSubImage1D",
|
||||
"glCopyTextureSubImage2D",
|
||||
"glCopyTextureSubImage3D",
|
||||
"glCreateBuffers",
|
||||
"glCreateFramebuffers",
|
||||
"glCreateProgram",
|
||||
"glCreateProgramPipelines",
|
||||
"glCreateQueries",
|
||||
"glCreateRenderbuffers",
|
||||
"glCreateSamplers",
|
||||
"glCreateShader",
|
||||
"glCreateShaderProgramv",
|
||||
"glCreateTextures",
|
||||
"glCreateTransformFeedbacks",
|
||||
"glCreateVertexArrays",
|
||||
"glCullFace",
|
||||
"glDebugMessageCallback",
|
||||
"glDebugMessageControl",
|
||||
"glDebugMessageInsert",
|
||||
"glDeleteBuffers",
|
||||
"glDeleteFramebuffers",
|
||||
"glDeleteProgram",
|
||||
"glDeleteProgramPipelines",
|
||||
"glDeleteQueries",
|
||||
"glDeleteRenderbuffers",
|
||||
"glDeleteSamplers",
|
||||
"glDeleteShader",
|
||||
"glDeleteSync",
|
||||
"glDeleteTextures",
|
||||
"glDeleteTransformFeedbacks",
|
||||
"glDeleteVertexArrays",
|
||||
"glDepthFunc",
|
||||
"glDepthMask",
|
||||
"glDepthRange",
|
||||
"glDepthRangeArrayv",
|
||||
"glDepthRangeIndexed",
|
||||
"glDepthRangef",
|
||||
"glDetachShader",
|
||||
"glDisable",
|
||||
"glDisableVertexArrayAttrib",
|
||||
"glDisableVertexAttribArray",
|
||||
"glDisablei",
|
||||
"glDispatchCompute",
|
||||
"glDispatchComputeIndirect",
|
||||
"glDrawArrays",
|
||||
"glDrawArraysIndirect",
|
||||
"glDrawArraysInstanced",
|
||||
"glDrawArraysInstancedBaseInstance",
|
||||
"glDrawBuffer",
|
||||
"glDrawBuffers",
|
||||
"glDrawElements",
|
||||
"glDrawElementsBaseVertex",
|
||||
"glDrawElementsIndirect",
|
||||
"glDrawElementsInstanced",
|
||||
"glDrawElementsInstancedBaseInstance",
|
||||
"glDrawElementsInstancedBaseVertex",
|
||||
"glDrawElementsInstancedBaseVertexBaseInstance",
|
||||
"glDrawRangeElements",
|
||||
"glDrawRangeElementsBaseVertex",
|
||||
"glDrawTransformFeedback",
|
||||
"glDrawTransformFeedbackInstanced",
|
||||
"glDrawTransformFeedbackStream",
|
||||
"glDrawTransformFeedbackStreamInstanced",
|
||||
"glEnable",
|
||||
"glEnableVertexArrayAttrib",
|
||||
"glEnableVertexAttribArray",
|
||||
"glEnablei",
|
||||
"glEndConditionalRender",
|
||||
"glEndQuery",
|
||||
"glEndQueryIndexed",
|
||||
"glEndTransformFeedback",
|
||||
"glFenceSync",
|
||||
"glFinish",
|
||||
"glFlush",
|
||||
"glFlushMappedBufferRange",
|
||||
"glFlushMappedNamedBufferRange",
|
||||
"glFramebufferParameteri",
|
||||
"glFramebufferRenderbuffer",
|
||||
"glFramebufferTexture",
|
||||
"glFramebufferTexture1D",
|
||||
"glFramebufferTexture2D",
|
||||
"glFramebufferTexture3D",
|
||||
"glFramebufferTextureLayer",
|
||||
"glFrontFace",
|
||||
"glGenBuffers",
|
||||
"glGenFramebuffers",
|
||||
"glGenProgramPipelines",
|
||||
"glGenQueries",
|
||||
"glGenRenderbuffers",
|
||||
"glGenSamplers",
|
||||
"glGenTextures",
|
||||
"glGenTransformFeedbacks",
|
||||
"glGenVertexArrays",
|
||||
"glGenerateMipmap",
|
||||
"glGenerateTextureMipmap",
|
||||
"glGetActiveAtomicCounterBufferiv",
|
||||
"glGetActiveAttrib",
|
||||
"glGetActiveSubroutineName",
|
||||
"glGetActiveSubroutineUniformName",
|
||||
"glGetActiveSubroutineUniformiv",
|
||||
"glGetActiveUniform",
|
||||
"glGetActiveUniformBlockName",
|
||||
"glGetActiveUniformBlockiv",
|
||||
"glGetActiveUniformName",
|
||||
"glGetActiveUniformsiv",
|
||||
"glGetAttachedShaders",
|
||||
"glGetAttribLocation",
|
||||
"glGetBooleani_v",
|
||||
"glGetBooleanv",
|
||||
"glGetBufferParameteri64v",
|
||||
"glGetBufferParameteriv",
|
||||
"glGetBufferPointerv",
|
||||
"glGetBufferSubData",
|
||||
"glGetCompressedTexImage",
|
||||
"glGetCompressedTextureImage",
|
||||
"glGetCompressedTextureSubImage",
|
||||
"glGetDebugMessageLog",
|
||||
"glGetDoublei_v",
|
||||
"glGetDoublev",
|
||||
"glGetError",
|
||||
"glGetFloati_v",
|
||||
"glGetFloatv",
|
||||
"glGetFragDataIndex",
|
||||
"glGetFragDataLocation",
|
||||
"glGetFramebufferAttachmentParameteriv",
|
||||
"glGetFramebufferParameteriv",
|
||||
"glGetGraphicsResetStatus",
|
||||
"glGetInteger64i_v",
|
||||
"glGetInteger64v",
|
||||
"glGetIntegeri_v",
|
||||
"glGetIntegerv",
|
||||
"glGetInternalformati64v",
|
||||
"glGetInternalformativ",
|
||||
"glGetMultisamplefv",
|
||||
"glGetNamedBufferParameteri64v",
|
||||
"glGetNamedBufferParameteriv",
|
||||
"glGetNamedBufferPointerv",
|
||||
"glGetNamedBufferSubData",
|
||||
"glGetNamedFramebufferAttachmentParameteriv",
|
||||
"glGetNamedFramebufferParameteriv",
|
||||
"glGetNamedRenderbufferParameteriv",
|
||||
"glGetObjectLabel",
|
||||
"glGetObjectPtrLabel",
|
||||
"glGetPointerv",
|
||||
"glGetProgramBinary",
|
||||
"glGetProgramInfoLog",
|
||||
"glGetProgramInterfaceiv",
|
||||
"glGetProgramPipelineInfoLog",
|
||||
"glGetProgramPipelineiv",
|
||||
"glGetProgramResourceIndex",
|
||||
"glGetProgramResourceLocation",
|
||||
"glGetProgramResourceLocationIndex",
|
||||
"glGetProgramResourceName",
|
||||
"glGetProgramResourceiv",
|
||||
"glGetProgramStageiv",
|
||||
"glGetProgramiv",
|
||||
"glGetQueryBufferObjecti64v",
|
||||
"glGetQueryBufferObjectiv",
|
||||
"glGetQueryBufferObjectui64v",
|
||||
"glGetQueryBufferObjectuiv",
|
||||
"glGetQueryIndexediv",
|
||||
"glGetQueryObjecti64v",
|
||||
"glGetQueryObjectiv",
|
||||
"glGetQueryObjectui64v",
|
||||
"glGetQueryObjectuiv",
|
||||
"glGetQueryiv",
|
||||
"glGetRenderbufferParameteriv",
|
||||
"glGetSamplerParameterIiv",
|
||||
"glGetSamplerParameterIuiv",
|
||||
"glGetSamplerParameterfv",
|
||||
"glGetSamplerParameteriv",
|
||||
"glGetShaderInfoLog",
|
||||
"glGetShaderPrecisionFormat",
|
||||
"glGetShaderSource",
|
||||
"glGetShaderiv",
|
||||
"glGetString",
|
||||
"glGetStringi",
|
||||
"glGetSubroutineIndex",
|
||||
"glGetSubroutineUniformLocation",
|
||||
"glGetSynciv",
|
||||
"glGetTexImage",
|
||||
"glGetTexLevelParameterfv",
|
||||
"glGetTexLevelParameteriv",
|
||||
"glGetTexParameterIiv",
|
||||
"glGetTexParameterIuiv",
|
||||
"glGetTexParameterfv",
|
||||
"glGetTexParameteriv",
|
||||
"glGetTextureImage",
|
||||
"glGetTextureLevelParameterfv",
|
||||
"glGetTextureLevelParameteriv",
|
||||
"glGetTextureParameterIiv",
|
||||
"glGetTextureParameterIuiv",
|
||||
"glGetTextureParameterfv",
|
||||
"glGetTextureParameteriv",
|
||||
"glGetTextureSubImage",
|
||||
"glGetTransformFeedbackVarying",
|
||||
"glGetTransformFeedbacki64_v",
|
||||
"glGetTransformFeedbacki_v",
|
||||
"glGetTransformFeedbackiv",
|
||||
"glGetUniformBlockIndex",
|
||||
"glGetUniformIndices",
|
||||
"glGetUniformLocation",
|
||||
"glGetUniformSubroutineuiv",
|
||||
"glGetUniformdv",
|
||||
"glGetUniformfv",
|
||||
"glGetUniformiv",
|
||||
"glGetUniformuiv",
|
||||
"glGetVertexArrayIndexed64iv",
|
||||
"glGetVertexArrayIndexediv",
|
||||
"glGetVertexArrayiv",
|
||||
"glGetVertexAttribIiv",
|
||||
"glGetVertexAttribIuiv",
|
||||
"glGetVertexAttribLdv",
|
||||
"glGetVertexAttribPointerv",
|
||||
"glGetVertexAttribdv",
|
||||
"glGetVertexAttribfv",
|
||||
"glGetVertexAttribiv",
|
||||
"glGetnCompressedTexImage",
|
||||
"glGetnTexImage",
|
||||
"glGetnUniformdv",
|
||||
"glGetnUniformfv",
|
||||
"glGetnUniformiv",
|
||||
"glGetnUniformuiv",
|
||||
"glHint",
|
||||
"glInvalidateBufferData",
|
||||
"glInvalidateBufferSubData",
|
||||
"glInvalidateFramebuffer",
|
||||
"glInvalidateNamedFramebufferData",
|
||||
"glInvalidateNamedFramebufferSubData",
|
||||
"glInvalidateSubFramebuffer",
|
||||
"glInvalidateTexImage",
|
||||
"glInvalidateTexSubImage",
|
||||
"glIsBuffer",
|
||||
"glIsEnabled",
|
||||
"glIsEnabledi",
|
||||
"glIsFramebuffer",
|
||||
"glIsProgram",
|
||||
"glIsProgramPipeline",
|
||||
"glIsQuery",
|
||||
"glIsRenderbuffer",
|
||||
"glIsSampler",
|
||||
"glIsShader",
|
||||
"glIsSync",
|
||||
"glIsTexture",
|
||||
"glIsTransformFeedback",
|
||||
"glIsVertexArray",
|
||||
"glLineWidth",
|
||||
"glLinkProgram",
|
||||
"glLogicOp",
|
||||
"glMapBuffer",
|
||||
"glMapBufferRange",
|
||||
"glMapNamedBuffer",
|
||||
"glMapNamedBufferRange",
|
||||
"glMemoryBarrier",
|
||||
"glMemoryBarrierByRegion",
|
||||
"glMinSampleShading",
|
||||
"glMultiDrawArrays",
|
||||
"glMultiDrawArraysIndirect",
|
||||
"glMultiDrawArraysIndirectCount",
|
||||
"glMultiDrawElements",
|
||||
"glMultiDrawElementsBaseVertex",
|
||||
"glMultiDrawElementsIndirect",
|
||||
"glMultiDrawElementsIndirectCount",
|
||||
"glNamedBufferData",
|
||||
"glNamedBufferStorage",
|
||||
"glNamedBufferSubData",
|
||||
"glNamedFramebufferDrawBuffer",
|
||||
"glNamedFramebufferDrawBuffers",
|
||||
"glNamedFramebufferParameteri",
|
||||
"glNamedFramebufferReadBuffer",
|
||||
"glNamedFramebufferRenderbuffer",
|
||||
"glNamedFramebufferTexture",
|
||||
"glNamedFramebufferTextureLayer",
|
||||
"glNamedRenderbufferStorage",
|
||||
"glNamedRenderbufferStorageMultisample",
|
||||
"glObjectLabel",
|
||||
"glObjectPtrLabel",
|
||||
"glPatchParameterfv",
|
||||
"glPatchParameteri",
|
||||
"glPauseTransformFeedback",
|
||||
"glPixelStoref",
|
||||
"glPixelStorei",
|
||||
"glPointParameterf",
|
||||
"glPointParameterfv",
|
||||
"glPointParameteri",
|
||||
"glPointParameteriv",
|
||||
"glPointSize",
|
||||
"glPolygonMode",
|
||||
"glPolygonOffset",
|
||||
"glPolygonOffsetClamp",
|
||||
"glPopDebugGroup",
|
||||
"glPrimitiveRestartIndex",
|
||||
"glProgramBinary",
|
||||
"glProgramParameteri",
|
||||
"glProgramUniform1d",
|
||||
"glProgramUniform1dv",
|
||||
"glProgramUniform1f",
|
||||
"glProgramUniform1fv",
|
||||
"glProgramUniform1i",
|
||||
"glProgramUniform1iv",
|
||||
"glProgramUniform1ui",
|
||||
"glProgramUniform1uiv",
|
||||
"glProgramUniform2d",
|
||||
"glProgramUniform2dv",
|
||||
"glProgramUniform2f",
|
||||
"glProgramUniform2fv",
|
||||
"glProgramUniform2i",
|
||||
"glProgramUniform2iv",
|
||||
"glProgramUniform2ui",
|
||||
"glProgramUniform2uiv",
|
||||
"glProgramUniform3d",
|
||||
"glProgramUniform3dv",
|
||||
"glProgramUniform3f",
|
||||
"glProgramUniform3fv",
|
||||
"glProgramUniform3i",
|
||||
"glProgramUniform3iv",
|
||||
"glProgramUniform3ui",
|
||||
"glProgramUniform3uiv",
|
||||
"glProgramUniform4d",
|
||||
"glProgramUniform4dv",
|
||||
"glProgramUniform4f",
|
||||
"glProgramUniform4fv",
|
||||
"glProgramUniform4i",
|
||||
"glProgramUniform4iv",
|
||||
"glProgramUniform4ui",
|
||||
"glProgramUniform4uiv",
|
||||
"glProgramUniformMatrix2dv",
|
||||
"glProgramUniformMatrix2fv",
|
||||
"glProgramUniformMatrix2x3dv",
|
||||
"glProgramUniformMatrix2x3fv",
|
||||
"glProgramUniformMatrix2x4dv",
|
||||
"glProgramUniformMatrix2x4fv",
|
||||
"glProgramUniformMatrix3dv",
|
||||
"glProgramUniformMatrix3fv",
|
||||
"glProgramUniformMatrix3x2dv",
|
||||
"glProgramUniformMatrix3x2fv",
|
||||
"glProgramUniformMatrix3x4dv",
|
||||
"glProgramUniformMatrix3x4fv",
|
||||
"glProgramUniformMatrix4dv",
|
||||
"glProgramUniformMatrix4fv",
|
||||
"glProgramUniformMatrix4x2dv",
|
||||
"glProgramUniformMatrix4x2fv",
|
||||
"glProgramUniformMatrix4x3dv",
|
||||
"glProgramUniformMatrix4x3fv",
|
||||
"glProvokingVertex",
|
||||
"glPushDebugGroup",
|
||||
"glQueryCounter",
|
||||
"glReadBuffer",
|
||||
"glReadPixels",
|
||||
"glReadnPixels",
|
||||
"glReleaseShaderCompiler",
|
||||
"glRenderbufferStorage",
|
||||
"glRenderbufferStorageMultisample",
|
||||
"glResumeTransformFeedback",
|
||||
"glSampleCoverage",
|
||||
"glSampleMaski",
|
||||
"glSamplerParameterIiv",
|
||||
"glSamplerParameterIuiv",
|
||||
"glSamplerParameterf",
|
||||
"glSamplerParameterfv",
|
||||
"glSamplerParameteri",
|
||||
"glSamplerParameteriv",
|
||||
"glScissor",
|
||||
"glScissorArrayv",
|
||||
"glScissorIndexed",
|
||||
"glScissorIndexedv",
|
||||
"glShaderBinary",
|
||||
"glShaderSource",
|
||||
"glShaderStorageBlockBinding",
|
||||
"glSpecializeShader",
|
||||
"glStencilFunc",
|
||||
"glStencilFuncSeparate",
|
||||
"glStencilMask",
|
||||
"glStencilMaskSeparate",
|
||||
"glStencilOp",
|
||||
"glStencilOpSeparate",
|
||||
"glTexBuffer",
|
||||
"glTexBufferRange",
|
||||
"glTexImage1D",
|
||||
"glTexImage2D",
|
||||
"glTexImage2DMultisample",
|
||||
"glTexImage3D",
|
||||
"glTexImage3DMultisample",
|
||||
"glTexParameterIiv",
|
||||
"glTexParameterIuiv",
|
||||
"glTexParameterf",
|
||||
"glTexParameterfv",
|
||||
"glTexParameteri",
|
||||
"glTexParameteriv",
|
||||
"glTexStorage1D",
|
||||
"glTexStorage2D",
|
||||
"glTexStorage2DMultisample",
|
||||
"glTexStorage3D",
|
||||
"glTexStorage3DMultisample",
|
||||
"glTexSubImage1D",
|
||||
"glTexSubImage2D",
|
||||
"glTexSubImage3D",
|
||||
"glTextureBarrier",
|
||||
"glTextureBuffer",
|
||||
"glTextureBufferRange",
|
||||
"glTextureParameterIiv",
|
||||
"glTextureParameterIuiv",
|
||||
"glTextureParameterf",
|
||||
"glTextureParameterfv",
|
||||
"glTextureParameteri",
|
||||
"glTextureParameteriv",
|
||||
"glTextureStorage1D",
|
||||
"glTextureStorage2D",
|
||||
"glTextureStorage2DMultisample",
|
||||
"glTextureStorage3D",
|
||||
"glTextureStorage3DMultisample",
|
||||
"glTextureSubImage1D",
|
||||
"glTextureSubImage2D",
|
||||
"glTextureSubImage3D",
|
||||
"glTextureView",
|
||||
"glTransformFeedbackBufferBase",
|
||||
"glTransformFeedbackBufferRange",
|
||||
"glTransformFeedbackVaryings",
|
||||
"glUniform1d",
|
||||
"glUniform1dv",
|
||||
"glUniform1f",
|
||||
"glUniform1fv",
|
||||
"glUniform1i",
|
||||
"glUniform1iv",
|
||||
"glUniform1ui",
|
||||
"glUniform1uiv",
|
||||
"glUniform2d",
|
||||
"glUniform2dv",
|
||||
"glUniform2f",
|
||||
"glUniform2fv",
|
||||
"glUniform2i",
|
||||
"glUniform2iv",
|
||||
"glUniform2ui",
|
||||
"glUniform2uiv",
|
||||
"glUniform3d",
|
||||
"glUniform3dv",
|
||||
"glUniform3f",
|
||||
"glUniform3fv",
|
||||
"glUniform3i",
|
||||
"glUniform3iv",
|
||||
"glUniform3ui",
|
||||
"glUniform3uiv",
|
||||
"glUniform4d",
|
||||
"glUniform4dv",
|
||||
"glUniform4f",
|
||||
"glUniform4fv",
|
||||
"glUniform4i",
|
||||
"glUniform4iv",
|
||||
"glUniform4ui",
|
||||
"glUniform4uiv",
|
||||
"glUniformBlockBinding",
|
||||
"glUniformMatrix2dv",
|
||||
"glUniformMatrix2fv",
|
||||
"glUniformMatrix2x3dv",
|
||||
"glUniformMatrix2x3fv",
|
||||
"glUniformMatrix2x4dv",
|
||||
"glUniformMatrix2x4fv",
|
||||
"glUniformMatrix3dv",
|
||||
"glUniformMatrix3fv",
|
||||
"glUniformMatrix3x2dv",
|
||||
"glUniformMatrix3x2fv",
|
||||
"glUniformMatrix3x4dv",
|
||||
"glUniformMatrix3x4fv",
|
||||
"glUniformMatrix4dv",
|
||||
"glUniformMatrix4fv",
|
||||
"glUniformMatrix4x2dv",
|
||||
"glUniformMatrix4x2fv",
|
||||
"glUniformMatrix4x3dv",
|
||||
"glUniformMatrix4x3fv",
|
||||
"glUniformSubroutinesuiv",
|
||||
"glUnmapBuffer",
|
||||
"glUnmapNamedBuffer",
|
||||
"glUseProgram",
|
||||
"glUseProgramStages",
|
||||
"glValidateProgram",
|
||||
"glValidateProgramPipeline",
|
||||
"glVertexArrayAttribBinding",
|
||||
"glVertexArrayAttribFormat",
|
||||
"glVertexArrayAttribIFormat",
|
||||
"glVertexArrayAttribLFormat",
|
||||
"glVertexArrayBindingDivisor",
|
||||
"glVertexArrayElementBuffer",
|
||||
"glVertexArrayVertexBuffer",
|
||||
"glVertexArrayVertexBuffers",
|
||||
"glVertexAttrib1d",
|
||||
"glVertexAttrib1dv",
|
||||
"glVertexAttrib1f",
|
||||
"glVertexAttrib1fv",
|
||||
"glVertexAttrib1s",
|
||||
"glVertexAttrib1sv",
|
||||
"glVertexAttrib2d",
|
||||
"glVertexAttrib2dv",
|
||||
"glVertexAttrib2f",
|
||||
"glVertexAttrib2fv",
|
||||
"glVertexAttrib2s",
|
||||
"glVertexAttrib2sv",
|
||||
"glVertexAttrib3d",
|
||||
"glVertexAttrib3dv",
|
||||
"glVertexAttrib3f",
|
||||
"glVertexAttrib3fv",
|
||||
"glVertexAttrib3s",
|
||||
"glVertexAttrib3sv",
|
||||
"glVertexAttrib4Nbv",
|
||||
"glVertexAttrib4Niv",
|
||||
"glVertexAttrib4Nsv",
|
||||
"glVertexAttrib4Nub",
|
||||
"glVertexAttrib4Nubv",
|
||||
"glVertexAttrib4Nuiv",
|
||||
"glVertexAttrib4Nusv",
|
||||
"glVertexAttrib4bv",
|
||||
"glVertexAttrib4d",
|
||||
"glVertexAttrib4dv",
|
||||
"glVertexAttrib4f",
|
||||
"glVertexAttrib4fv",
|
||||
"glVertexAttrib4iv",
|
||||
"glVertexAttrib4s",
|
||||
"glVertexAttrib4sv",
|
||||
"glVertexAttrib4ubv",
|
||||
"glVertexAttrib4uiv",
|
||||
"glVertexAttrib4usv",
|
||||
"glVertexAttribBinding",
|
||||
"glVertexAttribDivisor",
|
||||
"glVertexAttribFormat",
|
||||
"glVertexAttribI1i",
|
||||
"glVertexAttribI1iv",
|
||||
"glVertexAttribI1ui",
|
||||
"glVertexAttribI1uiv",
|
||||
"glVertexAttribI2i",
|
||||
"glVertexAttribI2iv",
|
||||
"glVertexAttribI2ui",
|
||||
"glVertexAttribI2uiv",
|
||||
"glVertexAttribI3i",
|
||||
"glVertexAttribI3iv",
|
||||
"glVertexAttribI3ui",
|
||||
"glVertexAttribI3uiv",
|
||||
"glVertexAttribI4bv",
|
||||
"glVertexAttribI4i",
|
||||
"glVertexAttribI4iv",
|
||||
"glVertexAttribI4sv",
|
||||
"glVertexAttribI4ubv",
|
||||
"glVertexAttribI4ui",
|
||||
"glVertexAttribI4uiv",
|
||||
"glVertexAttribI4usv",
|
||||
"glVertexAttribIFormat",
|
||||
"glVertexAttribIPointer",
|
||||
"glVertexAttribL1d",
|
||||
"glVertexAttribL1dv",
|
||||
"glVertexAttribL2d",
|
||||
"glVertexAttribL2dv",
|
||||
"glVertexAttribL3d",
|
||||
"glVertexAttribL3dv",
|
||||
"glVertexAttribL4d",
|
||||
"glVertexAttribL4dv",
|
||||
"glVertexAttribLFormat",
|
||||
"glVertexAttribLPointer",
|
||||
"glVertexAttribP1ui",
|
||||
"glVertexAttribP1uiv",
|
||||
"glVertexAttribP2ui",
|
||||
"glVertexAttribP2uiv",
|
||||
"glVertexAttribP3ui",
|
||||
"glVertexAttribP3uiv",
|
||||
"glVertexAttribP4ui",
|
||||
"glVertexAttribP4uiv",
|
||||
"glVertexAttribPointer",
|
||||
"glVertexBindingDivisor",
|
||||
"glViewport",
|
||||
"glViewportArrayv",
|
||||
"glViewportIndexedf",
|
||||
"glViewportIndexedfv",
|
||||
"glWaitSync",
|
||||
};
|
||||
|
||||
union GL3WProcs gl3wProcs;
|
||||
|
||||
static void load_procs(GL3WGetProcAddressProc proc)
|
||||
{
|
||||
size_t i;
|
||||
for (i = 0; i < ARRAY_SIZE(proc_names); i++)
|
||||
gl3wProcs.ptr[i] = proc(proc_names[i]);
|
||||
}
|
1
simulation/imgui
Submodule
1
simulation/imgui
Submodule
|
@ -0,0 +1 @@
|
|||
Subproject commit d1d5075b66f93686954154ceaba7fe30abc41f4b
|
6
simulation/include/SDL.h
Normal file
6
simulation/include/SDL.h
Normal file
|
@ -0,0 +1,6 @@
|
|||
#if defined(__APPLE__)
|
||||
|
||||
#include <SDL2/SDL.h>
|
||||
#else
|
||||
#error "Platform not supported, fix include paths and stuff.."
|
||||
#endif
|
1
simulation/include/SDL_syswm.h
Normal file
1
simulation/include/SDL_syswm.h
Normal file
|
@ -0,0 +1 @@
|
|||
#include <SDL2/SDL_syswm.h>
|
|
@ -7,6 +7,10 @@
|
|||
#include <cmath>
|
||||
#include "globals.h"
|
||||
#include "hardware.h"
|
||||
#include "imgui.h"
|
||||
#include "GL/gl3w.h"
|
||||
#include "examples/imgui_impl_sdl.h"
|
||||
#include "examples/imgui_impl_opengl3.h"
|
||||
|
||||
#include <Arduino.h>
|
||||
|
||||
|
@ -24,10 +28,9 @@ SimWire Wire;
|
|||
SimSerial Serial;
|
||||
|
||||
|
||||
static const int scale = 4;
|
||||
static const int scale = 3;
|
||||
|
||||
static SDL_Window *window;
|
||||
static SDL_Surface *surface;
|
||||
|
||||
void _reboot_Teensyduino_()
|
||||
{
|
||||
|
@ -59,6 +62,8 @@ static uint16_t analogInputs[256]; // random number of inputs..
|
|||
static uint16_t analogOutputs[256]; // random number of inputs..
|
||||
static int _analogRes = 12;
|
||||
|
||||
static GLuint displayTexture;
|
||||
|
||||
void digitalWrite(uint8_t pin, uint8_t val)
|
||||
{
|
||||
printf("digital write %d = %d\n", pin, val);
|
||||
|
@ -88,7 +93,7 @@ int analogRead(uint8_t pin)
|
|||
|
||||
void analogReadRes(unsigned int __attribute__((unused)) bits)
|
||||
{
|
||||
// ??
|
||||
_analogRes = bits;
|
||||
}
|
||||
|
||||
uint32_t analogWriteRes(uint32_t res)
|
||||
|
@ -112,7 +117,7 @@ bool animateAnalogs = false;
|
|||
void analogUpdate(uint32_t time) {
|
||||
|
||||
const uint16_t touchMaxValue = 1023;
|
||||
const uint16_t analogMax = 4095;
|
||||
const uint16_t analogMax = (1<<_analogRes)-1;
|
||||
|
||||
if(animateAnalogs) {
|
||||
for( int i = 0 ; i < 32; ++i) {
|
||||
|
@ -126,7 +131,6 @@ void analogUpdate(uint32_t time) {
|
|||
regs[r] = value & 0xffu;
|
||||
regs[r+1] = (value >> 8) & 0x03u;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -141,57 +145,118 @@ uint32_t millis()
|
|||
return SDL_GetTicks();
|
||||
}
|
||||
|
||||
int touchRead(uint8_t reg){ return touchSensor.readRegister16(reg); }
|
||||
|
||||
// There are 9 touch sensors pins on the teensy 3.2
|
||||
int touchValues[12];
|
||||
|
||||
static int touchPinMapping[12] = {
|
||||
specialKeyPin, // 0 // SK or S2
|
||||
halfPitchBendKeyPin, // 1 // PD or S1
|
||||
vibratoPin, // 15
|
||||
extraPin, // 16
|
||||
bitePin, // 17
|
||||
pbDnPin, // 22
|
||||
pbUpPin, // 23
|
||||
};
|
||||
|
||||
|
||||
int main()
|
||||
int touchRead(uint8_t pin)
|
||||
{
|
||||
return SimRun();
|
||||
// find mapped sensors
|
||||
int i = 0;
|
||||
for(; i< 9 && touchPinMapping[i] != pin; ++i)
|
||||
if( i < 9)
|
||||
return touchValues[i];
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void touchWrite(uint8_t pin, uint16_t value)
|
||||
{
|
||||
// find mapped sensors
|
||||
int i = 0;
|
||||
for(; (i < 9) && (touchPinMapping[i] != pin); ++i)
|
||||
if( i < 9) touchValues[i] = value;
|
||||
}
|
||||
|
||||
//***********************************************************
|
||||
|
||||
static void GetDisplay(SDL_Surface* dest)
|
||||
static void doInputWindow()
|
||||
{
|
||||
int w = display.width();
|
||||
int h = display.height();
|
||||
if( ImGui::Begin( "Inputs" ) ) {
|
||||
int val = analogInputs[breathSensorPin];
|
||||
if( ImGui::SliderInt("Breath input", &val, 0, 4095 ) && !animateAnalogs ) {
|
||||
analogInputs[breathSensorPin] = val;
|
||||
}
|
||||
|
||||
SDL_LockSurface(dest);
|
||||
uint8_t* buffer = (uint8_t*)surface->pixels;
|
||||
int pitch = surface->pitch;
|
||||
val = analogInputs[vMeterPin];
|
||||
if( ImGui::SliderInt("Voltage", &val, 0, 4095 ) && !animateAnalogs ) {
|
||||
analogInputs[vMeterPin] = val;
|
||||
}
|
||||
|
||||
if(!display.enabled_) {
|
||||
SDL_memset( buffer, 0, (w*h)*3);
|
||||
} else {
|
||||
int fg = 255;
|
||||
int bg = 0;
|
||||
val = analogInputs[0];
|
||||
if( ImGui::SliderInt("Unknown", &val, 0, 4095 ) && !animateAnalogs ) {
|
||||
analogInputs[0] = val;
|
||||
}
|
||||
|
||||
val = analogInputs[A7];
|
||||
if( ImGui::SliderInt("Alt Bite", &val, 0, 4095 ) && !animateAnalogs ) {
|
||||
analogInputs[A7] = val;
|
||||
}
|
||||
|
||||
}
|
||||
ImGui::End();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
static uint8_t displayBuffer[128*128];
|
||||
|
||||
static void GetDisplay()
|
||||
{
|
||||
SDL_memset( displayBuffer, 0, (128*128));
|
||||
|
||||
if(display.enabled_) {
|
||||
uint8_t fg = 255;
|
||||
uint8_t bg = 0;
|
||||
|
||||
if( display.dimmed_) fg = 127;
|
||||
if( display.inverted_ ) { int tmp = fg; fg = bg; bg = tmp; }
|
||||
if( display.inverted_ ) { uint8_t tmp = fg; fg = bg; bg = tmp; }
|
||||
|
||||
for(int y = 0 ; y < h; ++y) {
|
||||
for(int x = 0 ; x < w; ++x) {
|
||||
int color = display.getPixel(x,y) ? fg : bg;
|
||||
SDL_memset( buffer + pitch*y + x*3, color, 3);
|
||||
for(int y = 0 ; y < 64; ++y) {
|
||||
for(int x = 0 ; x < 128; ++x) {
|
||||
uint8_t color = display.getPixel(x,y) ? fg : bg;
|
||||
displayBuffer[x+y*128] = color;
|
||||
}
|
||||
}
|
||||
}
|
||||
SDL_UnlockSurface(dest);
|
||||
|
||||
glBindTexture( GL_TEXTURE_2D, displayTexture );
|
||||
glTexImage2D( GL_TEXTURE_2D, 0, GL_RGB, 128, 128, 0, GL_RGB, GL_UNSIGNED_BYTE_3_3_2, displayBuffer);
|
||||
|
||||
GLenum error = glGetError();
|
||||
if(error != GL_NO_ERROR) {
|
||||
printf("glerror %d\n", error);
|
||||
}
|
||||
glBindTexture( GL_TEXTURE_2D, 0);
|
||||
}
|
||||
|
||||
void toggleAnalogAnimation() {
|
||||
static void toggleAnalogAnimation() {
|
||||
animateAnalogs = !animateAnalogs;
|
||||
printf("Analog input variations: %s\n", animateAnalogs ? "ON": "OFF");
|
||||
}
|
||||
|
||||
static int doQuit = 0;
|
||||
|
||||
static void SimLoop(std::function<bool()> continue_predicate, std::function<void()> loopFunc)
|
||||
{
|
||||
int doQuit = 0;
|
||||
uint32_t time;
|
||||
while( continue_predicate() ) {
|
||||
|
||||
SDL_Event event;
|
||||
while( SDL_PollEvent(&event) ) {
|
||||
ImGui_ImplSDL2_ProcessEvent(&event);
|
||||
|
||||
if( event.type == SDL_QUIT ) {
|
||||
doQuit = 1;
|
||||
break;
|
||||
|
@ -225,18 +290,36 @@ static void SimLoop(std::function<bool()> continue_predicate, std::function<void
|
|||
|
||||
time = SDL_GetTicks();
|
||||
|
||||
analogUpdate(SDL_GetTicks());
|
||||
|
||||
if(loopFunc) loopFunc();
|
||||
|
||||
analogUpdate(time);
|
||||
|
||||
// TODO: Get buffer from SSD1306 and copy to surface...
|
||||
|
||||
GetDisplay(surface);
|
||||
GetDisplay();
|
||||
|
||||
SDL_Surface *dstSurface = SDL_GetWindowSurface(window);
|
||||
SDL_BlitScaled( surface, NULL, dstSurface, NULL );
|
||||
SDL_UpdateWindowSurface(window);
|
||||
glClearColor(0.0f, 1.0f, 0.0f, 1);
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
ImGui_ImplOpenGL3_NewFrame();
|
||||
ImGui_ImplSDL2_NewFrame(window);
|
||||
ImGui::NewFrame();
|
||||
|
||||
// Render UI here..
|
||||
doInputWindow();
|
||||
|
||||
ImGui::Begin("NuEVI display");
|
||||
ImVec2 size( 128*scale, 64*scale );
|
||||
ImVec2 uv0(0,0);
|
||||
ImVec2 uv1(1, 0.5f);
|
||||
uint64_t tmp = displayTexture; // Avoid warning as void* is larger than GLuint
|
||||
ImGui::Image( (void*)tmp, size, uv0, uv1 );
|
||||
|
||||
ImGui::End();
|
||||
|
||||
ImGui::Render();
|
||||
ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());
|
||||
SDL_GL_SwapWindow(window);
|
||||
|
||||
uint32_t timePassed = SDL_GetTicks() - time;
|
||||
if( timePassed < 16 ) {
|
||||
|
@ -257,18 +340,29 @@ static int SimRun( )
|
|||
|
||||
static int SimInit()
|
||||
{
|
||||
|
||||
int result = result = SDL_Init( SDL_INIT_VIDEO | SDL_INIT_AUDIO );
|
||||
if( 0 != result ) {
|
||||
fprintf(stderr, "Could not initialize SDL");
|
||||
return 1;
|
||||
}
|
||||
|
||||
window = SDL_CreateWindow( "TinySim"
|
||||
SDL_GL_SetAttribute(SDL_GL_CONTEXT_FLAGS, SDL_GL_CONTEXT_FORWARD_COMPATIBLE_FLAG);
|
||||
SDL_GL_SetAttribute(SDL_GL_ACCELERATED_VISUAL, 1);
|
||||
SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE);
|
||||
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
|
||||
SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24);
|
||||
SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, 8);
|
||||
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 4);
|
||||
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 1);
|
||||
|
||||
|
||||
window = SDL_CreateWindow( "NuEVI Simulator"
|
||||
, SDL_WINDOWPOS_UNDEFINED
|
||||
, SDL_WINDOWPOS_UNDEFINED
|
||||
, 128*scale
|
||||
, 64*scale
|
||||
, SDL_WINDOW_SHOWN );
|
||||
, 1024
|
||||
, 768
|
||||
, SDL_WINDOW_SHOWN | SDL_WINDOW_OPENGL);
|
||||
|
||||
if( window == NULL ) {
|
||||
fprintf(stderr, "Could not create SDL window");
|
||||
|
@ -276,22 +370,21 @@ static int SimInit()
|
|||
return 2;
|
||||
}
|
||||
|
||||
SDL_SetWindowTitle( window, "Tiny Sim" );
|
||||
SDL_GLContext context = SDL_GL_CreateContext(window);
|
||||
gl3wInit();
|
||||
|
||||
ImGui::CreateContext();
|
||||
ImGui_ImplSDL2_InitForOpenGL(window, context);
|
||||
ImGui_ImplOpenGL3_Init("#version 150");
|
||||
|
||||
glGenTextures(1, &displayTexture);
|
||||
glBindTexture( GL_TEXTURE_2D, displayTexture);
|
||||
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
glBindTexture(GL_TEXTURE_2D, 0);
|
||||
|
||||
memset(digitalInputs, 1, sizeof(digitalInputs));
|
||||
|
||||
int16_t w = display.width();
|
||||
int16_t h = display.height();
|
||||
|
||||
surface = SDL_CreateRGBSurfaceWithFormat(0, w, h, 0, SDL_PIXELFORMAT_RGB24);
|
||||
if(!surface)
|
||||
{
|
||||
printf("Could not create surface with size %d %d\n", w,h);
|
||||
SimQuit();
|
||||
}
|
||||
|
||||
printf("create surface with size %d %d\n", w,h);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -301,9 +394,15 @@ static void SimQuit()
|
|||
|
||||
if( window != NULL ) {
|
||||
SDL_DestroyWindow( window );
|
||||
SDL_FreeSurface( surface );
|
||||
// SDL_FreeSurface( surface );
|
||||
}
|
||||
SDL_Quit();
|
||||
}
|
||||
|
||||
#include "NuEVI.ino"
|
||||
|
||||
|
||||
int main()
|
||||
{
|
||||
return SimRun();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue