Skip to content

Instantly share code, notes, and snippets.

@untodesu
Created December 1, 2019 12:41
Show Gist options
  • Save untodesu/201b403278073e01c5c57089253697d0 to your computer and use it in GitHub Desktop.
Save untodesu/201b403278073e01c5c57089253697d0 to your computer and use it in GitHub Desktop.
//...
//================================
// Graphics interface
//================================
class IGraphics {
public:
//================================
// Load texture and get it's ID
//================================
virtual TextureID LoadTexture(const std::string &filename) = 0;
//================================
// Unload existing texture
//================================
virtual void UnloadTexture(TextureID tex) = 0;
//================================
// Unload all loaded textures
//================================
virtual void UnloadAllTextures(void) = 0;
//================================
// Draw textured rectangle
//================================
virtual void DrawTexturedRect(int x, int y, int w, int h, TextureID tex) = 0;
//================================
// Draw colored rectangle
//================================
virtual void DrawRect(int x, int y, int w, int h, int t, Color border, Color inside) = 0;
//================================
// Draw colored line
//================================
virtual void DrawLine(int x1, int y1, int x2, int y2, Color color) = 0;
//================================
// Set default colors
//================================
virtual void SetupDefaultColors(Color background, Color foreground) = 0;
//================================
// Clear screen with default color
//================================
virtual void ClearScreen(void) = 0;
//================================
// Clear screen
//================================
virtual void ClearScreen(Color color) = 0;
};
//================================
// Audio interface (WAV only!)
//================================
class IAudio {
public:
//================================
// Load sound and get it's ID
//================================
virtual SoundID LoadSound(const std::string &filename) = 0;
//================================
// Unload previously loaded sound
//===============================
virtual void UnloadSound(SoundID snd) = 0;
//================================
// Unload all previously loaded sounds
//===============================
virtual void UnloadAllSounds(void) = 0;
//================================
// Set sound volume
//================================
virtual void SetSoundVolume(SoundID snd, int left, int right) = 0;
//================================
// Actually emit sound
//================================
virtual void EmitSound(SoundID snd) = 0;
};
//...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment