Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 6 additions & 13 deletions Headers/System/Graphics/GraphicsHelpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -301,24 +301,24 @@ namespace System::Graphics{
GLint y,
GLsizei width,
GLsizei height,
PixelFormat format,
PixelType type,
GLenum format,
GLenum type,
void* data) {
#if defined(SYSTEM_GRAPHICS_OPENGL)
SYSTEM_INTERNAL_glReadPixels(x,
y,
width,
height,
static_cast<GLenum>(format),
static_cast<GLenum>(type),
format,
type,
data);
#else
throw std::runtime_error("GraphicsHelpers gl function not implemented");
#endif
}
inline static void gl_glGetIntegerv(GLStateParam pname, GLint* data) {
inline static void gl_glGetIntegerv(GLenum pname, GLint* data) {
#if defined(SYSTEM_GRAPHICS_OPENGL)
SYSTEM_INTERNAL_glGetIntegerv(static_cast<GLenum>(pname), data);
SYSTEM_INTERNAL_glGetIntegerv(pname, data);
#else
throw std::runtime_error("GraphicsHelpers gl function not implemented");
#endif
Expand Down Expand Up @@ -509,13 +509,6 @@ namespace System::Graphics{
throw std::runtime_error("GraphicsHelpers gl function not implemented");
#endif
}
inline static void gl_glGetIntegerv(GLenum pname, GLint* data){
#if defined(SYSTEM_GRAPHICS_OPENGL)
SYSTEM_INTERNAL_glGetIntegerv( pname, data);
#else
throw std::runtime_error("GraphicsHelpers gl function not implemented");
#endif
}

inline static void gl_glUniform4f(GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3){
#if defined(SYSTEM_GRAPHICS_OPENGL)
Expand Down
3 changes: 3 additions & 0 deletions Headers/System/Internal/InternalGLloader.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ typedef int64_t GLint64EXT;
typedef struct __GLsync* GLsync;
#define GL_MINOR_VERSION 0x821C
#define GL_MAJOR_VERSION 0x821B
#define GL_VIEWPORT 0x0BA2
#define GL_RGBA 0x1908
#define GL_UNSIGNED_BYTE 0x1401



Expand Down
4 changes: 2 additions & 2 deletions Sources/System/Camera.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,14 @@ void System::Camera::RenderStart() const{
}
void Camera::TakeScreenshot(const std::string& filename) {
GLint viewport[4];
System::Graphics::GL::gl_glGetIntegerv(System::Graphics::GLStateParam::VIEWPORT, viewport);
System::Graphics::GL::gl_glGetIntegerv(GL_VIEWPORT, viewport);
int x = viewport[0];
int y = viewport[1];
int width = viewport[2];
int height = viewport[3];

Image image(width, height);
System::Graphics::GL::gl_glReadPixels(x, y, width, height, System::Graphics::PixelFormat::RGBA, System::Graphics::PixelType::UNSIGNED_BYTE, image.m_pixels.data());
System::Graphics::GL::gl_glReadPixels(x, y, width, height, GL_RGBA, GL_UNSIGNED_BYTE, image.m_pixels.data());
image.Flip();
image.Save(filename, Image::ImageFormat::BMP);
}
Expand Down
2 changes: 1 addition & 1 deletion Tests/scene_render/makefile
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ RELEASE_TARGET = scene_render_release
# Flags
DEBUG_FLAGS = $(INCLUDES) $(STANDARD) -g -DDEBUG -DSYSTEM_GRAPHICS_OPENGL
RELEASE_FLAGS = $(INCLUDES) $(STANDARD) -O3 -DNDEBUG -DSYSTEM_GRAPHICS_OPENGL
LDFLAGS = -lGL -ldl
LDFLAGS = -lGL -ldl -lglfw

# Default target
all: debug
Expand Down
19 changes: 16 additions & 3 deletions Tests/scene_render/scene_render.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,26 @@
#include <System/Shader.hpp>
#include <System/Texture2d.hpp>
#include <System/Graphics/GraphicsHelpers.h>
#include <GLFW/glfw3.h>

using namespace System::Graphics;

int main() {
glfwInit();
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
glfwWindowHint(GLFW_VISIBLE, GLFW_FALSE);

GLFWwindow* window = glfwCreateWindow(800, 600, "Test", NULL, NULL);
if (window == NULL) {
glfwTerminate();
return -1;
}
glfwMakeContextCurrent(window);

System::Scene::Initialize();
OpenGLVersion version;
OpenGLVersion version;
OpenGLInit(&version);
System::GameObject* cameraGO = new System::GameObject("Main Camera");
System::Camera* camera = cameraGO->AddComponent<System::Camera>();
Expand All @@ -30,12 +44,11 @@ int main() {
System::Scene scene;
scene.Run();



delete material;
delete shader;
delete cube;
delete cameraGO;

glfwTerminate();
return 0;
}
Binary file added Tests/scene_render/scene_render_debug
Binary file not shown.