Skip to content

Commit

Permalink
Performance, support legacy applications, clean up
Browse files Browse the repository at this point in the history
* bump version to 0.8.0
* added 6 new extensions
* added many ARB/EXT functions
* added glGetTexImage
* proper glShaderSource implementation
* improved performance by replacing usleep with _mm_pause in server
* added SWAP_BUFFERS_SYNC register, fixing frame glitches
* removed SGL_SHARED_MEMORY_DIRECT
* added new font for overlay
* fix glColorPointer not handling GL_RGBA/GL_BGRA
* fix glNormalPointer size
* push vertex attribs in glDrawElements
* added CMake option for easier lib32 compilation
* cleaned up & reorganized code
  • Loading branch information
dmaivel committed Jul 28, 2024
1 parent 2fb69cc commit d2d8634
Show file tree
Hide file tree
Showing 17 changed files with 1,503 additions and 1,574 deletions.
12 changes: 9 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
cmake_minimum_required(VERSION 3.5.0)
project(sharedgl VERSION 0.7.2 LANGUAGES C)
project(sharedgl VERSION 0.8.0 LANGUAGES C)

include_directories(${CMAKE_SOURCE_DIR}/inc)

# set(CMAKE_C_COMPILER "clang")

option(LINUX_LIB32 "Compile 32-bit libGL. Does not affect server." OFF)

IF(WIN32)
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /Gz")
ELSE()
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -march=native")
# set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -march=native")
ENDIF(WIN32)

file(GLOB GLOBBED_SERVER_SOURCES CONFIGURE_DEPENDS "src/server/*.c" "src/network/*.c")
file(GLOB GLOBBED_SERVER_SOURCES CONFIGURE_DEPENDS "src/server/*.c" "src/network/*.c" "src/client/scratch.c")

# client stuff
IF(UNIX)
Expand All @@ -35,6 +37,10 @@ IF(UNIX)
target_link_libraries(sharedgl-core X11)
set_target_properties(sharedgl-core PROPERTIES OUTPUT_NAME "GL")
set_target_properties(sharedgl-core PROPERTIES VERSION 1)
IF(LINUX_LIB32)
target_compile_options(sharedgl-core PRIVATE "-m32")
target_link_options(sharedgl-core PRIVATE "-m32")
ENDIF(LINUX_LIB32)
ELSEIF(WIN32)
add_library(sharedgl-core SHARED ${GLOBBED_CLIENT_SOURCES} ${GLOBBED_CLIENT_P_SOURCES})
IF(CMAKE_GENERATOR_PLATFORM MATCHES "Win32")
Expand Down
13 changes: 10 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,16 @@ cmake --build . --target sharedgl-core --config Release

For detailed build instructions for Windows, visit the [Windows section](#windows-in-a-vm).

### Build options

These CMake options are accessible by either:
1. Using `ccmake` on `build` folder
2. Configuring with `-D...`

| **Option** | **Legal values** | **Default** | **Description** |
|-|-|-|-|
| LINUX_LIB32 | ON/OFF | OFF | Enable if you wish to build the Linux client library (libGL) as 32-bit. This does not affect the server. |

# Usage
The server must be started on the host before running any clients. Note that the server can only be ran on Linux.

Expand All @@ -70,7 +80,6 @@ Variables labeled with `host` get their values from the host/server when their o
| **Option** | **Legal values** | **Default** | **Description** |
|-|-|-|-|
| SGL_SHARED_MEMORY_DIRECT | Boolean | true | If you intend on only running a single accelerated application at a time, this variable ensures maximum performance by writing/reading directly to/from shared memory. Make sure to set to `false` if you intend on using multiclient support. Available for both Windows and Linux clients. |
| SGL_WINED3D_DONT_VFLIP | Boolean | false | If running a DirectX application via WineD3D, ensure this variable is set to `true` in order for the application to render the framebuffer in the proper orientation. Only available for Windows clients. |
| SGL_RUN_WITH_LOW_PRIORITY | Boolean | false | On single core setups, by setting the process priority to low / `IDLE_PRIORITY_CLASS`, applications will run smoother as the kernel driver is given more CPU time. Users should only set this to `true` if the VM has only a single VCPU. Only available for Windows clients. |
| GL_VERSION_OVERRIDE | Digit.Digit | `host` | Override the OpenGL version on the client side. Available for both Windows and Linux clients. |
Expand Down Expand Up @@ -122,8 +131,6 @@ There are two possible drivers one may use:
```
3. By default, this builds for Windows 10 x64 (`10_X64`). If you wish to compile for a different version or multiple versions, you must provide it through the command line like so: `kcertify.bat 10_X64,10_NI_X64`. A list of OS versions is provided on MSDN [here](https://learn.microsoft.com/en-us/windows-hardware/drivers/devtest/inf2cat).
If using multiclient support, please read about `SGL_SHARED_MEMORY_DIRECT` in the [environment variables](#environment-variables) section.
### Library / ICD
There are two ways to install the library on windows:
Expand Down
3 changes: 3 additions & 0 deletions inc/client/pb.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ struct pb_net_hooks {
void pb_set_net(struct pb_net_hooks hooks, size_t internal_alloc_size);

#ifndef _WIN32
/*
* to-do: determine if direct_access is really unneeded
*/
void pb_set(int pb, bool direct_access);
#else
void pb_set(bool direct_access);
Expand Down
3 changes: 3 additions & 0 deletions inc/commongl.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,15 @@ typedef int GLfixed;
typedef unsigned long GLuint64;
typedef long GLint64;
typedef struct __GLsync *GLsync;
typedef int GLhandleARB;
typedef char GLcharARB;

typedef void (*GLDEBUGPROC)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,const void *userParam);

/* GL types for handling large vertex buffer objects */
typedef long GLintptr;
typedef signed long GLsizeiptr;
typedef signed long GLsizeiptrARB;

/* Boolean */
#define GL_FALSE (GLboolean)0
Expand Down
Loading

0 comments on commit d2d8634

Please sign in to comment.