-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a29e158
commit 6992bcc
Showing
12 changed files
with
1,754 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
@echo off | ||
if exist .\build\ppLive.dll move .\build\ppLive.dll .\build\ppLive.%random%.dll | ||
cl .\live\ppUtils.c .\examples\live.c /I.\src /I.\live /MD /link /DLL /SUBSYSTEM:CONSOLE /out:.\build\ppLive.dll | ||
if exist .\build\pp.exe move .\build\pp.exe .\build\pp.%random%.exe | ||
cl .\src\ppWindows.c .\live\*.c /I.\src /I.\live Psapi.lib /link /SUBSYSTEM:CONSOLE /out:.\build\pp.exe | ||
del *.obj |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
headerdoc2html -udpb src/pp.h -o docs/ | ||
gatherheaderdoc docs | ||
mv docs/masterTOC.html docs/index.html |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
#include "ppLive.h" | ||
#include <time.h> | ||
#include <stdlib.h> | ||
|
||
struct ppState { | ||
ppColor clearColor; | ||
}; | ||
|
||
// Called once at the beginning of runtime | ||
static ppState* init(void) { | ||
ppState *state = malloc(sizeof(ppState)); | ||
if (!state) | ||
return NULL; | ||
state->clearColor = (ppColor){.r = 255, .g = 0, .b = 0}; | ||
return state; | ||
} | ||
|
||
// Called once at the end of runtime | ||
static void deinit(ppState *state) { | ||
if (!state) | ||
return; | ||
free(state); | ||
} | ||
|
||
// Called whenever the app is modified and reloaded | ||
static void reload(ppState *state) { | ||
} | ||
|
||
// Called just before the app is reloaded | ||
static void unload(ppState *state) { | ||
} | ||
|
||
static int event(ppState *state, ppEvent *e) { | ||
switch (e->type) { | ||
case ppKeyboardEvent: | ||
printf("Keyboard key %d is now %s\n", e->Keyboard.key, e->Keyboard.isdown ? "pressed" : "released"); | ||
break; | ||
case ppMouseButtonEvent: | ||
printf("Mouse button %d is now %s\n", e->Mouse.button, e->Mouse.isdown ? "pressed" : "released"); | ||
break; | ||
case ppMouseMoveEvent: | ||
printf("Mouse moved by %fx%f to %dx%d\n", e->Mouse.Position.dx, e->Mouse.Position.dy, e->Mouse.Position.x, e->Mouse.Position.y); | ||
break; | ||
case ppMouseScrollEvent: | ||
printf("Mouse scrolled by %fx%f\n", e->Mouse.Scroll.dx, e->Mouse.Scroll.dy); | ||
break; | ||
case ppResizedEvent: | ||
printf("Window has resized to %dx%d\n", e->Window.Size.width, e->Window.Size.height); | ||
break; | ||
case ppFocusEvent: | ||
printf("Window is now %s\n", e->Window.focused ? "focused" : "blured"); | ||
break; | ||
case ppClosedEvent: | ||
printf("Window closed\n"); | ||
return 0; | ||
} | ||
return 1; | ||
} | ||
|
||
// Called every frame | ||
static int tick(ppState *state, ppSurface *frame, double delta) { | ||
ppClearSurface(frame, state->clearColor); | ||
return 1; | ||
} | ||
|
||
// App descriptor to direct callbacks | ||
// Must be called "pp" as that is the symbol that is looked up | ||
EXPORT const ppApp pp = { | ||
.init = init, | ||
.deinit = deinit, | ||
.reload = reload, | ||
.unload = unload, | ||
.event = event, | ||
.tick = tick | ||
}; |
Oops, something went wrong.