1
0
Fork 0

Update README

master
Austin Morlan 1 month ago
parent 2b4bd4158f
commit b4e2c43852
Signed by: austin
GPG Key ID: FD6B27654AF5E348
  1. 7
      CMakeLists.txt
  2. 2
      README.md
  3. 31
      Source/Platform.cpp
  4. 11
      Source/Platform.hpp

@ -3,7 +3,9 @@ project(chip8)
set(CMAKE_CXX_STANDARD 11)
find_package(SDL2 REQUIRED)
add_subdirectory(3rdParty/glad EXCLUDE_FROM_ALL)
add_subdirectory(3rdParty/sdl-2.0.20 EXCLUDE_FROM_ALL)
add_subdirectory(3rdParty/imgui-1.88 EXCLUDE_FROM_ALL)
add_executable(
chip8
@ -13,4 +15,5 @@ add_executable(
target_compile_options(chip8 PRIVATE -Wall)
target_link_libraries(chip8 PRIVATE SDL2::SDL2)
target_link_libraries(chip8 PRIVATE glad SDL2 imgui)

@ -1,4 +1,4 @@
# CHIP-8 Emulator
# CHIP-8 Emulator (2019)
A simple emulator for the CHIP-8.

@ -1,17 +1,34 @@
#include "Platform.hpp"
#include <SDL2/SDL.h>
#include <glad/gl.h>
#include <SDL.h>
Platform::Platform(char const* title, int windowWidth, int windowHeight, int textureWidth, int textureHeight)
{
SDL_Init(SDL_INIT_VIDEO);
window = SDL_CreateWindow(title, 0, 0, windowWidth, windowHeight, SDL_WINDOW_SHOWN);
renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED);
texture = SDL_CreateTexture(
renderer, SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_STREAMING, textureWidth, textureHeight);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 3);
window = SDL_CreateWindow(
title,
SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED,
windowWidth, windowHeight,
SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE);
gl_context = SDL_GL_CreateContext(window);
SDL_GL_SetSwapInterval(1);
gladLoadGL((GLADloadfunc)SDL_GL_GetProcAddress);
glGenTextures(1, &framebuffer_texture);
glBindTexture(GL_TEXTURE_2D, framebuffer_texture);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 640, 320, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
glBindTexture(GL_TEXTURE_2D, 0);
}
Platform::~Platform()

@ -1,15 +1,14 @@
#pragma once
#include <cstdint>
class SDL_Window;
class SDL_Renderer;
class SDL_Texture;
#include <SDL.h>
#include <glad/gl.h>
class Platform
{
friend class Imgui;
public:
Platform(char const* title, int windowWidth, int windowHeight, int textureWidth, int textureHeight);
~Platform();
@ -18,6 +17,8 @@ public:
private:
SDL_Window* window{};
SDL_GLContext gl_context{};
GLuint framebuffer_texture;
SDL_Renderer* renderer{};
SDL_Texture* texture{};
};

Loading…
Cancel
Save