Colobot
glutil.h
1 /*
2  * This file is part of the Colobot: Gold Edition source code
3  * Copyright (C) 2001-2015, Daniel Roux, EPSITEC SA & TerranovaTeam
4  * http://epsitec.ch; http://colobot.info; http://github.com/colobot
5  *
6  * This program is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14  * See the GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program. If not, see http://gnu.org/licenses
18  */
19 
20 #pragma once
21 
22 // config.h must be included first
23 #include "common/config.h"
24 
25 #include "common/make_unique.h"
26 
27 #include "graphics/core/device.h"
28 
29 #include "math/intpoint.h"
30 
31 #include <GL/glew.h>
32 
33 #include <memory>
34 
35 
36 // Graphics module namespace
37 namespace Gfx
38 {
39 
40 enum FramebufferSupport
41 {
42  FBS_NONE,
43  FBS_EXT,
44  FBS_ARB,
45 };
46 
47 FramebufferSupport DetectFramebufferSupport();
48 
50 std::unique_ptr<CDevice> CreateDevice(const DeviceConfig &config, const std::string& name);
51 
53 // First digit is major part, second digit is minor part.
54 int GetOpenGLVersion();
55 
58 
59 CompFunc TranslateGLCompFunc(GLenum flag);
60 
61 GLenum TranslateGfxCompFunc(CompFunc func);
62 
63 BlendFunc TranslateGLBlendFunc(GLenum flag);
64 
65 GLenum TranslateGfxBlendFunc(BlendFunc func);
66 
67 bool InPlane(Math::Vector normal, float originPlane, Math::Vector center, float radius);
68 
69 GLenum TranslateTextureCoordinate(int index);
70 
71 GLenum TranslateTextureCoordinateGen(int index);
72 
73 GLint LoadShader(GLint type, const char* filename);
74 
75 GLint LinkProgram(int count, GLint shaders[]);
76 
78 {
79 public:
80  CGLFrameBufferPixels(std::size_t size)
81  : m_pixels(MakeUniqueArray<GLubyte>(size))
82  {}
83 
84  void* GetPixelsData() override
85  {
86  return static_cast<void*>(m_pixels.get());
87  }
88 
89 private:
90  std::unique_ptr<GLubyte[]> m_pixels;
91 };
92 
93 std::unique_ptr<CGLFrameBufferPixels> GetGLFrameBufferPixels(Math::IntPoint size);
94 
95 } // namespace Gfx
std::unique_ptr< CDevice > CreateDevice(const DeviceConfig &config, const std::string &name)
Creates OpenGL device.
Definition: glutil.cpp:47
Definition: device.h:249
CompFunc
Type of function used to compare values.
Definition: device.h:128
BlendFunc
Type of blending function.
Definition: device.h:144
GLenum TranslateGfxPrimitive(PrimitiveType type)
Translate Gfx primitive type to OpenGL primitive type.
Definition: glutil.cpp:76
PrimitiveType
Type of primitive to render.
Definition: device.h:210
Namespace for (new) graphics code.
Definition: app.h:49
int GetOpenGLVersion()
Returns OpenGL version as one number.
Definition: glutil.cpp:66
Definition: glutil.h:77
3D (3x1) vector
Definition: vector.h:53
Abstract graphics device - CDevice class and related structs/enums.
2D Point with integer coords
Definition: intpoint.h:39
IntPoint struct.