colobot/colobot-base/graphics/opengl33/glutil.h

107 lines
3.0 KiB
C
Raw Permalink Normal View History

/*
* This file is part of the Colobot: Gold Edition source code
2021-09-11 13:52:34 +00:00
* Copyright (C) 2001-2021, Daniel Roux, EPSITEC SA & TerranovaTeam
2015-08-22 14:40:02 +00:00
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see http://gnu.org/licenses
*/
#pragma once
// config.h must be included first
2015-05-19 21:02:54 +00:00
#include "common/config.h"
#include <GL/glew.h>
#include <glm/glm.hpp>
2015-05-19 21:02:54 +00:00
#include <string>
#include <memory>
#include <vector>
2016-03-17 21:45:03 +00:00
struct SDL_Surface;
class CImage;
struct ImageData;
// Graphics module namespace
namespace Gfx
{
class CDevice;
class CFrameBufferPixels;
struct DeviceConfig;
enum class PrimitiveType : unsigned char;
enum class Type : unsigned char;
enum class TextureFormat : unsigned char;
bool InitializeGLEW();
//! Creates OpenGL device
std::unique_ptr<CDevice> CreateDevice(const DeviceConfig &config, const std::string& name);
//! Returns OpenGL version
// \return First digit is major part, second digit is minor part.
int GetOpenGLVersion();
//! Returns OpenGL version
// \return First digit is major part, second digit is minor part.
int GetOpenGLVersion(int &major, int &minor);
2016-02-18 11:20:40 +00:00
//! Checks if extensions in space-delimited list are supported
// \return true if all extensions are supported
bool AreExtensionsSupported(std::string list);
//! Returns information about graphics card
std::string GetHardwareInfo(bool full = false);
//! Clears OpenGL errors
int ClearGLErrors();
//! Checks for OpenGL errors
bool CheckGLErrors();
//! Translate Gfx primitive type to OpenGL primitive type
GLenum TranslateGfxPrimitive(PrimitiveType type);
bool InPlane(glm::vec3 normal, float originPlane, glm::vec3 center, float radius);
GLenum TranslateType(Type type);
std::string GetLastShaderError();
std::string LoadSource(const std::string& path);
GLint CreateShader(GLint type, const std::vector<std::string>& sources);
2015-06-01 15:21:10 +00:00
GLint LoadShader(GLint type, const char* filename);
GLint LinkProgram(int count, const GLint* shaders);
2015-06-01 15:21:10 +00:00
GLint LinkProgram(const std::vector<GLint>& shaders);
2016-03-17 21:45:03 +00:00
// TODO: Moved this here temporarily only to remove code duplication in CGLDeviceXX
struct PreparedTextureData
{
SDL_Surface* actualSurface = nullptr;
SDL_Surface* convertedSurface = nullptr;
GLenum sourceFormat = 0;
bool alpha = false;
};
PreparedTextureData PrepareTextureData(ImageData* imageData, TextureFormat format);
2016-03-17 21:45:03 +00:00
std::unique_ptr<CFrameBufferPixels> GetGLFrameBufferPixels(const glm::ivec2& size);
} // namespace Gfx