Update README
This commit is contained in:
parent
2b4bd4158f
commit
b4e2c43852
|
@ -3,7 +3,9 @@ project(chip8)
|
||||||
|
|
||||||
set(CMAKE_CXX_STANDARD 11)
|
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(
|
add_executable(
|
||||||
chip8
|
chip8
|
||||||
|
@ -13,4 +15,5 @@ add_executable(
|
||||||
|
|
||||||
target_compile_options(chip8 PRIVATE -Wall)
|
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.
|
A simple emulator for the CHIP-8.
|
||||||
|
|
||||||
|
|
|
@ -1,17 +1,34 @@
|
||||||
#include "Platform.hpp"
|
#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)
|
Platform::Platform(char const* title, int windowWidth, int windowHeight, int textureWidth, int textureHeight)
|
||||||
{
|
{
|
||||||
SDL_Init(SDL_INIT_VIDEO);
|
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(
|
gl_context = SDL_GL_CreateContext(window);
|
||||||
renderer, SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_STREAMING, textureWidth, textureHeight);
|
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()
|
Platform::~Platform()
|
||||||
|
|
|
@ -1,15 +1,14 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
#include <SDL.h>
|
||||||
|
#include <glad/gl.h>
|
||||||
class SDL_Window;
|
|
||||||
class SDL_Renderer;
|
|
||||||
class SDL_Texture;
|
|
||||||
|
|
||||||
|
|
||||||
class Platform
|
class Platform
|
||||||
{
|
{
|
||||||
|
friend class Imgui;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Platform(char const* title, int windowWidth, int windowHeight, int textureWidth, int textureHeight);
|
Platform(char const* title, int windowWidth, int windowHeight, int textureWidth, int textureHeight);
|
||||||
~Platform();
|
~Platform();
|
||||||
|
@ -18,6 +17,8 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
SDL_Window* window{};
|
SDL_Window* window{};
|
||||||
|
SDL_GLContext gl_context{};
|
||||||
|
GLuint framebuffer_texture;
|
||||||
SDL_Renderer* renderer{};
|
SDL_Renderer* renderer{};
|
||||||
SDL_Texture* texture{};
|
SDL_Texture* texture{};
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue