فهرست منبع

Build on Windows

kiwec 2 هفته پیش
والد
کامیت
036cbca374

+ 1 - 1
build.bat

@@ -13,7 +13,7 @@ if %errorlevel% equ 0 (
 set CXXFLAGS=-std=c++17 -Wall -fmessage-length=0 -Wno-sign-compare -Wno-unused-local-typedefs -Wno-reorder -Wno-switch -IC:\mingw32\include
 set CXXFLAGS=%CXXFLAGS% -D__GXX_EXPERIMENTAL_CXX0X__
 set CXXFLAGS=%CXXFLAGS% -Isrc/App -Isrc/App/Osu -Isrc/Engine -Isrc/GUI -Isrc/GUI/Windows -Isrc/GUI/Windows/VinylScratcher -Isrc/Engine/Input -Isrc/Engine/Platform -Isrc/Engine/Main -Isrc/Engine/Renderer -Isrc/Util
-set LDFLAGS=-logg -lADLMIDI -lmad -lmodplug -lsmpeg -lgme -lvorbis -lopus -lvorbisfile -ldiscord-rpc -lSDL2_mixer_ext.dll -lSDL2 -ld3dcompiler_47 -ld3d11 -ldxgi -lcurl -llibxinput9_1_0 -lfreetype -lopengl32 -lOpenCL -lvulkan-1 -lglew32 -lglu32 -lgdi32 -lbass -lbassasio -lbass_fx -lbassmix -lbasswasapi -lbassloud -lcomctl32 -lDwmapi -lComdlg32 -lpsapi -lws2_32 -lwinmm -lpthread -llibjpeg -lwbemuuid -lole32 -loleaut32 -llzma
+set LDFLAGS=-logg -lADLMIDI -lmad -lmodplug -lsmpeg -lgme -lvorbis -lopus -lvorbisfile -ldiscord-rpc -lSDL2_mixer_ext.dll -lSDL2 -ld3dcompiler_47 -ld3d11 -ldxgi -lcurl -llibxinput9_1_0 -lfreetype -lopengl32 -lOpenCL -lvulkan-1 -lglew32 -lglu32 -lgdi32 -lbass -lbassasio -lbass_fx -lbassmix -lbasswasapi -lbassloud -lcomctl32 -lDwmapi -lComdlg32 -lpsapi -lws2_32 -lwinmm -lpthread -llibjpeg -lwbemuuid -lole32 -loleaut32 -llzma -lShlwapi
 
 set CXXFLAGS=%CXXFLAGS% -g3
 rem set CXXFLAGS=%CXXFLAGS% -O3

+ 0 - 14
resources/shaders/flashlight.fsh

@@ -1,14 +0,0 @@
-#version 110
-
-uniform float max_opacity;
-uniform float flashlight_radius;
-uniform vec2 flashlight_center;
-
-void main(void)
-{
-    float dist = distance(flashlight_center, gl_FragCoord.xy);
-    float opacity = 1.0 - smoothstep(flashlight_radius, flashlight_radius * 1.4, dist);
-    opacity = 1.0 - min(opacity, max_opacity);
-
-    gl_FragColor = vec4(0.0, 0.0, 0.0, opacity);
-}

+ 0 - 10
resources/shaders/flashlight.vsh

@@ -1,10 +0,0 @@
-#version 110
-
-varying vec2 tex_coord;
-
-void main() {
-    gl_Position = gl_ModelViewProjectionMatrix * vec4(gl_Vertex.x, gl_Vertex.y, 0.0, 1.0);
-    gl_FrontColor = gl_Color;
-
-    tex_coord = gl_MultiTexCoord0.xy;
-}

+ 1 - 0
src/App/Osu/Bancho.cpp

@@ -1,4 +1,5 @@
 #ifdef _WIN32
+#include "cbase.h"
 #include <stdio.h>
 #include <wbemidl.h>
 #include <windows.h>

+ 1 - 0
src/App/Osu/BanchoSubmitter.cpp

@@ -1,4 +1,5 @@
 #ifdef _WIN32
+#include "cbase.h"
 #include <windows.h>
 #else
 #include <sys/random.h>

+ 21 - 1
src/App/Osu/Osu.cpp

@@ -498,7 +498,27 @@ Osu::Osu(int instanceID) {
     m_osu_mod_mafham_ref->setCallback(fastdelegate::MakeDelegate(this, &Osu::onModMafhamChange));
     m_osu_mod_fposu_ref->setCallback(fastdelegate::MakeDelegate(this, &Osu::onModFPoSuChange));
 
-    flashlight_shader = engine->getResourceManager()->loadShader("flashlight.vsh", "flashlight.fsh", "flashlight");
+    // Not the type of shader you want players to tweak or delete, so loading from string
+    flashlight_shader = engine->getGraphics()->createShaderFromSource(
+        "#version 110\n"
+        "varying vec2 tex_coord;\n"
+        "void main() {\n"
+        "    gl_Position = gl_ModelViewProjectionMatrix * vec4(gl_Vertex.x, gl_Vertex.y, 0.0, 1.0);\n"
+        "    gl_FrontColor = gl_Color;\n"
+        "    tex_coord = gl_MultiTexCoord0.xy;\n"
+        "}",
+        "#version 110\n"
+        "uniform float max_opacity;\n"
+        "uniform float flashlight_radius;\n"
+        "uniform vec2 flashlight_center;\n"
+        "void main(void) {\n"
+        "    float dist = distance(flashlight_center, gl_FragCoord.xy);\n"
+        "    float opacity = 1.0 - smoothstep(flashlight_radius, flashlight_radius * 1.4, dist);\n"
+        "    opacity = 1.0 - min(opacity, max_opacity);\n"
+        "    gl_FragColor = vec4(0.0, 0.0, 0.0, opacity);\n"
+        "}"
+    );
+
 }
 
 Osu::~Osu() {

+ 1 - 0
src/App/Osu/SongBrowser.cpp

@@ -1,4 +1,5 @@
 #ifdef _WIN32
+#include "cbase.h"
 #include <windows.h>
 #else
 #include <sys/random.h>

+ 1 - 2
src/App/Osu/UpdateHandler.cpp

@@ -130,9 +130,8 @@ void UpdateHandler::_requestUpdate() {
     const char *os = "linux";
 #endif
 
-    // XXX: Change update URL to /update/ or something
     debugLog("Downloading latest update... (current v%.2f, latest v%.2f)\n", current_version, fLatestVersion);
-    update_url = UString::format(NEOSU_UPDATE_URL "/neosu-multiplayer-%s-v%.2f.zip", os, fLatestVersion);
+    update_url = UString::format(NEOSU_UPDATE_URL "/update/%s-v%.2f.zip", os, fLatestVersion);
 }
 
 bool UpdateHandler::_downloadUpdate() {

+ 2 - 3
src/Engine/Font.cpp

@@ -86,7 +86,8 @@ void McFont::init() {
     FT_Set_Char_Size(face, m_iFontSize * 64, m_iFontSize * 64, m_iFontDPI, m_iFontDPI);
 
     // create texture atlas
-    const int atlasSize = m_iFontSize * m_iFontDPI / 10;  // XXX: incorrect calculation
+    // HACKHACK: hardcoded max atlas size, and heuristic
+    const int atlasSize = (m_iFontDPI > 96 ? (m_iFontDPI > 2 * 96 ? 2048 : 1024) : 512);
     engine->getResourceManager()->requestNextLoadUnmanaged();
     m_textureAtlas = engine->getResourceManager()->createTextureAtlas(atlasSize, atlasSize);
 
@@ -272,8 +273,6 @@ void McFont::renderFTGlyphToTextureAtlas(FT_Library library, FT_Face face, wchar
     const int width = bitmap.width;
     const int height = bitmap.rows;
 
-    debugLog("Creating texture for font %s (%dpt)\n", m_sFilePath.c_str(), m_iFontSize);
-
     // build texture
     Vector2 atlasPos;
     if(width > 0 && height > 0) {

+ 1 - 0
src/Engine/Platform/WinContextMenu.h

@@ -12,6 +12,7 @@
 #ifndef WINCONTEXTMENU_H
 #define WINCONTEXTMENU_H
 
+#include "cbase.h"
 #include <Windows.h>
 
 #include "ContextMenu.h"

+ 1 - 0
src/Engine/Platform/WinEnvironment.h

@@ -10,6 +10,7 @@
 #ifndef WINENVIRONMENT_H
 #define WINENVIRONMENT_H
 
+#include "cbase.h"
 #include <windows.h>
 
 #include "Environment.h"

+ 1 - 0
src/Engine/Platform/WinSWGraphicsInterface.h

@@ -10,6 +10,7 @@
 #ifndef WINSWGRAPHICSINTERFACE_H
 #define WINSWGRAPHICSINTERFACE_H
 
+#include "cbase.h"
 #include <Windows.h>
 
 #include "SWGraphicsInterface.h"

+ 2 - 0
src/Engine/Sound.h

@@ -1,5 +1,7 @@
 #pragma once
 
+#include "cbase.h"
+
 #define NOBASSOVERLOADS
 #include <bass.h>
 #include <bass_fx.h>

+ 1 - 1
src/Engine/SoundEngine.cpp

@@ -456,7 +456,7 @@ bool SoundEngine::initializeOutputDevice(OUTPUT_DEVICE device) {
         // BASS_WASAPI_EXCLUSIVE makes neosu have exclusive output to the sound card
         auto flags = BASS_WASAPI_RAW | BASS_MIXER_NONSTOP | BASS_WASAPI_EXCLUSIVE;
 
-        if(!BASS_WASAPI_Init(device.id, 0, 0, flags, bufferSize, updatePeriod, WASAPIPROC_BASS, g_bassOutputMixer)) {
+        if(!BASS_WASAPI_Init(device.id, 0, 0, flags, bufferSize, updatePeriod, WASAPIPROC_BASS, (void*)g_bassOutputMixer)) {
             const int errorCode = BASS_ErrorGetCode();
             if(errorCode == BASS_ERROR_WASAPI_BUFFER) {
                 debugLog("Sound Error: BASS_WASAPI_Init() failed with BASS_ERROR_WASAPI_BUFFER!");

+ 2 - 1
src/Engine/SoundEngine.h

@@ -8,8 +8,9 @@
 #ifndef SOUNDENGINE_H
 #define SOUNDENGINE_H
 
-#include "Sound.h"
 #include "cbase.h"
+// ^ needs to be before Sound.h on windows
+#include "Sound.h"
 
 enum class OutputDriver {
     NONE,

+ 2 - 12
src/GUI/CBaseUIElement.h

@@ -1,12 +1,5 @@
-//================ Copyright (c) 2013, PG, All rights reserved. =================//
-//
-// Purpose:		the base class for all UI Elements
-//
-// $NoKeywords: $buie
-//===============================================================================//
-
-#ifndef CBASEUIELEMENT_H
-#define CBASEUIELEMENT_H
+#pragma once
+#include "cbase.h"
 
 #define ELEMENT_BODY(T)                                          \
     virtual T *setPos(float xPos, float yPos) {                  \
@@ -381,7 +374,6 @@
     }
 
 #include "KeyboardListener.h"
-#include "cbase.h"
 
 class CBaseUIElement : public KeyboardListener {
    public:
@@ -473,5 +465,3 @@ class CBaseUIElement : public KeyboardListener {
     bool m_bMouseInsideCheck;
     bool m_bMouseUpCheck;
 };
-
-#endif

+ 12 - 0
src/Util/cbase.h

@@ -1,5 +1,12 @@
 #pragma once
 
+#ifdef _WIN32
+// #including <shlwapi.h> for strcasecmp and StrStrIA
+#include <winsock2.h>
+// winsock2.h must be included before windows.h
+#include <shlwapi.h>
+#endif
+
 // STD INCLUDES
 
 #include <math.h>
@@ -40,6 +47,11 @@
 #define NULL nullptr
 #endif
 
+#ifdef _WIN32
+#define reallocarray(ptr, a, b) realloc(ptr, a * b)
+#define strcasestr(a, b) StrStrIA(a, b)
+#endif
+
 typedef unsigned char COLORPART;
 
 #define SAFE_DELETE(p)  \