소스 검색

update

tags/day-25
Ledda 4 달 전
부모
커밋
b37f0e1b8f
2개의 변경된 파일6개의 추가작업 그리고 30개의 파일을 삭제
  1. +5
    -3
      src/handmade.cpp
  2. +1
    -27
      src/win32_handmade.cpp

+ 5
- 3
src/handmade.cpp 파일 보기

@@ -12,10 +12,9 @@ void debug_printf(wchar_t* format, ...) {
free(output);
}

internal void outputSound(GameSoundOutputBuffer *soundBuffer) {
internal void outputSound(GameSoundOutputBuffer *soundBuffer, int toneHz) {
local_persist real32 tSine;
int16 toneVolume = 3000;
int toneHz = 440;
int wavePeriod = soundBuffer->samplesPerSecond/toneHz;

int16 *sampleOut = soundBuffer->samples;
@@ -43,6 +42,9 @@ internal void renderWeirdGradient(GameOffscreenBuffer *buffer, int xOffset, int
}

internal void gameUpdateAndRender(GameOffscreenBuffer *videoBuf, GameInput *input, GameSoundOutputBuffer *soundBuf) {
outputSound(soundBuf);
local_persist int greenOffset = 0;
local_persist int blueOffset = 0;
local_persist int toneHz = 440;
outputSound(soundBuf, toneHz);
renderWeirdGradient(videoBuf, input->xOffset, input->yOffset);
}

+ 1
- 27
src/win32_handmade.cpp 파일 보기

@@ -3,21 +3,9 @@
#include <Xinput.h>
#include <dsound.h>

#include "win32_handmade.h"
#include "handmade.cpp"

struct Win32OffscreenBuffer {
BITMAPINFO info;
void *memory;
int width;
int height;
int bytesPerPixel;
};

struct Win32WindowDimensions {
int width;
int height;
};

global ATOM HH_CTRLW;
global bool running;
global Win32OffscreenBuffer globalBackBuffer;
@@ -216,18 +204,6 @@ LRESULT mainWindowCallback(
return result;
}

struct Win32SoundOutput {
int samplesPerSecond;
int toneHz;
int wavePeriod;
int16 toneVolume;
uint32 runningSampleIndex;
int bytesPerSample;
int secondaryBufferSize;
real32 tSine;
int latencySampleCount;
};

internal void win32ClearBuffer(Win32SoundOutput *soundOutput) {
VOID *region1;
DWORD region1Size;
@@ -321,9 +297,7 @@ int APIENTRY WinMain(HINSTANCE instance, HINSTANCE prevInstance, PSTR commandLin
// sound test
Win32SoundOutput soundOutput = {};
soundOutput.samplesPerSecond = 48000;
soundOutput.toneHz = 440; // A above middle C
soundOutput.wavePeriod = soundOutput.samplesPerSecond / soundOutput.toneHz;
soundOutput.toneVolume = 6000;
soundOutput.runningSampleIndex = 0;
soundOutput.bytesPerSample = sizeof(int16)*2;
soundOutput.secondaryBufferSize = soundOutput.samplesPerSecond*soundOutput.bytesPerSample;


불러오는 중...
취소
저장