Commit ad313c25 authored by James Fulop's avatar James Fulop
Browse files

took 0.5 - 1 seconds off overall compile time

parent c43e9eb1
......@@ -7,8 +7,8 @@
#include "prof_process.c"
#include "imgui.cpp"
#include "imgui_draw.cpp"
#include "imgui_demo.cpp" // NOTE(james): this console depends on stuff in here
// For the console example, here we are using a more C++ like approach of declaring a class to hold the data and the functions.
// NOTE(imgui):For the console example, here we are using a more C++ like approach of declaring a class to hold the data and the functions.
struct YamgineConsole
{
char InputBuf[256];
......@@ -172,7 +172,7 @@ struct YamgineConsole
}
static int TextEditCallbackStub(ImGuiTextEditCallbackData* data) // In C++11 you are better off using lambdas for this sort of forwarding callbacks
{
ExampleAppConsole* console = (ExampleAppConsole*)data->UserData;
YamgineConsole* console = (YamgineConsole*)data->UserData;
return console->TextEditCallback(data);
}
int TextEditCallback(ImGuiTextEditCallbackData* data)
......@@ -396,7 +396,7 @@ void LoadCustomAssets(render_assets* Assets, memory_arena* AssetArena, platform_
#endif
}
#ifdef FMOD_SUPPORT
//TODO(james): compile these out on deploy builds
void (*Common_Private_Error)(FMOD_RESULT, const char *, int);
......@@ -414,7 +414,7 @@ void ERRCHECK_fn(FMOD_RESULT result, const char *file, int line)
//Common_Fatal("%s(%d): FMOD error %d - %s", file, line, result, FMOD_ErrorString(result));
}
}
#endif
////////////////////////////////////////////////////
// IMGUI
......@@ -531,7 +531,7 @@ void CharacterController(entity* Entity, v2 MoveDirectionXZ, bool32 JumpHit, flo
}
#define NETWORKING 0
void GameMode(game_and_editor_memory* Memory, memory_arena* TransientArena,
fmod_state* FmodState, platform_api* PlatformAPI,
platform_api* PlatformAPI,
render_list* EditorList, render_list* RenderList,
game_input* Input, bool32 IsFocused)
{
......@@ -593,7 +593,7 @@ void GameMode(game_and_editor_memory* Memory, memory_arena* TransientArena,
}
#ifdef FMOD_SUPPORT
//TODO(james): add in velocity, forward, and up
FMOD_3D_ATTRIBUTES PlayerAttributes = {{0}};//init to zero?
PlayerAttributes.position.x = GameState->Player->LocalPosition.x;
......@@ -602,6 +602,7 @@ void GameMode(game_and_editor_memory* Memory, memory_arena* TransientArena,
int PlayerIndex = 0;// TODO(james): adjust for multiplayer!!
//FMOD_Studio_System_SetListenerAttributes(FmodState->StudioSystem, PlayerIndex, &PlayerAttributes);
#endif
//DrawDebugXZGrid(RenderList);
......@@ -925,8 +926,7 @@ if (Input->Controllers[0].Action1.DownThisFrame)
SetWindowFocus();
}
EditorMode(GameAndEditorMemory, &TransientArena,
&Memory->FmodState, &Memory->PlatformAPI, Memory->RenderDocAPI,
EditorMode(GameAndEditorMemory, &TransientArena, &Memory->PlatformAPI, Memory->RenderDocAPI,
EditorList, Input);
}
ImGui::EndDock();
......@@ -1036,7 +1036,7 @@ if (Input->Controllers[0].Action1.DownThisFrame)
if (ImGui::BeginDock("Asset Browser"))
{
AssetBrowser(GameAndEditorMemory, &TransientArena, &Memory->FmodState, &Memory->PlatformAPI,
AssetBrowser(GameAndEditorMemory, &TransientArena, &Memory->PlatformAPI,
EditorList, Input);
}
ImGui::EndDock();
......@@ -1113,7 +1113,7 @@ if (Input->Controllers[0].Action1.DownThisFrame)
ImGui::End();
GameMode(GameAndEditorMemory, &TransientArena, &Memory->FmodState, &Memory->PlatformAPI,
GameMode(GameAndEditorMemory, &TransientArena, &Memory->PlatformAPI,
EditorList, GameList, Input, IsGameWindowFocused);
DrawImGui(EditorList);
......
......@@ -9,10 +9,12 @@
#define Prof_ENABLED
#include "prof.h"
#ifdef FMOD_SUPPORT
#include "fmod_studio.h"
#endif
#include "yamgine_memory_arena.h"
#include "yamgine_collision.h"
#include "yamgine_render_list.h"
#include "yamgine_entity.h"
......
......@@ -1174,7 +1174,6 @@ void ModelAssetGui(mesh* Mesh, mesh** SelectedMesh, mesh** DroppedOnMesh,
void AssetBrowser(game_and_editor_memory* Memory,
memory_arena* TransientArena,
fmod_state* FmodState,
platform_api* PlatformAPI,
render_list* RenderList,
game_input* Input)
......@@ -1260,7 +1259,6 @@ void InstantiateMeshAssetInstance(entity_master* EntityMaster, mesh* Mesh, entit
}
void EditorMode(game_and_editor_memory* Memory, memory_arena* TransientArena,
fmod_state* FmodState,
platform_api* PlatformAPI,
RENDERDOC_API_1_1_1* RenderDocAPI,
render_list* RenderList, game_input* Input)
......
......@@ -351,6 +351,7 @@ introspect(category:"math") typedef struct aabb
serialize("param") v3 HalfWidths;
} aabb;
#ifdef FMOD_SUPPORT
#include "fmod_studio.h"
typedef struct fmod_state
{
......@@ -359,7 +360,7 @@ typedef struct fmod_state
FMOD_STUDIO_EVENTDESCRIPTION* MusicEvent;
FMOD_STUDIO_EVENTDESCRIPTION* MouseClickEvent;
} fmod_state;
#endif
typedef struct game_button_state
{
......@@ -568,7 +569,9 @@ typedef struct game_memory
{
char ExecutableFolder[255];//max_path
#ifdef FMOD_SUPPORT
fmod_state FmodState;//maybe make this another param of GameUpdateAndRender?
#endif
platform_api PlatformAPI;
......
#include "platform_win32.h"
#include "imgui.h"
#include <stdio.h>//for _snprintf_s
global_variable char DLL_FILE_NAME[] = "yamgine.dll";
......@@ -95,8 +91,6 @@ global_variable bool32 OpenGLSupportsSRGBFramebuffer;
#define WGL_SAMPLES_ARB 0x2042
global_variable bool32 OpenGLSupportsMultisampling;
#include "yamgine_shared.h"
global_variable gl_code* GlobalGLCode;
global_variable gl_state* GlobalGLState;
......@@ -1167,7 +1161,7 @@ Win32InitOpenGL(HDC WindowDC, gl_state* GLState, gl_code* GLCode)
////////////////////////////////////////////////////
// FMOD
////////////////////////////////////////////////////
#ifdef FMOD_SUPPORT
void (*Common_Private_Error)(FMOD_RESULT, const char *, int);
#define ERRCHECK(_result) ERRCHECK_fn(_result, __FILE__, __LINE__)
......@@ -1306,7 +1300,7 @@ void InitFmod(fmod_state* State, char* ExecutableFolder)
ERRCHECK( FMOD_Studio_System_GetEvent(State->StudioSystem, "event:/ButtonPress", &State->MouseClickEvent) );
}
#endif
////////////////////////////////////////////////////
......
#if !defined(PLATFORM_WIN32_H)
#include "platform_agnostic.h"
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include "renderer_opengl.h"// includes a lot of our other code as well, plus windows.h
#include <xinput.h>
//#include "gl/gl.h"
#include "renderer_opengl.h"
struct win32_replay_buffer
{
HANDLE FileHandle;
......
#if !defined(RENDERER_OPENGL_H)
#include "platform_agnostic.h"
#define WIN32_LEAN_AND_MEAN
#include <windows.h> // gl.h depends on this? WTF?
#include "gl/gl.h"
#include "yamgine_shared.h"
/* NOTE(james):
This file contains commands that are OpenGL only. Platform specific context
creation should occur in the platform layer. Should just need to pass an Init function
......@@ -85,12 +87,10 @@ struct gl_render_contexts
bool32 IsEditor;
};
#include "yamgine_shared.h"
#include "yamgine_render_list.h"
//TODO(james): annoying to have to recompile these
#include "imgui.h"
//#include "imgui.h"
#define Prof_ENABLED
#include "prof.h"
......
//#define TEXTURE
//#define RECIEVE_SHADOWS
//#define LIGHTING
//vert
layout(location = 0) in vec3 PositionIn;
layout(location = 1) in vec3 NormalIn;
#ifdef TEXTURE
layout(location = 2) in vec2 TexCoordsIn;
#endif
uniform mat4 Model;
uniform mat4 View;
uniform mat4 Projection;
uniform mat4 LightSpaceMatrix;
VERT_TO_FRAG
{
vec3 Normal;
vec4 FragPosLightSpace;
#ifdef TEXTURE
vec2 TexCoord;
#endif
};
void VERT()
{
gl_Position =Projection * View * Model* vec4(PositionIn,1.0);
VERT_TO_FRAG.Normal = mat3(transpose(inverse(Model))) * NormalIn;//TODO(james): move this to CPU, pass as uniform
VERT_TO_FRAG.FragPosLightSpace = LightSpaceMatrix * Model * vec4(PositionIn, 1.0);
#ifdef TEXTURE
VERT_TO_FRAG.TexCoord = TexCoordsIn;
#endif
}
//
// frag
//
uniform vec4 ObjectColor;
uniform vec3 LightDir;
uniform vec3 LightColor;
uniform sampler2DShadow ShadowMapTexture;
#ifdef TEXTURE
uniform sampler2D Texture;
#endif
out vec4 OutColor;
// NOTE(james): returns 1 if in shadow, 0 if not
float ShadowCalculations(vec4 FragPosLightSpace)
{
float CosTheta = clamp(dot(VERT_TO_FRAG.Normal, LightDir), 0, 1);
float Bias = 0.005*tan(acos(CosTheta));
Bias = clamp(Bias, 0,0.01);
FragPosLightSpace.z -= Bias;
vec3 ProjCoords = FragPosLightSpace.xyz / FragPosLightSpace.w;
ProjCoords = ProjCoords * 0.5f + 0.5f;//[-1,1] to [0,1]
float ClosestDepth = texture(ShadowMapTexture, ProjCoords);
float CurrentDepth = ProjCoords.z;
float Shadow = 1;
Shadow -= ClosestDepth;
if (ProjCoords.z > 1)
{
Shadow = 1;
}
return Shadow;
}
void FRAG()
{
float AmbientStrength = 0.15f;
vec3 Ambient = AmbientStrength * LightColor;
vec3 Norm = normalize(VERT_TO_FRAG.Normal);
float Diff = max(dot(Norm, LightDir), 0.0);
vec3 Diffuse = Diff * LightColor;
vec3 ViewDir = normalize(LightDir);
float Spec = 0.0;
vec3 HalfwayDir = normalize(LightDir + ViewDir);
Spec = pow(max(dot(Norm, HalfwayDir), 0.0), 64.0);
vec3 Specular = Spec * LightColor;
float InShadowAmount = ShadowCalculations(VERT_TO_FRAG.FragPosLightSpace);
#ifdef TEXTURE
vec3 Result = (Ambient + (1.0 - InShadowAmount) * (Diffuse + Specular)) * (ObjectColor.xyz * texture(Texture, VERT_TO_FRAG.TexCoord).xyz);
#else
vec3 Result = (Ambient + (1.0 - InShadowAmount) * (Diffuse + Specular)) * (ObjectColor.xyz);
#endif
OutColor = vec4(Result, ObjectColor.a);
}
\ No newline at end of file
#if !defined(YAMGINE_META_H)
#include <stdio.h>
enum meta_type
{
MetaType_uint32,
......
#if !defined(YAMGINE_RENDER_LIST_H)
//#include "yamgine_shared.h"
/* TODO(james):
-I think when we have multiple cameras, I think they will all have separate render groups
-For any position based drawing, maybe we should do AABB frustom intersection checking before adding them to list?
*/
//#include "yamgine_transform.h"
enum render_group_entry_type
{
RenderGroupEntryType_render_entry_clear,
......
#include "yamgine_generated.h"
#include "yamgine_meta.h"
#include "yamgine_string.h"
#include <stdlib.h>//atoi
#define STB_SPRINTF_IMPLEMENTATION
#include "stb_printf.h"
......
#if !defined(YAMGINE_SHARED_H)
//#include "yamgine_intrinsics.h"
#include "platform_agnostic.h"
#include "yamgine_math.h"
#include "yamgine_string.h"
#include "yamgine_transform.h"
#include "yamgine_render_list.h"
#define YAMGINE_SHARED_H
#endif
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment