Hi there I'm learning c++ so I'm not sure if this is a stupid mistake on my part. I'm trying to do something simple with raylib, I'm trying to simply clear the background by calling a method in a class. When I try to do this from the class, the window flickers horribly and sometimes freezes. But when it's called inside main it runs perfectly fine and acts like expected. I've programmed in lots of other languages before and I'm not quite sure why it should behave differently.
Here's the code:
main.cpp:
#include <iostream>
#include <string>
#include <array>
#include "Viewer.h"
#include <raylib.h>
using namespace std;
#define log(x) std::cout << x << std::endl
int main() {
int screenWidth = 800;
int screenHeight = 450;
InitWindow(screenWidth, screenHeight, "test");
Viewer* viewer = new Viewer();
while (!WindowShouldClose()) {
BeginDrawing();
//ClearBackground(DARKGRAY);
//DrawText("Congrats!", 190, 200, 20, LIGHTGRAY);
//DrawLine
viewer->draw();
EndDrawing();
}
delete viewer;
CloseWindow();
//cin.get();
}
viewer.cpp
#include <raylib.h>
class Viewer {
public:
void draw() {
ClearBackground(DARKGRAY);
}
};
viewer.h
#pragma once
class Viewer {
public:
void draw(){}
};
Extra info, I'm using Visual Studio 2019 and vckpg to manage libraries.