Merge branch 'static' into update

This commit is contained in:
Andrea Odetti 2021-10-23 20:27:43 +01:00
commit b16084baf3
14 changed files with 164 additions and 67 deletions

View file

@ -2,6 +2,7 @@ include(FindPkgConfig)
pkg_check_modules(YAML REQUIRED yaml-0.1)
pkg_check_modules(MINIZIP REQUIRED minizip)
pkg_check_modules(ZLIB REQUIRED zlib)
pkg_check_modules(SLIRP slirp)
if ("${SLIRP_FOUND}" STREQUAL "")
@ -228,7 +229,16 @@ set(HEADER_FILES
Z80VICE/daa.h
)
add_library(appleii SHARED
if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
# Applle's linker does not like the link-time interface of libappleii
# we need link everything at once
message("Mac OS X detected, libappleii as static library")
set(LIBRARY_TYPE "STATIC")
else()
set(LIBRARY_TYPE "SHARED")
endif()
add_library(appleii "${LIBRARY_TYPE}"
${SOURCE_FILES}
${HEADER_FILES}
)
@ -239,6 +249,7 @@ target_include_directories(appleii PRIVATE
${PCAP_INCLUDE_DIRS}
${Boost_INCLUDE_DIRS}
${SLIRP_INCLUDE_DIRS}
${ZLIB_INCLUDE_DIRS}
Debugger
)
@ -252,13 +263,15 @@ target_link_libraries(appleii PRIVATE
${MINIZIP_LIBRARIES}
${PCAP_LIBRARIES}
${SLIRP_LIBRARIES}
${ZLIB_LIBRARIES}
)
target_link_directories(appleii PRIVATE
${YAML_LIBRARY_DIR}
${MINIZIP_LIBRARY_DIR}
${PCAP_LIBRARY_DIR}
${SLIRP_LIBRARY_DIR}
${YAML_LIBRARY_DIRS}
${MINIZIP_LIBRARY_DIRS}
${PCAP_LIBRARY_DIRS}
${SLIRP_LIBRARY_DIRS}
${ZLIB_LIBRARY_DIRS}
)
target_compile_options(appleii PUBLIC

View file

@ -34,8 +34,9 @@ target_include_directories(common2 PRIVATE
${Boost_INCLUDE_DIRS}
)
target_link_libraries(common2 PUBLIC
target_link_libraries(common2 PRIVATE
Boost::program_options
appleii
)
file(RELATIVE_PATH ROOT_PATH ${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR})

View file

@ -3,7 +3,7 @@
#include "StdAfx.h"
#include "Memory.h"
#include "Debugger/DebugDefs.h"
#include "Debugger/Debugger_Types.h"
#include "viewbuffer.h"

View file

@ -1,12 +1,30 @@
include(FindPkgConfig)
find_package(SDL2 REQUIRED)
pkg_search_module(SDL2_IMAGE REQUIRED SDL2_image)
pkg_search_module(GLES2 REQUIRED glesv2)
add_executable(sa2)
set(IMGUI_PATH "imgui/imgui")
set(IMGUI_CLUB_PATH "imgui/imgui_club")
add_executable(sa2)
find_package(SDL2 REQUIRED)
pkg_search_module(SDL2_IMAGE REQUIRED SDL2_image)
# the default is to use GLES
set (SA2_USE_OPENGL 0)
if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
set (SA2_USE_OPENGL 1)
endif()
if (${SA2_USE_OPENGL})
pkg_search_module(GLES2 REQUIRED opengl)
else()
pkg_search_module(GLES2 REQUIRED glesv2)
target_compile_definitions(sa2 PRIVATE
IMGUI_IMPL_OPENGL_ES2
)
endif()
set(SOURCE_FILES
main.cpp
@ -65,7 +83,7 @@ target_sources(sa2 PRIVATE
imgui/settingshelper.h
imgui/sdlsettings.h
imgui/imconfig.h
imgui/gles.h
imgui/glselector.h
${IMGUI_PATH}/imgui.h
${IMGUI_PATH}/imgui.cpp
@ -86,7 +104,6 @@ target_include_directories(sa2 PRIVATE
)
target_compile_definitions(sa2 PRIVATE
IMGUI_IMPL_OPENGL_ES2
IMGUI_USER_CONFIG="frontends/sdl/imgui/imconfig.h"
)

View file

@ -1,35 +0,0 @@
#pragma once
#if defined(IMGUI_IMPL_OPENGL_ES2)
// Pi3 with Fake KMS
// "OpenGL ES 2.0 Mesa 19.3.2"
// "Supported versions are: 1.00 ES"
#include <GLES2/gl2.h>
#define SDL_CONTEXT_MAJOR 2
#elif defined(IMGUI_IMPL_OPENGL_ES3)
// Pi4 with Fake KMS
// "OpenGL ES 3.1 Mesa 19.3.2"
// "Supported versions are: 1.00 ES, 3.00 ES, and 3.10 ES"
// On my desktop
// "OpenGL ES 3.1 Mesa 20.2.6"
// "Supported versions are: 1.00 ES, 3.00 ES, and 3.10 ES"
#include <GLES3/gl3.h>
#define SDL_CONTEXT_MAJOR 3
// "310 es" is accepted on a Pi4, but the imgui shaders do not compile
#endif
// this is used in all cases for GL_BGRA_EXT
#include <GLES2/gl2ext.h>
#include "imgui.h"
#include "imgui_impl_sdl.h"
#include "imgui_impl_opengl3.h"
#include "imgui_memory_editor.h"

View file

@ -0,0 +1,75 @@
#pragma once
#if defined(IMGUI_IMPL_OPENGL_ES2)
// Pi3 with Fake KMS
// "OpenGL ES 2.0 Mesa 19.3.2"
// "Supported versions are: 1.00 ES"
#include <GLES2/gl2.h>
#include <GLES2/gl2ext.h>
#define SA2_CONTEXT_FLAGS 0
#define SA2_CONTEXT_PROFILE_MASK SDL_GL_CONTEXT_PROFILE_ES
#define SA2_CONTEXT_MAJOR_VERSION 2
#define SA2_CONTEXT_MINOR_VERSION 0
// this is defined in gl2ext.h and nowhere in gl3.h
#define SA2_IMAGE_FORMAT_INTERNAL GL_BGRA_EXT
#define SA2_IMAGE_FORMAT GL_BGRA_EXT
#elif defined(IMGUI_IMPL_OPENGL_ES3)
// Pi4 with Fake KMS
// "OpenGL ES 3.1 Mesa 19.3.2"
// "Supported versions are: 1.00 ES, 3.00 ES, and 3.10 ES"
// On my desktop
// "OpenGL ES 3.1 Mesa 20.2.6"
// "Supported versions are: 1.00 ES, 3.00 ES, and 3.10 ES"
// "310 es" is accepted on a Pi4, but the imgui shaders do not compile
#include <GLES3/gl3.h>
#include <GLES2/gl2ext.h>
#define SA2_CONTEXT_FLAGS 0
#define SA2_CONTEXT_PROFILE_MASK SDL_GL_CONTEXT_PROFILE_ES
#define SA2_CONTEXT_MAJOR_VERSION 3
#define SA2_CONTEXT_MINOR_VERSION 0
// this is defined in gl2ext.h and nowhere in gl3.h
#define SA2_IMAGE_FORMAT_INTERNAL GL_BGRA_EXT
#define SA2_IMAGE_FORMAT GL_BGRA_EXT
#elif defined(__APPLE__)
#include <SDL_opengl.h>
#define SA2_CONTEXT_FLAGS SDL_GL_CONTEXT_FORWARD_COMPATIBLE_FLAG
#define SA2_CONTEXT_PROFILE_MASK SDL_GL_CONTEXT_PROFILE_CORE
#define SA2_CONTEXT_MAJOR_VERSION 3
#define SA2_CONTEXT_MINOR_VERSION 2
#define SA2_IMAGE_FORMAT_INTERNAL GL_RGBA
#define SA2_IMAGE_FORMAT GL_BGRA
#else
#include <SDL_opengl.h>
#define SA2_CONTEXT_FLAGS 0
#define SA2_CONTEXT_PROFILE_MASK SDL_GL_CONTEXT_PROFILE_CORE
#define SA2_CONTEXT_MAJOR_VERSION 3
#define SA2_CONTEXT_MINOR_VERSION 2
#define SA2_IMAGE_FORMAT_INTERNAL GL_RGBA
#define SA2_IMAGE_FORMAT GL_BGRA
#endif
#include "imgui.h"
#include "imgui_impl_sdl.h"
#include "imgui_impl_opengl3.h"
#include "imgui_memory_editor.h"

View file

@ -31,10 +31,8 @@ namespace sa2
{
glBindTexture(GL_TEXTURE_2D, texture);
const GLenum format = GL_BGRA_EXT; // this is defined in gl2ext.h and nowhere in gl3.h
const GLenum type = GL_UNSIGNED_BYTE;
glTexImage2D(GL_TEXTURE_2D, 0, format, width, height, 0, format, type, nullptr);
glTexImage2D(GL_TEXTURE_2D, 0, SA2_IMAGE_FORMAT_INTERNAL, width, height, 0, SA2_IMAGE_FORMAT, type, nullptr);
}
void loadTextureFromData(GLuint texture, const uint8_t * data, size_t width, size_t height, size_t pitch)
@ -48,9 +46,8 @@ namespace sa2
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
const GLenum format = GL_BGRA_EXT; // this is defined in gl2ext.h and nowhere in gl3.h
const GLenum type = GL_UNSIGNED_BYTE;
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, width, height, format, type, data);
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, width, height, SA2_IMAGE_FORMAT, type, data);
// reset to default state
glPixelStorei(UGL_UNPACK_LENGTH, 0);
}

View file

@ -1,7 +1,7 @@
#pragma once
#include <cstddef>
#include "frontends/sdl/imgui/gles.h"
#include "frontends/sdl/imgui/glselector.h"
namespace sa2
{

View file

@ -12,16 +12,35 @@
#include <iostream>
namespace
{
std::string safeGlGetString(GLenum name)
{
const char * str = reinterpret_cast<const char *>(glGetString(name));
if (str)
{
return str;
}
else
{
return "<MISSING>";
}
}
}
namespace sa2
{
SDLImGuiFrame::SDLImGuiFrame(const common2::EmulatorOptions & options)
: SDLFrame(options)
{
SDL_GL_SetAttribute(SDL_GL_CONTEXT_FLAGS, 0);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_ES);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, SDL_CONTEXT_MAJOR); // from local gles.h
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 0);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_FLAGS, SA2_CONTEXT_FLAGS);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SA2_CONTEXT_PROFILE_MASK);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, SA2_CONTEXT_MAJOR_VERSION); // from local gles.h
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, SA2_CONTEXT_MINOR_VERSION);
// Create window with graphics context
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
@ -49,11 +68,11 @@ namespace sa2
// Setup Platform/Renderer backends
std::cerr << "IMGUI_VERSION: " << IMGUI_VERSION << std::endl;
std::cerr << "GL_VENDOR: " << glGetString(GL_VENDOR) << std::endl;
std::cerr << "GL_RENDERER: " << glGetString(GL_RENDERER) << std::endl;
std::cerr << "GL_VERSION: " << glGetString(GL_VERSION) << std::endl;
std::cerr << "GL_SHADING_LANGUAGE_VERSION: " << glGetString(GL_SHADING_LANGUAGE_VERSION) << std::endl;
// const char* runtime_gl_extensions = (const char*)glGetString(GL_EXTENSIONS);
std::cerr << "GL_VENDOR: " << safeGlGetString(GL_VENDOR) << std::endl;
std::cerr << "GL_RENDERER: " << safeGlGetString(GL_RENDERER) << std::endl;
std::cerr << "GL_VERSION: " << safeGlGetString(GL_VERSION) << std::endl;
std::cerr << "GL_SHADING_LANGUAGE_VERSION: " << safeGlGetString(GL_SHADING_LANGUAGE_VERSION) << std::endl;
// const char* runtime_gl_extensions = (const char*)safeGlGetString(GL_EXTENSIONS);
// std::cerr << "GL_EXTENSIONS: " << runtime_gl_extensions << std::endl;
// Setup Dear ImGui context

View file

@ -2,7 +2,7 @@
#include "frontends/sdl/sdlframe.h"
#include "frontends/sdl/imgui/sdlsettings.h"
#include "frontends/sdl/imgui/gles.h"
#include "frontends/sdl/imgui/glselector.h"
namespace common2
{

View file

@ -19,7 +19,7 @@
#include "Utilities.h"
#include "Memory.h"
#include "Debugger/DebugDefs.h"
#include "Debugger/Debugger_Types.h"
#include "Tfe/tfe.h"
#include "Tfe/tfesupp.h"

View file

@ -1,6 +1,6 @@
#pragma once
#include "frontends/sdl/imgui/gles.h"
#include "frontends/sdl/imgui/glselector.h"
#include "frontends/sdl/sdirectsound.h"
#include "Debugger/Debug.h"
#include "Debugger/Debugger_Console.h"

View file

@ -8,7 +8,7 @@
#include "Tfe/tfe.h"
#include "frontends/sdl/imgui/settingshelper.h"
#include "frontends/sdl/imgui/gles.h"
#include "frontends/sdl/imgui/glselector.h"
#include "imgui_internal.h"

View file

@ -2,10 +2,20 @@
#include "linux/network/uthernet2.h"
#include <unistd.h>
#include <sys/types.h>
#include <errno.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <poll.h>
// fix SOCK_NONBLOCK for e.g. macOS
#ifndef SOCK_NONBLOCK
// DISCALIMER
// totally untested, use at your own risk
#include <fcntl.h>
#define SOCK_NONBLOCK O_NONBLOCK
#endif
#define MAX_RXLENGTH 1518
// #define U2_LOG_VERBOSE