Update README
This commit is contained in:
4 files changed
+34
-13
No files matched your search
+22
-5
@@ -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()
|
||||
|
||||
+6
-5
@@ -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{};
|
||||
};
|
||||
Reference in new issue
Block a user