Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <Scene/Scene.h>
- #include <Input/Input.h>
- #include <Scene/ComponentMeshRenderer.h>
- #include <Graphics/OpenGL/DeviceOpenGL.h>
- #include <Graphics/OpenGL/WindowOpenGLSDL.h>
- #include <Editor/Editor.h>
- #include <Profiling/Profiling.h>
- #include <Input/EventSystem.h>
- //#include <Graphics/Vulkan/InstanceVulkan.h>
- using namespace Columbus;
- #include <imgui/imgui.h>
- #include <imgui/examples/imgui_impl_opengl3.h>
- #include <imgui/examples/imgui_impl_sdl.h>
- #include <ImGuizmo/ImGuizmo.h>
- #include <Windows.h>
- #include <Lib\GLEW\include\GL\wglew.h>
- #include <Graphics/OpenGL/ShaderOpenGL.h>
- #ifdef PLATFORM_WINDOWS
- //Hint to the driver to use discrete GPU
- extern "C"
- {
- //NVIDIA
- __declspec(dllexport) int NvOptimusEnablement = 1;
- //AMD
- __declspec(dllexport) int AmdPowerXpressRequestHighPerformance = 1;
- }
- #endif
- //#define COLUMBUS_EDITOR
- HWND hwnd;
- HDC hdc;
- HGLRC hrc;
- bool quit = false;
- const char* class_name = "Columbus Engine Window Class";
- LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wparam, LPARAM lparam)
- {
- switch (msg)
- {
- default:
- DefWindowProc(hWnd, msg, wparam, lparam);
- }
- return 0;
- }
- #define main main
- int main(int argc, char** argv)
- {
- HINSTANCE hInstance = GetModuleHandle(0);
- WNDCLASS wc = { 0 };
- wc.style = CS_OWNDC | CS_HREDRAW | CS_VREDRAW;
- wc.lpfnWndProc = WndProc;
- wc.cbClsExtra = 0;
- wc.cbWndExtra = 0;
- wc.hInstance = hInstance;
- wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
- wc.hCursor = LoadCursor(NULL, IDC_ARROW);
- wc.lpszMenuName = NULL;
- wc.lpszClassName = class_name;
- if (!RegisterClass(&wc))
- COLUMBUS_ASSERT(false);
- hwnd = CreateWindow(class_name, "Columbus Engine", WS_OVERLAPPEDWINDOW, 0, 0, 640, 480, 0, 0, hInstance, 0);
- PIXELFORMATDESCRIPTOR pfd;
- memset(&pfd, 0, sizeof(pfd));
- pfd.nSize = sizeof(pfd);
- pfd.nVersion = 1;
- pfd.dwFlags = PFD_DOUBLEBUFFER | PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL;
- pfd.iPixelType = PFD_TYPE_RGBA;
- pfd.cColorBits = 32;
- pfd.cDepthBits = 24;
- pfd.cStencilBits = 8;
- pfd.iLayerType = PFD_MAIN_PLANE;
- hdc = GetDC(hwnd);
- int fmt = ChoosePixelFormat(hdc, &pfd);
- COLUMBUS_ASSERT(fmt != 0);
- if (SetPixelFormat(hdc, fmt, &pfd) != TRUE) COLUMBUS_ASSERT(false);
- hrc = wglCreateContext(hdc);
- wglMakeCurrent(hdc, hrc);
- printf("%s\n", glGetString(GL_VERSION));
- SetWindowLongA(hwnd, GWLP_WNDPROC, (LONG)&WndProc);
- ShowWindow(hwnd, SW_NORMAL);
- glewInit();
- gDevice = new DeviceOpenGL();
- gDevice->Initialize();
- auto tex = gDevice->CreateTexture();
- tex->Load("Data/Skyboxes/Dawn.exr");
- auto sky = new Skybox(tex);
- ScreenQuad q;
- MSG msg;
- while (!quit)
- {
- if (PeekMessage(&msg, 0, 0, 0, PM_REMOVE))
- {
- TranslateMessage(&msg);
- DispatchMessage(&msg);
- if (msg.message == WM_QUIT) quit = true;
- }
- else
- {
- glClearColor(1, 0, 0, 1);
- glClear(GL_COLOR_BUFFER_BIT);
- /*glBegin(GL_TRIANGLES);
- glVertex2f(-1, 0);
- glVertex2f(1, 0);
- glVertex2f(0, 1);
- glEnd();*/
- glViewport(0, 0, 640, 480);
- //((TextureOpenGL*)tex)->Bind();
- //asd->Bind()
- Camera cam;
- cam.Perspective(60, 640.0f / 480.0f, 0.1, 1000);
- cam.Update();
- sky->SetCamera(cam);
- sky->Render();
- SwapBuffers(hdc);
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment