1
0
Fork 0

Update README

This commit is contained in:
Austin Morlan 2022-10-28 13:58:52 -07:00
parent 2b4bd4158f
commit b4e2c43852
Signed by: austin
GPG Key ID: FD6B27654AF5E348
4 changed files with 34 additions and 13 deletions

View File

@ -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)

View File

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

View File

@ -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);
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);
renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED);
window = SDL_CreateWindow(
title,
SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED,
windowWidth, windowHeight,
SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE);
texture = SDL_CreateTexture(
renderer, SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_STREAMING, textureWidth, textureHeight);
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()

View File

@ -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{};
};