Skip to content

Commit

Permalink
update examples
Browse files Browse the repository at this point in the history
  • Loading branch information
ColleagueRiley committed Jan 7, 2025
1 parent a49a166 commit 0d275db
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
13 changes: 8 additions & 5 deletions RGFW.h
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,6 @@ int main() {

#if defined(_WIN32) && !defined(RGFW_X11) && !defined(RGFW_WEBASM) /* (if you're using X11 on windows some how) */
#define RGFW_WINDOWS
#define RGFW_PROC_DEF(proc, name) if (name##SRC == NULL && proc != NULL) name##SRC = (PFN_##name)GetProcAddress(proc, #name)
/* make sure the correct architecture is defined */
#if defined(_WIN64)
#define _AMD64_
Expand Down Expand Up @@ -363,8 +362,6 @@ int main() {
#define RGFW_MACOS_X11
#define RGFW_X11
#include <X11/Xlib.h>

#define RGFW_PROC_DEF(proc, name) if (name##SRC == NULL) name##SRC = (name##PROC)dlsym(proc, #name)
#elif defined(__APPLE__) && !defined(RGFW_MACOS_X11) && !defined(RGFW_X11) && !defined(RGFW_WEBASM)
#define RGFW_MACOS
#endif
Expand Down Expand Up @@ -5443,6 +5440,8 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
__declspec(dllimport) u32 __stdcall timeBeginPeriod(u32 uPeriod);
#endif

#define RGFW_PROC_DEF(proc, name) if (name##SRC == NULL && proc != NULL) name##SRC = (PFN_##name)(void*)GetProcAddress(proc, #name)

#ifndef RGFW_NO_XINPUT
void RGFW_loadXInput(void) {
u32 i;
Expand Down Expand Up @@ -5625,15 +5624,19 @@ RGFW_window* RGFW_createWindow(const char* name, RGFW_rect rect, RGFW_windowArgs
RGFW_ASSERT(FAILED(CreateDXGIFactory(&__uuidof(IDXGIFactory), (void**) &RGFW_dxInfo.pFactory)) == 0);

if (FAILED(RGFW_dxInfo.pFactory->lpVtbl->EnumAdapters(RGFW_dxInfo.pFactory, 0, &RGFW_dxInfo.pAdapter))) {
fprintf(stderr, "Failed to enumerate DXGI adapters\n");
#ifdef RGFW_DEBUG
fprintf(stderr, "Failed to enumerate DXGI adapters\n");
#endif
RGFW_dxInfo.pFactory->lpVtbl->Release(RGFW_dxInfo.pFactory);
return NULL;
}

D3D_FEATURE_LEVEL featureLevels[] = { D3D_FEATURE_LEVEL_11_0 };

if (FAILED(D3D11CreateDevice(RGFW_dxInfo.pAdapter, D3D_DRIVER_TYPE_UNKNOWN, NULL, 0, featureLevels, 1, D3D11_SDK_VERSION, &RGFW_dxInfo.pDevice, NULL, &RGFW_dxInfo.pDeviceContext))) {
fprintf(stderr, "Failed to create Direct3D device\n");
#ifdef RGFW_DEBUG
fprintf(stderr, "Failed to create Direct3D device\n");
#endif
RGFW_dxInfo.pAdapter->lpVtbl->Release(RGFW_dxInfo.pAdapter);
RGFW_dxInfo.pFactory->lpVtbl->Release(RGFW_dxInfo.pFactory);
return NULL;
Expand Down
3 changes: 2 additions & 1 deletion examples/dx11/dx11.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#define RGFW_IMPLEMENTATION
#define RGFW_DIRECTX
#define RGFW_DEBUG
#include "RGFW.h"

#define MULTILINE_STR(...) #__VA_ARGS__
Expand Down Expand Up @@ -28,7 +29,7 @@ const char* shaderString = MULTILINE_STR(
);

int main(void) {
RGFW_window* win = RGFW_createWindow("name", RGFW_RECT(0, 0, 500, 500), RGFW_CENTER);
RGFW_window* win = RGFW_createWindow("name", RGFW_RECT(0, 0, 500, 500), RGFW_center);
RGFW_window_makeCurrent(win);

RGFW_directXinfo* dxInfo = RGFW_getDirectXInfo();
Expand Down
2 changes: 2 additions & 0 deletions examples/events/events.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#define RGFW_IMPLEMENTATION
#include "RGFW.h"

#include <stdio.h>

int main(void) {
RGFW_window* win = RGFW_createWindow("RGFW Events", RGFW_RECT(500, 500, 500, 500), RGFW_center | RGFW_allowDND | RGFW_transparent);

Expand Down

0 comments on commit 0d275db

Please sign in to comment.