mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-03-22 15:05:03 +01:00
GLES support
This commit is contained in:
@@ -6,7 +6,7 @@ set(DEPS_DIR ${DEPS_DIR} "${CMAKE_SOURCE_DIR}/ref")
|
||||
project("eu07")
|
||||
|
||||
set(CMAKE_CXX_STANDARD 14)
|
||||
include_directories("." "Console" "McZapkie" "gl")
|
||||
include_directories("." "Console" "McZapkie" "gl" "ref/glad/include")
|
||||
file(GLOB HEADERS "*.h" "Console/*.h" "McZapkie/*.h" "gl/*.h")
|
||||
|
||||
set(SOURCES
|
||||
@@ -95,9 +95,10 @@ set(SOURCES
|
||||
"simulationenvironment.cpp"
|
||||
"simulationstateserializer.cpp"
|
||||
"precipitation.cpp"
|
||||
"openglcolor.cpp"
|
||||
"map.cpp"
|
||||
|
||||
"ref/glad/src/glad.c"
|
||||
|
||||
"gl/shader.cpp"
|
||||
"gl/vao.cpp"
|
||||
"gl/ubo.cpp"
|
||||
@@ -130,9 +131,7 @@ if (WIN32)
|
||||
add_definitions(-DEU07_BUILD_STATIC) # to make pymath to not redefine round
|
||||
|
||||
set(SOURCES ${SOURCES} "windows.cpp" "Console.cpp" "Console/LPT.cpp" "Console/PoKeys55.cpp")
|
||||
set(GLEW_INCLUDE_DIR ${GLEW_INCLUDE_DIR} "${DEPS_DIR}/glew/include/")
|
||||
set(GLFW3_INCLUDE_DIR ${GLFW3_INCLUDE_DIR} "${DEPS_DIR}/glfw/include/")
|
||||
set(GLUT_INCLUDE_DIR ${GLUT_INCLUDE_DIR} "${DEPS_DIR}/freeglut/include/")
|
||||
set(PNG_PNG_INCLUDE_DIR ${PNG_PNG_INCLUDE_DIR} "${DEPS_DIR}/libpng/include/")
|
||||
set(ZLIB_INCLUDE_DIR ${ZLIB_INCLUDE_DIR} "${DEPS_DIR}/zlib/")
|
||||
set(GLM_INCLUDE_DIR ${GLM_INCLUDE_DIR} "${DEPS_DIR}/glm/")
|
||||
@@ -150,9 +149,7 @@ if (WIN32)
|
||||
|
||||
set (PREFIX "-${ARCH}")
|
||||
|
||||
set(GLEW_LIBRARY ${GLEW_LIBRARY} "${DEPS_DIR}/glew/lib/${ARCH}/glew32s.lib")
|
||||
set(GLFW3_LIBRARIES ${GLFW3_LIBRARIES} "${DEPS_DIR}/glfw/lib/${ARCH}/glfw3.lib")
|
||||
set(GLUT_glut_LIBRARY ${GLFW3_ROOT_PATH} "${DEPS_DIR}/freeglut/lib/${ARCH}/freeglut.lib")
|
||||
set(PNG_LIBRARY ${PNG_LIBRARY} "${DEPS_DIR}/libpng/lib/${ARCH}/libpng16.lib")
|
||||
set(OPENAL_LIBRARY ${OPENAL_LIBRARY} "${DEPS_DIR}/openal/lib/${ARCH}/OpenAL32.lib")
|
||||
set(LIBSNDFILE_LIBRARY ${LIBSNDFILE_LIBRARY} "${DEPS_DIR}/libsndfile/lib/${ARCH}/libsndfile-1.lib")
|
||||
@@ -193,26 +190,10 @@ set_target_properties( ${PROJECT_NAME}
|
||||
DEBUG_POSTFIX "_d"
|
||||
)
|
||||
|
||||
if (POLICY CMP0072)
|
||||
cmake_policy(SET CMP0072 NEW)
|
||||
endif()
|
||||
|
||||
find_package(OpenGL REQUIRED)
|
||||
include_directories(${OPENGL_INCLUDE_DIR})
|
||||
target_link_libraries(${PROJECT_NAME} ${OPENGL_LIBRARIES})
|
||||
|
||||
find_package(GLEW REQUIRED)
|
||||
include_directories(${GLEW_INCLUDE_DIRS})
|
||||
target_link_libraries(${PROJECT_NAME} ${GLEW_LIBRARIES})
|
||||
|
||||
find_package(GLFW3 REQUIRED)
|
||||
include_directories(${GLFW3_INCLUDE_DIR})
|
||||
target_link_libraries(${PROJECT_NAME} ${GLFW3_LIBRARIES})
|
||||
|
||||
find_package(GLUT REQUIRED)
|
||||
include_directories(${GLUT_INCLUDE_DIR})
|
||||
target_link_libraries(${PROJECT_NAME} ${GLUT_LIBRARIES})
|
||||
|
||||
find_package(PythonLibs 2 REQUIRED)
|
||||
include_directories(${PYTHON_INCLUDE_DIRS})
|
||||
target_link_libraries(${PROJECT_NAME} ${PYTHON_LIBRARIES})
|
||||
|
||||
@@ -738,6 +738,11 @@ global_settings::ConfigParse(cParser &Parser) {
|
||||
Parser.getTokens(1);
|
||||
Parser >> gfx_skippipeline;
|
||||
}
|
||||
else if (token == "gfx.usegles")
|
||||
{
|
||||
Parser.getTokens(1);
|
||||
Parser >> use_gles;
|
||||
}
|
||||
else if (token == "map.enabled")
|
||||
{
|
||||
Parser.getTokens(1);
|
||||
|
||||
@@ -188,6 +188,7 @@ struct global_settings {
|
||||
bool gfx_skippipeline = false;
|
||||
|
||||
bool map_enabled = true;
|
||||
bool use_gles = false;
|
||||
|
||||
// methods
|
||||
void LoadIniFile( std::string asFileName );
|
||||
|
||||
2
Logs.cpp
2
Logs.cpp
@@ -97,7 +97,7 @@ void WriteLog( const char *str, logtype const Type ) {
|
||||
WriteConsole( GetStdHandle( STD_OUTPUT_HANDLE ), str, (DWORD)strlen( str ), &wr, NULL );
|
||||
WriteConsole( GetStdHandle( STD_OUTPUT_HANDLE ), endstring, (DWORD)strlen( endstring ), &wr, NULL );
|
||||
#else
|
||||
printf("%s\n", str);
|
||||
printf("%s\n", str);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -142,7 +142,7 @@ void python_taskqueue::exit() {
|
||||
m_condition.notify_all();
|
||||
// let them free up their shit before we proceed
|
||||
for( auto const &worker : m_workers ) {
|
||||
if (worker)
|
||||
if (worker && worker->joinable())
|
||||
worker->join();
|
||||
}
|
||||
// get rid of the leftover tasks
|
||||
|
||||
163
Texture.cpp
163
Texture.cpp
@@ -16,8 +16,6 @@ http://mozilla.org/MPL/2.0/.
|
||||
#include "stdafx.h"
|
||||
#include "Texture.h"
|
||||
|
||||
#include "GL/glew.h"
|
||||
|
||||
#include "utilities.h"
|
||||
#include "Globals.h"
|
||||
#include "Logs.h"
|
||||
@@ -34,6 +32,128 @@ texture_manager::texture_manager() {
|
||||
m_textures.emplace_back( new opengl_texture(), std::chrono::steady_clock::time_point() );
|
||||
}
|
||||
|
||||
// convert image to format suitable for given internalformat
|
||||
// required for GLES, on desktop GL it will be done by driver
|
||||
void opengl_texture::gles_match_internalformat(GLuint internalformat)
|
||||
{
|
||||
// don't care about sRGB here
|
||||
if (internalformat == GL_SRGB8)
|
||||
internalformat = GL_RGB8;
|
||||
if (internalformat == GL_SRGB8_ALPHA8)
|
||||
internalformat = GL_RGBA8;
|
||||
if (internalformat == GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT)
|
||||
internalformat = GL_COMPRESSED_RGBA_S3TC_DXT1_EXT;
|
||||
if (internalformat == GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT)
|
||||
internalformat = GL_COMPRESSED_RGBA_S3TC_DXT3_EXT;
|
||||
if (internalformat == GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT)
|
||||
internalformat = GL_COMPRESSED_RGBA_S3TC_DXT5_EXT;
|
||||
|
||||
// ignore compressed formats (and hope that GLES driver will support it)
|
||||
if (precompressed_formats.find(internalformat) != precompressed_formats.end())
|
||||
return;
|
||||
|
||||
// we don't want BGR(A), reverse it
|
||||
if (data_format == GL_BGR)
|
||||
{
|
||||
std::vector<char> reverse;
|
||||
reverse.resize(data.size());
|
||||
|
||||
for (int y = 0; y < data_height; y++)
|
||||
for (int x = 0; x < data_width; x++)
|
||||
{
|
||||
int offset = (y * data_width + x) * 3;
|
||||
reverse[offset + 0] = data[offset + 2];
|
||||
reverse[offset + 1] = data[offset + 1];
|
||||
reverse[offset + 2] = data[offset + 0];
|
||||
}
|
||||
|
||||
data_format = GL_RGB;
|
||||
data = reverse;
|
||||
}
|
||||
else if (data_format == GL_BGRA)
|
||||
{
|
||||
std::vector<char> reverse;
|
||||
reverse.resize(data.size());
|
||||
|
||||
for (int y = 0; y < data_height; y++)
|
||||
for (int x = 0; x < data_width; x++)
|
||||
{
|
||||
int offset = (y * data_width + x) * 4;
|
||||
reverse[offset + 0] = data[offset + 2];
|
||||
reverse[offset + 1] = data[offset + 1];
|
||||
reverse[offset + 2] = data[offset + 0];
|
||||
reverse[offset + 3] = data[offset + 3];
|
||||
}
|
||||
|
||||
data_format = GL_RGBA;
|
||||
data = reverse;
|
||||
}
|
||||
|
||||
// if format matches, we're done
|
||||
if (data_format == GL_RGBA && internalformat == GL_RGBA8)
|
||||
return;
|
||||
if (data_format == GL_RGB && internalformat == GL_RGB8)
|
||||
return;
|
||||
if (data_format == GL_RG && internalformat == GL_RG8)
|
||||
return;
|
||||
if (data_format == GL_RED && internalformat == GL_R8)
|
||||
return;
|
||||
|
||||
// do conversion
|
||||
|
||||
int in_c = 0;
|
||||
if (data_format == GL_RGBA)
|
||||
in_c = 4;
|
||||
else if (data_format == GL_RGB)
|
||||
in_c = 3;
|
||||
else if (data_format == GL_RG)
|
||||
in_c = 2;
|
||||
else if (data_format == GL_RED)
|
||||
in_c = 1;
|
||||
|
||||
int out_c = 0;
|
||||
if (internalformat == GL_RGBA8)
|
||||
out_c = 4;
|
||||
else if (internalformat == GL_RGB8)
|
||||
out_c = 3;
|
||||
else if (internalformat == GL_RG8)
|
||||
out_c = 2;
|
||||
else if (internalformat == GL_R8)
|
||||
out_c = 1;
|
||||
|
||||
if (!in_c || !out_c)
|
||||
return; // conversion not supported
|
||||
|
||||
std::vector<char> out;
|
||||
out.resize(data_width * data_height * out_c);
|
||||
|
||||
for (int y = 0; y < data_height; y++)
|
||||
for (int x = 0; x < data_width; x++)
|
||||
{
|
||||
int pixel = (y * data_width + x);
|
||||
int in_off = pixel * in_c;
|
||||
int out_off = pixel * out_c;
|
||||
for (int i = 0; i < out_c; i++)
|
||||
{
|
||||
if (i < in_c)
|
||||
out[out_off + i] = data[in_off + i];
|
||||
else
|
||||
out[out_off + i] = 0xFF;
|
||||
}
|
||||
}
|
||||
|
||||
if (out_c == 4)
|
||||
data_format = GL_RGBA;
|
||||
else if (out_c == 3)
|
||||
data_format = GL_RGB;
|
||||
else if (out_c == 2)
|
||||
data_format = GL_RG;
|
||||
else if (out_c == 1)
|
||||
data_format = GL_RED;
|
||||
|
||||
data = out;
|
||||
}
|
||||
|
||||
// loads texture data from specified file
|
||||
// TODO: wrap it in a workitem class, for the job system deferred loading
|
||||
void
|
||||
@@ -168,12 +288,10 @@ opengl_texture::load_BMP() {
|
||||
|
||||
// fill remaining data info
|
||||
if( info.bmiHeader.biBitCount == 32 ) {
|
||||
|
||||
data_format = GL_BGRA;
|
||||
data_components = GL_RGBA;
|
||||
}
|
||||
else {
|
||||
|
||||
data_format = GL_BGR;
|
||||
data_components = GL_RGB;
|
||||
}
|
||||
@@ -581,7 +699,7 @@ opengl_texture::bind(size_t unit) {
|
||||
if (units[unit] == id)
|
||||
return true;
|
||||
|
||||
if (GLEW_ARB_direct_state_access)
|
||||
if (GLAD_GL_ARB_direct_state_access)
|
||||
{
|
||||
glBindTextureUnit(unit, id);
|
||||
}
|
||||
@@ -602,7 +720,7 @@ opengl_texture::bind(size_t unit) {
|
||||
|
||||
void opengl_texture::unbind(size_t unit)
|
||||
{
|
||||
if (GLEW_ARB_direct_state_access)
|
||||
if (GLAD_GL_ARB_direct_state_access)
|
||||
{
|
||||
glBindTextureUnit(unit, 0);
|
||||
}
|
||||
@@ -746,10 +864,21 @@ opengl_texture::create() {
|
||||
float borderColor[] = { 0.0f, 0.0f, 0.0f, 0.0f };
|
||||
glTexParameterfv(target, GL_TEXTURE_BORDER_COLOR, borderColor);
|
||||
}
|
||||
if (target == GL_TEXTURE_2D)
|
||||
glTexImage2D(target, 0, data_format, data_width, data_height, 0, data_components, GL_BYTE, nullptr);
|
||||
else if (target == GL_TEXTURE_2D_MULTISAMPLE)
|
||||
glTexImage2DMultisample(target, samples, data_format, data_width, data_height, GL_FALSE);
|
||||
|
||||
if (Global.use_gles)
|
||||
{
|
||||
if (target == GL_TEXTURE_2D || !glTexStorage2DMultisample)
|
||||
glTexStorage2D(target, count_trailing_zeros(std::max(data_width, data_height)) + 1, data_format, data_width, data_height);
|
||||
else if (target == GL_TEXTURE_2D_MULTISAMPLE)
|
||||
glTexStorage2DMultisample(target, samples, data_format, data_width, data_height, GL_FALSE);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (target == GL_TEXTURE_2D)
|
||||
glTexImage2D(target, 0, data_format, data_width, data_height, 0, data_components, GL_UNSIGNED_SHORT, nullptr);
|
||||
else if (target == GL_TEXTURE_2D_MULTISAMPLE)
|
||||
glTexImage2DMultisample(target, samples, data_format, data_width, data_height, GL_FALSE);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -773,6 +902,15 @@ opengl_texture::create() {
|
||||
|
||||
GLint internal_format = mapping[components][components_hint];
|
||||
|
||||
if (Global.use_gles)
|
||||
{
|
||||
// GLES cannot generate mipmaps on SRGB8
|
||||
if (internal_format == GL_SRGB8)
|
||||
internal_format = GL_SRGB8_ALPHA8;
|
||||
|
||||
gles_match_internalformat(internal_format);
|
||||
}
|
||||
|
||||
auto blocksize_it = precompressed_formats.find(internal_format);
|
||||
|
||||
for( int maplevel = 0; maplevel < data_mapcount; ++maplevel ) {
|
||||
@@ -887,7 +1025,10 @@ opengl_texture::set_filtering() const
|
||||
// default texture mode
|
||||
::glTexParameteri(target, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
|
||||
::glTexParameteri(target, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR );
|
||||
::glTexParameterf(target, GL_TEXTURE_MAX_ANISOTROPY_EXT, Global.AnisotropicFiltering );
|
||||
if (GLAD_GL_ARB_texture_filter_anisotropic)
|
||||
::glTexParameterf(target, GL_TEXTURE_MAX_ANISOTROPY, Global.AnisotropicFiltering );
|
||||
else if (GLAD_GL_EXT_texture_filter_anisotropic)
|
||||
::glTexParameterf(target, GL_TEXTURE_MAX_ANISOTROPY_EXT, Global.AnisotropicFiltering );
|
||||
|
||||
bool sharpen{ false };
|
||||
for( auto const &trait : traits ) {
|
||||
|
||||
@@ -69,6 +69,7 @@ private:
|
||||
void set_filtering() const;
|
||||
void downsize( GLuint const Format );
|
||||
void flip_vertical();
|
||||
void gles_match_internalformat(GLuint format);
|
||||
|
||||
// members
|
||||
bool is_rendertarget; // is used as postfx rendertarget, without loaded data
|
||||
|
||||
18
TrkFoll.cpp
18
TrkFoll.cpp
@@ -282,21 +282,3 @@ bool TTrackFollower::ComputatePosition()
|
||||
}
|
||||
return false;
|
||||
}
|
||||
#if RENDER_CONE
|
||||
#include "GL/glew.h"
|
||||
#include "GL/glut.h"
|
||||
void TTrackFollower::Render(float fNr)
|
||||
{ // funkcja rysująca stożek w miejscu osi
|
||||
glPushMatrix(); // matryca kamery
|
||||
glTranslatef(pPosition.x, pPosition.y + 6, pPosition.z); // 6m ponad
|
||||
glRotated(RadToDeg(-vAngles.z), 0, 1, 0); // obrót względem osi OY
|
||||
// glRotated(RadToDeg(vAngles.z),0,1,0); //obrót względem osi OY
|
||||
glDisable(GL_LIGHTING);
|
||||
glColor3f(1.0, 1.0 - fNr, 1.0 - fNr); // biały dla 0, czerwony dla 1
|
||||
// glutWireCone(promień podstawy,wysokość,kątność podstawy,ilość segmentów na wysokość)
|
||||
glutWireCone(0.5, 2, 4, 1); // rysowanie stożka (ostrosłupa o podstawie wieloboka)
|
||||
glEnable(GL_LIGHTING);
|
||||
glPopMatrix();
|
||||
}
|
||||
#endif
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
@@ -126,10 +126,10 @@ eu07_application::init( int Argc, char *Argv[] ) {
|
||||
if( ( result = init_glfw() ) != 0 ) {
|
||||
return result;
|
||||
}
|
||||
init_callbacks();
|
||||
if( ( result = init_gfx() ) != 0 ) {
|
||||
return result;
|
||||
}
|
||||
init_callbacks();
|
||||
if( ( result = init_audio() ) != 0 ) {
|
||||
return result;
|
||||
}
|
||||
@@ -157,6 +157,9 @@ eu07_application::run() {
|
||||
Timer::subsystem.mainloop_total.start();
|
||||
glfwPollEvents();
|
||||
|
||||
if (m_modestack.empty())
|
||||
return 0;
|
||||
|
||||
m_modes[ m_modestack.top() ]->on_event_poll();
|
||||
|
||||
simulation::Commands.update();
|
||||
@@ -188,8 +191,8 @@ eu07_application::exit() {
|
||||
for( auto *window : m_windows ) {
|
||||
glfwDestroyWindow( window );
|
||||
}
|
||||
glfwTerminate();
|
||||
m_taskqueue.exit();
|
||||
glfwTerminate();
|
||||
}
|
||||
|
||||
void
|
||||
@@ -426,12 +429,22 @@ eu07_application::init_glfw() {
|
||||
glfwWindowHint( GLFW_REFRESH_RATE, vmode->refreshRate );
|
||||
|
||||
glfwWindowHint(GLFW_SRGB_CAPABLE, GLFW_TRUE);
|
||||
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
|
||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
|
||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
|
||||
if (!Global.use_gles)
|
||||
{
|
||||
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
|
||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
|
||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
|
||||
}
|
||||
else
|
||||
{
|
||||
glfwWindowHint(GLFW_CONTEXT_CREATION_API, GLFW_EGL_CONTEXT_API);
|
||||
glfwWindowHint(GLFW_CLIENT_API, GLFW_OPENGL_ES_API);
|
||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
|
||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 0);
|
||||
}
|
||||
|
||||
glfwWindowHint( GLFW_AUTO_ICONIFY, GLFW_FALSE );
|
||||
if( Global.iMultisampling > 0 ) {
|
||||
if (Global.gfx_skippipeline && Global.iMultisampling > 0) {
|
||||
glfwWindowHint( GLFW_SAMPLES, 1 << Global.iMultisampling );
|
||||
}
|
||||
|
||||
@@ -495,9 +508,21 @@ eu07_application::init_callbacks() {
|
||||
int
|
||||
eu07_application::init_gfx() {
|
||||
|
||||
if( glewInit() != GLEW_OK ) {
|
||||
ErrorLog( "Bad init: failed to initialize glew" );
|
||||
return -1;
|
||||
if (!Global.use_gles)
|
||||
{
|
||||
if (!gladLoadGLLoader((GLADloadproc)glfwGetProcAddress))
|
||||
{
|
||||
ErrorLog( "Bad init: failed to initialize glad" );
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!gladLoadGLES2Loader((GLADloadproc)glfwGetProcAddress))
|
||||
{
|
||||
ErrorLog( "Bad init: failed to initialize glad" );
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
if (!ui_layer::init(m_windows.front()))
|
||||
|
||||
@@ -700,14 +700,7 @@ driver_mode::OnKeyDown(int cKey) {
|
||||
}
|
||||
else {
|
||||
// f7: wireframe toggle
|
||||
// TODO: pass this to renderer instead of making direct calls
|
||||
Global.bWireFrame = !Global.bWireFrame;
|
||||
if( true == Global.bWireFrame ) {
|
||||
glPolygonMode( GL_FRONT_AND_BACK, GL_LINE );
|
||||
}
|
||||
else {
|
||||
glPolygonMode( GL_FRONT_AND_BACK, GL_FILL );
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -59,11 +59,15 @@ void gl::framebuffer::blit_to(framebuffer &other, int w, int h, GLbitfield mask,
|
||||
{
|
||||
glBindFramebuffer(GL_READ_FRAMEBUFFER, *this);
|
||||
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, other);
|
||||
if (mask & GL_COLOR_BUFFER_BIT)
|
||||
{
|
||||
glReadBuffer(attachment);
|
||||
glDrawBuffer(attachment);
|
||||
}
|
||||
|
||||
int attachment_n = attachment - GL_COLOR_ATTACHMENT0;
|
||||
|
||||
GLenum outputs[8] = { GL_NONE };
|
||||
outputs[attachment_n] = attachment;
|
||||
|
||||
glReadBuffer(attachment);
|
||||
glDrawBuffers(attachment_n + 1, outputs);
|
||||
|
||||
glBlitFramebuffer(0, 0, w, h, 0, 0, w, h, mask, GL_NEAREST);
|
||||
unbind();
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ void gl::glsl_common_setup()
|
||||
"#define ENVMAP_ENABLED " + std::to_string((int)Global.gfx_envmap_enabled) + "\n" +
|
||||
"#define MOTIONBLUR_ENABLED " + std::to_string((int)Global.gfx_postfx_motionblur_enabled) + "\n" +
|
||||
"#define POSTFX_ENABLED " + std::to_string((int)!Global.gfx_skippipeline) + "\n" +
|
||||
"#define USE_GLES " + std::to_string((int)Global.use_gles) + "\n" +
|
||||
"const uint MAX_LIGHTS = " + std::to_string(MAX_LIGHTS) + "U;\n" +
|
||||
"const uint MAX_PARAMS = " + std::to_string(MAX_PARAMS) + "U;\n" +
|
||||
R"STRING(
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <GL/glew.h>
|
||||
#include <glad/glad.h>
|
||||
|
||||
namespace gl
|
||||
{
|
||||
|
||||
@@ -202,7 +202,18 @@ void gl::shader::log_error(const std::string &str)
|
||||
gl::shader::shader(const std::string &filename)
|
||||
{
|
||||
name = filename;
|
||||
std::string str = read_file(filename);
|
||||
std::string str;
|
||||
if (!Global.use_gles)
|
||||
{
|
||||
str += "#version 330 core\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
str += "#version 300 es\n";
|
||||
str += "precision highp float;\n";
|
||||
str += "precision highp sampler2DShadow;\n";
|
||||
}
|
||||
str += read_file(filename);
|
||||
process_source(str);
|
||||
|
||||
const GLchar *cstr = str.c_str();
|
||||
@@ -228,9 +239,10 @@ gl::shader::shader(const std::string &filename)
|
||||
{
|
||||
GLchar info[512];
|
||||
glGetShaderInfoLog(*this, 512, 0, info);
|
||||
ErrorLog(std::string(info));
|
||||
std::cerr << std::string(info) << std::endl;
|
||||
throw shader_exception("failed to compile " + filename + ": " + std::string(info));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
gl::shader::~shader()
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
#include <stdint.h> // intptr_t
|
||||
#endif
|
||||
|
||||
#include <GL/glew.h>
|
||||
#include <glad/glad.h>
|
||||
|
||||
// OpenGL Data
|
||||
static GLuint g_FontTexture = 0;
|
||||
|
||||
@@ -32,10 +32,10 @@
|
||||
#include "imgui.h"
|
||||
#include "imgui_impl_opengl3.h"
|
||||
|
||||
#include <GL/glew.h>
|
||||
#include <glad/glad.h>
|
||||
|
||||
// OpenGL Data
|
||||
static char g_GlslVersion[32] = "";
|
||||
static char g_GlslVersion[128] = "";
|
||||
static GLuint g_FontTexture = 0;
|
||||
static int g_ShaderHandle = 0, g_VertHandle = 0, g_FragHandle = 0;
|
||||
static int g_AttribLocationTex = 0, g_AttribLocationProjMtx = 0;
|
||||
@@ -86,7 +86,6 @@ void ImGui_ImplOpenGL3_RenderDrawData(ImDrawData* draw_data)
|
||||
GLint last_sampler; glGetIntegerv(GL_SAMPLER_BINDING, &last_sampler);
|
||||
GLint last_array_buffer; glGetIntegerv(GL_ARRAY_BUFFER_BINDING, &last_array_buffer);
|
||||
GLint last_vertex_array; glGetIntegerv(GL_VERTEX_ARRAY_BINDING, &last_vertex_array);
|
||||
GLint last_polygon_mode[2]; glGetIntegerv(GL_POLYGON_MODE, last_polygon_mode);
|
||||
GLint last_viewport[4]; glGetIntegerv(GL_VIEWPORT, last_viewport);
|
||||
GLint last_scissor_box[4]; glGetIntegerv(GL_SCISSOR_BOX, last_scissor_box);
|
||||
GLenum last_blend_src_rgb; glGetIntegerv(GL_BLEND_SRC_RGB, (GLint*)&last_blend_src_rgb);
|
||||
@@ -99,7 +98,16 @@ void ImGui_ImplOpenGL3_RenderDrawData(ImDrawData* draw_data)
|
||||
GLboolean last_enable_cull_face = glIsEnabled(GL_CULL_FACE);
|
||||
GLboolean last_enable_depth_test = glIsEnabled(GL_DEPTH_TEST);
|
||||
GLboolean last_enable_scissor_test = glIsEnabled(GL_SCISSOR_TEST);
|
||||
GLboolean last_enable_srgb = glIsEnabled(GL_FRAMEBUFFER_SRGB);
|
||||
|
||||
GLint last_polygon_mode[2];
|
||||
GLboolean last_enable_srgb;
|
||||
if (GLAD_GL_VERSION_3_3)
|
||||
{
|
||||
glGetIntegerv(GL_POLYGON_MODE, last_polygon_mode);
|
||||
last_enable_srgb = glIsEnabled(GL_FRAMEBUFFER_SRGB);
|
||||
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
|
||||
glEnable(GL_FRAMEBUFFER_SRGB);
|
||||
}
|
||||
|
||||
// Setup render state: alpha-blending enabled, no face culling, no depth testing, scissor enabled, polygon fill
|
||||
glEnable(GL_BLEND);
|
||||
@@ -108,8 +116,6 @@ void ImGui_ImplOpenGL3_RenderDrawData(ImDrawData* draw_data)
|
||||
glDisable(GL_CULL_FACE);
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
glEnable(GL_SCISSOR_TEST);
|
||||
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
|
||||
glEnable(GL_FRAMEBUFFER_SRGB);
|
||||
|
||||
// Setup viewport, orthographic projection matrix
|
||||
// Our visible imgui space lies from draw_data->DisplayPps (top left) to draw_data->DisplayPos+data_data->DisplaySize (bottom right). DisplayMin is typically (0,0) for single viewport apps.
|
||||
@@ -195,10 +201,14 @@ void ImGui_ImplOpenGL3_RenderDrawData(ImDrawData* draw_data)
|
||||
if (last_enable_cull_face) glEnable(GL_CULL_FACE); else glDisable(GL_CULL_FACE);
|
||||
if (last_enable_depth_test) glEnable(GL_DEPTH_TEST); else glDisable(GL_DEPTH_TEST);
|
||||
if (last_enable_scissor_test) glEnable(GL_SCISSOR_TEST); else glDisable(GL_SCISSOR_TEST);
|
||||
if (last_enable_srgb) glEnable(GL_FRAMEBUFFER_SRGB); else glDisable(GL_FRAMEBUFFER_SRGB);
|
||||
glPolygonMode(GL_FRONT_AND_BACK, (GLenum)last_polygon_mode[0]);
|
||||
glViewport(last_viewport[0], last_viewport[1], (GLsizei)last_viewport[2], (GLsizei)last_viewport[3]);
|
||||
glScissor(last_scissor_box[0], last_scissor_box[1], (GLsizei)last_scissor_box[2], (GLsizei)last_scissor_box[3]);
|
||||
|
||||
if (GLAD_GL_VERSION_3_3)
|
||||
{
|
||||
if (last_enable_srgb) glEnable(GL_FRAMEBUFFER_SRGB); else glDisable(GL_FRAMEBUFFER_SRGB);
|
||||
glPolygonMode(GL_FRONT_AND_BACK, (GLenum)last_polygon_mode[0]);
|
||||
}
|
||||
}
|
||||
|
||||
bool ImGui_ImplOpenGL3_CreateFontsTexture()
|
||||
|
||||
7
moon.cpp
7
moon.cpp
@@ -15,7 +15,9 @@ cMoon::cMoon() {
|
||||
m_observer.temp = 15.0; // ambient dry-bulb temperature, degrees C
|
||||
}
|
||||
|
||||
cMoon::~cMoon() { gluDeleteQuadric( moonsphere ); }
|
||||
cMoon::~cMoon() {
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
cMoon::init() {
|
||||
@@ -24,9 +26,6 @@ cMoon::init() {
|
||||
// NOTE: we're calculating phase just once, because it's unlikely simulation will last a few days,
|
||||
// plus a sudden texture change would be pretty jarring
|
||||
phase();
|
||||
|
||||
moonsphere = gluNewQuadric();
|
||||
gluQuadricNormals( moonsphere, GLU_SMOOTH );
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
3
moon.h
3
moon.h
@@ -1,7 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
#include "GL/glew.h"
|
||||
|
||||
// TODO: sun and moon share code as celestial bodies, we could make a base class out of it
|
||||
|
||||
class cMoon {
|
||||
@@ -53,7 +51,6 @@ protected:
|
||||
float normalize( const float Value ) const;
|
||||
|
||||
// members:
|
||||
GLUquadricObj *moonsphere; // temporary handler for moon positioning test
|
||||
|
||||
struct celestialbody { // main planet parameters
|
||||
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
/*
|
||||
This Source Code Form is subject to the
|
||||
terms of the Mozilla Public License, v.
|
||||
2.0. If a copy of the MPL was not
|
||||
distributed with this file, You can
|
||||
obtain one at
|
||||
http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
#include "stdafx.h"
|
||||
|
||||
opengl_color OpenGLColor;
|
||||
@@ -1,69 +0,0 @@
|
||||
/*
|
||||
This Source Code Form is subject to the
|
||||
terms of the Mozilla Public License, v.
|
||||
2.0. If a copy of the MPL was not
|
||||
distributed with this file, You can
|
||||
obtain one at
|
||||
http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
// encapsulation of the fixed pipeline opengl color
|
||||
class opengl_color {
|
||||
|
||||
public:
|
||||
// constructors:
|
||||
opengl_color() = default;
|
||||
|
||||
// methods:
|
||||
inline
|
||||
void
|
||||
color3( glm::vec3 const &Color ) {
|
||||
return color4( glm::vec4{ Color, 1.f } ); }
|
||||
inline
|
||||
void
|
||||
color3( float const Red, float const Green, float const Blue ) {
|
||||
return color3( glm::vec3 { Red, Green, Blue } ); }
|
||||
inline
|
||||
void
|
||||
color3( float const *Value ) {
|
||||
return color3( glm::make_vec3( Value ) ); }
|
||||
inline
|
||||
void
|
||||
color4( glm::vec4 const &Color ) {
|
||||
if( ( Color != m_color ) ) {
|
||||
m_color = Color;
|
||||
::glColor4fv( glm::value_ptr( m_color ) ); } }
|
||||
inline
|
||||
void
|
||||
color4( float const Red, float const Green, float const Blue, float const Alpha ) {
|
||||
return color4( glm::vec4{ Red, Green, Blue, Alpha } ); }
|
||||
inline
|
||||
void
|
||||
color4( float const *Value ) {
|
||||
return color4( glm::make_vec4( Value ) );
|
||||
}
|
||||
inline
|
||||
glm::vec4 const &
|
||||
data() const {
|
||||
return m_color; }
|
||||
inline
|
||||
float const *
|
||||
data_array() const {
|
||||
return glm::value_ptr( m_color ); }
|
||||
|
||||
private:
|
||||
// members:
|
||||
glm::vec4 m_color { -1 };
|
||||
};
|
||||
|
||||
extern opengl_color OpenGLColor;
|
||||
|
||||
// NOTE: standard opengl calls re-definitions
|
||||
#define glColor3f OpenGLColor.color3
|
||||
#define glColor3fv OpenGLColor.color3
|
||||
#define glColor4f OpenGLColor.color4
|
||||
#define glColor4fv OpenGLColor.color4
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
@@ -376,8 +376,11 @@ void opengl_vbogeometrybank::draw_(const std::vector<gfx::geometry_handle>::iter
|
||||
m_vao->bind();
|
||||
if (m_offsets.size() == 1)
|
||||
glDrawArrays(type, m_offsets.front(), m_counts.front());
|
||||
else
|
||||
else if (!Global.use_gles)
|
||||
glMultiDrawArrays(type, m_offsets.data(), m_counts.data(), m_offsets.size());
|
||||
else
|
||||
for (size_t i = 0; i < m_offsets.size(); i++)
|
||||
glDrawArrays(type, m_offsets[i], m_counts[i]);
|
||||
}
|
||||
|
||||
// release () subclass details
|
||||
|
||||
@@ -12,10 +12,6 @@ http://mozilla.org/MPL/2.0/.
|
||||
#include <vector>
|
||||
#include <glm/glm.hpp>
|
||||
#include <glm/gtc/type_ptr.hpp>
|
||||
#include "GL/glew.h"
|
||||
#ifdef _WIN32
|
||||
#include "GL/wglew.h"
|
||||
#endif
|
||||
#include "ResourceManager.h"
|
||||
#include "gl/vao.h"
|
||||
|
||||
|
||||
@@ -15,9 +15,9 @@ http://mozilla.org/MPL/2.0/.
|
||||
#include <glm/glm.hpp>
|
||||
#include <glm/gtc/matrix_transform.hpp>
|
||||
#include <glm/gtc/type_ptr.hpp>
|
||||
#ifdef _WIN32
|
||||
#include "GL/wglew.h"
|
||||
#endif
|
||||
|
||||
#define GL_MODELVIEW 1
|
||||
#define GL_PROJECTION 2
|
||||
|
||||
// encapsulation of the fixed pipeline opengl matrix stack
|
||||
class opengl_matrices {
|
||||
|
||||
@@ -1,22 +0,0 @@
|
||||
#ifndef __FREEGLUT_H__
|
||||
#define __FREEGLUT_H__
|
||||
|
||||
/*
|
||||
* freeglut.h
|
||||
*
|
||||
* The freeglut library include file
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* PAWEL W. OLSZTA BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "freeglut_std.h"
|
||||
#include "freeglut_ext.h"
|
||||
|
||||
/*** END OF FILE ***/
|
||||
|
||||
#endif /* __FREEGLUT_H__ */
|
||||
@@ -1,271 +0,0 @@
|
||||
#ifndef __FREEGLUT_EXT_H__
|
||||
#define __FREEGLUT_EXT_H__
|
||||
|
||||
/*
|
||||
* freeglut_ext.h
|
||||
*
|
||||
* The non-GLUT-compatible extensions to the freeglut library include file
|
||||
*
|
||||
* Copyright (c) 1999-2000 Pawel W. Olszta. All Rights Reserved.
|
||||
* Written by Pawel W. Olszta, <olszta@sourceforge.net>
|
||||
* Creation date: Thu Dec 2 1999
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* PAWEL W. OLSZTA BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Additional GLUT Key definitions for the Special key function
|
||||
*/
|
||||
#define GLUT_KEY_NUM_LOCK 0x006D
|
||||
#define GLUT_KEY_BEGIN 0x006E
|
||||
#define GLUT_KEY_DELETE 0x006F
|
||||
#define GLUT_KEY_SHIFT_L 0x0070
|
||||
#define GLUT_KEY_SHIFT_R 0x0071
|
||||
#define GLUT_KEY_CTRL_L 0x0072
|
||||
#define GLUT_KEY_CTRL_R 0x0073
|
||||
#define GLUT_KEY_ALT_L 0x0074
|
||||
#define GLUT_KEY_ALT_R 0x0075
|
||||
|
||||
/*
|
||||
* GLUT API Extension macro definitions -- behaviour when the user clicks on an "x" to close a window
|
||||
*/
|
||||
#define GLUT_ACTION_EXIT 0
|
||||
#define GLUT_ACTION_GLUTMAINLOOP_RETURNS 1
|
||||
#define GLUT_ACTION_CONTINUE_EXECUTION 2
|
||||
|
||||
/*
|
||||
* Create a new rendering context when the user opens a new window?
|
||||
*/
|
||||
#define GLUT_CREATE_NEW_CONTEXT 0
|
||||
#define GLUT_USE_CURRENT_CONTEXT 1
|
||||
|
||||
/*
|
||||
* Direct/Indirect rendering context options (has meaning only in Unix/X11)
|
||||
*/
|
||||
#define GLUT_FORCE_INDIRECT_CONTEXT 0
|
||||
#define GLUT_ALLOW_DIRECT_CONTEXT 1
|
||||
#define GLUT_TRY_DIRECT_CONTEXT 2
|
||||
#define GLUT_FORCE_DIRECT_CONTEXT 3
|
||||
|
||||
/*
|
||||
* GLUT API Extension macro definitions -- the glutGet parameters
|
||||
*/
|
||||
#define GLUT_INIT_STATE 0x007C
|
||||
|
||||
#define GLUT_ACTION_ON_WINDOW_CLOSE 0x01F9
|
||||
|
||||
#define GLUT_WINDOW_BORDER_WIDTH 0x01FA
|
||||
#define GLUT_WINDOW_BORDER_HEIGHT 0x01FB
|
||||
#define GLUT_WINDOW_HEADER_HEIGHT 0x01FB /* Docs say it should always have been GLUT_WINDOW_BORDER_HEIGHT, keep this for backward compatibility */
|
||||
|
||||
#define GLUT_VERSION 0x01FC
|
||||
|
||||
#define GLUT_RENDERING_CONTEXT 0x01FD
|
||||
#define GLUT_DIRECT_RENDERING 0x01FE
|
||||
|
||||
#define GLUT_FULL_SCREEN 0x01FF
|
||||
|
||||
#define GLUT_SKIP_STALE_MOTION_EVENTS 0x0204
|
||||
|
||||
#define GLUT_GEOMETRY_VISUALIZE_NORMALS 0x0205
|
||||
|
||||
#define GLUT_STROKE_FONT_DRAW_JOIN_DOTS 0x0206 /* Draw dots between line segments of stroke fonts? */
|
||||
|
||||
/*
|
||||
* New tokens for glutInitDisplayMode.
|
||||
* Only one GLUT_AUXn bit may be used at a time.
|
||||
* Value 0x0400 is defined in OpenGLUT.
|
||||
*/
|
||||
#define GLUT_AUX 0x1000
|
||||
|
||||
#define GLUT_AUX1 0x1000
|
||||
#define GLUT_AUX2 0x2000
|
||||
#define GLUT_AUX3 0x4000
|
||||
#define GLUT_AUX4 0x8000
|
||||
|
||||
/*
|
||||
* Context-related flags, see fg_state.c
|
||||
* Set the requested OpenGL version
|
||||
*/
|
||||
#define GLUT_INIT_MAJOR_VERSION 0x0200
|
||||
#define GLUT_INIT_MINOR_VERSION 0x0201
|
||||
#define GLUT_INIT_FLAGS 0x0202
|
||||
#define GLUT_INIT_PROFILE 0x0203
|
||||
|
||||
/*
|
||||
* Flags for glutInitContextFlags, see fg_init.c
|
||||
*/
|
||||
#define GLUT_DEBUG 0x0001
|
||||
#define GLUT_FORWARD_COMPATIBLE 0x0002
|
||||
|
||||
|
||||
/*
|
||||
* Flags for glutInitContextProfile, see fg_init.c
|
||||
*/
|
||||
#define GLUT_CORE_PROFILE 0x0001
|
||||
#define GLUT_COMPATIBILITY_PROFILE 0x0002
|
||||
|
||||
/*
|
||||
* Process loop function, see fg_main.c
|
||||
*/
|
||||
FGAPI void FGAPIENTRY glutMainLoopEvent( void );
|
||||
FGAPI void FGAPIENTRY glutLeaveMainLoop( void );
|
||||
FGAPI void FGAPIENTRY glutExit ( void );
|
||||
|
||||
/*
|
||||
* Window management functions, see fg_window.c
|
||||
*/
|
||||
FGAPI void FGAPIENTRY glutFullScreenToggle( void );
|
||||
FGAPI void FGAPIENTRY glutLeaveFullScreen( void );
|
||||
|
||||
/*
|
||||
* Menu functions
|
||||
*/
|
||||
FGAPI void FGAPIENTRY glutSetMenuFont( int menuID, void* font );
|
||||
|
||||
/*
|
||||
* Window-specific callback functions, see fg_callbacks.c
|
||||
*/
|
||||
FGAPI void FGAPIENTRY glutMouseWheelFunc( void (* callback)( int, int, int, int ) );
|
||||
FGAPI void FGAPIENTRY glutPositionFunc( void (* callback)( int, int ) );
|
||||
FGAPI void FGAPIENTRY glutCloseFunc( void (* callback)( void ) );
|
||||
FGAPI void FGAPIENTRY glutWMCloseFunc( void (* callback)( void ) );
|
||||
/* And also a destruction callback for menus */
|
||||
FGAPI void FGAPIENTRY glutMenuDestroyFunc( void (* callback)( void ) );
|
||||
|
||||
/*
|
||||
* State setting and retrieval functions, see fg_state.c
|
||||
*/
|
||||
FGAPI void FGAPIENTRY glutSetOption ( GLenum option_flag, int value );
|
||||
FGAPI int * FGAPIENTRY glutGetModeValues(GLenum mode, int * size);
|
||||
/* A.Donev: User-data manipulation */
|
||||
FGAPI void* FGAPIENTRY glutGetWindowData( void );
|
||||
FGAPI void FGAPIENTRY glutSetWindowData(void* data);
|
||||
FGAPI void* FGAPIENTRY glutGetMenuData( void );
|
||||
FGAPI void FGAPIENTRY glutSetMenuData(void* data);
|
||||
|
||||
/*
|
||||
* Font stuff, see fg_font.c
|
||||
*/
|
||||
FGAPI int FGAPIENTRY glutBitmapHeight( void* font );
|
||||
FGAPI GLfloat FGAPIENTRY glutStrokeHeight( void* font );
|
||||
FGAPI void FGAPIENTRY glutBitmapString( void* font, const unsigned char *string );
|
||||
FGAPI void FGAPIENTRY glutStrokeString( void* font, const unsigned char *string );
|
||||
|
||||
/*
|
||||
* Geometry functions, see fg_geometry.c
|
||||
*/
|
||||
FGAPI void FGAPIENTRY glutWireRhombicDodecahedron( void );
|
||||
FGAPI void FGAPIENTRY glutSolidRhombicDodecahedron( void );
|
||||
FGAPI void FGAPIENTRY glutWireSierpinskiSponge ( int num_levels, double offset[3], double scale );
|
||||
FGAPI void FGAPIENTRY glutSolidSierpinskiSponge ( int num_levels, double offset[3], double scale );
|
||||
FGAPI void FGAPIENTRY glutWireCylinder( double radius, double height, GLint slices, GLint stacks);
|
||||
FGAPI void FGAPIENTRY glutSolidCylinder( double radius, double height, GLint slices, GLint stacks);
|
||||
|
||||
/*
|
||||
* Rest of functions for rendering Newell's teaset, found in fg_teapot.c
|
||||
* NB: front facing polygons have clockwise winding, not counter clockwise
|
||||
*/
|
||||
FGAPI void FGAPIENTRY glutWireTeacup( double size );
|
||||
FGAPI void FGAPIENTRY glutSolidTeacup( double size );
|
||||
FGAPI void FGAPIENTRY glutWireTeaspoon( double size );
|
||||
FGAPI void FGAPIENTRY glutSolidTeaspoon( double size );
|
||||
|
||||
/*
|
||||
* Extension functions, see fg_ext.c
|
||||
*/
|
||||
typedef void (*GLUTproc)();
|
||||
FGAPI GLUTproc FGAPIENTRY glutGetProcAddress( const char *procName );
|
||||
|
||||
/*
|
||||
* Multi-touch/multi-pointer extensions
|
||||
*/
|
||||
|
||||
#define GLUT_HAS_MULTI 1
|
||||
|
||||
/* TODO: add device_id parameter,
|
||||
cf. http://sourceforge.net/mailarchive/forum.php?thread_name=20120518071314.GA28061%40perso.beuc.net&forum_name=freeglut-developer */
|
||||
FGAPI void FGAPIENTRY glutMultiEntryFunc( void (* callback)( int, int ) );
|
||||
FGAPI void FGAPIENTRY glutMultiButtonFunc( void (* callback)( int, int, int, int, int ) );
|
||||
FGAPI void FGAPIENTRY glutMultiMotionFunc( void (* callback)( int, int, int ) );
|
||||
FGAPI void FGAPIENTRY glutMultiPassiveFunc( void (* callback)( int, int, int ) );
|
||||
|
||||
/*
|
||||
* Joystick functions, see fg_joystick.c
|
||||
*/
|
||||
/* USE OF THESE FUNCTIONS IS DEPRECATED !!!!! */
|
||||
/* If you have a serious need for these functions in your application, please either
|
||||
* contact the "freeglut" developer community at freeglut-developer@lists.sourceforge.net,
|
||||
* switch to the OpenGLUT library, or else port your joystick functionality over to PLIB's
|
||||
* "js" library.
|
||||
*/
|
||||
int glutJoystickGetNumAxes( int ident );
|
||||
int glutJoystickGetNumButtons( int ident );
|
||||
int glutJoystickNotWorking( int ident );
|
||||
float glutJoystickGetDeadBand( int ident, int axis );
|
||||
void glutJoystickSetDeadBand( int ident, int axis, float db );
|
||||
float glutJoystickGetSaturation( int ident, int axis );
|
||||
void glutJoystickSetSaturation( int ident, int axis, float st );
|
||||
void glutJoystickSetMinRange( int ident, float *axes );
|
||||
void glutJoystickSetMaxRange( int ident, float *axes );
|
||||
void glutJoystickSetCenter( int ident, float *axes );
|
||||
void glutJoystickGetMinRange( int ident, float *axes );
|
||||
void glutJoystickGetMaxRange( int ident, float *axes );
|
||||
void glutJoystickGetCenter( int ident, float *axes );
|
||||
|
||||
/*
|
||||
* Initialization functions, see fg_init.c
|
||||
*/
|
||||
/* to get the typedef for va_list */
|
||||
#include <stdarg.h>
|
||||
FGAPI void FGAPIENTRY glutInitContextVersion( int majorVersion, int minorVersion );
|
||||
FGAPI void FGAPIENTRY glutInitContextFlags( int flags );
|
||||
FGAPI void FGAPIENTRY glutInitContextProfile( int profile );
|
||||
FGAPI void FGAPIENTRY glutInitErrorFunc( void (* callback)( const char *fmt, va_list ap ) );
|
||||
FGAPI void FGAPIENTRY glutInitWarningFunc( void (* callback)( const char *fmt, va_list ap ) );
|
||||
|
||||
/* OpenGL >= 2.0 support */
|
||||
FGAPI void FGAPIENTRY glutSetVertexAttribCoord3(GLint attrib);
|
||||
FGAPI void FGAPIENTRY glutSetVertexAttribNormal(GLint attrib);
|
||||
FGAPI void FGAPIENTRY glutSetVertexAttribTexCoord2(GLint attrib);
|
||||
|
||||
/* Mobile platforms lifecycle */
|
||||
FGAPI void FGAPIENTRY glutInitContextFunc(void (* callback)());
|
||||
FGAPI void FGAPIENTRY glutAppStatusFunc(void (* callback)(int));
|
||||
/* state flags that can be passed to callback set by glutAppStatusFunc */
|
||||
#define GLUT_APPSTATUS_PAUSE 0x0001
|
||||
#define GLUT_APPSTATUS_RESUME 0x0002
|
||||
|
||||
/*
|
||||
* GLUT API macro definitions -- the display mode definitions
|
||||
*/
|
||||
#define GLUT_CAPTIONLESS 0x0400
|
||||
#define GLUT_BORDERLESS 0x0800
|
||||
#define GLUT_SRGB 0x1000
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
/*** END OF FILE ***/
|
||||
|
||||
#endif /* __FREEGLUT_EXT_H__ */
|
||||
@@ -1,638 +0,0 @@
|
||||
#ifndef __FREEGLUT_STD_H__
|
||||
#define __FREEGLUT_STD_H__
|
||||
|
||||
/*
|
||||
* freeglut_std.h
|
||||
*
|
||||
* The GLUT-compatible part of the freeglut library include file
|
||||
*
|
||||
* Copyright (c) 1999-2000 Pawel W. Olszta. All Rights Reserved.
|
||||
* Written by Pawel W. Olszta, <olszta@sourceforge.net>
|
||||
* Creation date: Thu Dec 2 1999
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* PAWEL W. OLSZTA BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Under windows, we have to differentiate between static and dynamic libraries
|
||||
*/
|
||||
#ifdef _WIN32
|
||||
/* #pragma may not be supported by some compilers.
|
||||
* Discussion by FreeGLUT developers suggests that
|
||||
* Visual C++ specific code involving pragmas may
|
||||
* need to move to a separate header. 24th Dec 2003
|
||||
*/
|
||||
|
||||
/* Define FREEGLUT_LIB_PRAGMAS to 1 to include library
|
||||
* pragmas or to 0 to exclude library pragmas.
|
||||
* The default behavior depends on the compiler/platform.
|
||||
*/
|
||||
# ifndef FREEGLUT_LIB_PRAGMAS
|
||||
# if ( defined(_MSC_VER) || defined(__WATCOMC__) ) && !defined(_WIN32_WCE)
|
||||
# define FREEGLUT_LIB_PRAGMAS 1
|
||||
# else
|
||||
# define FREEGLUT_LIB_PRAGMAS 0
|
||||
# endif
|
||||
# endif
|
||||
|
||||
# ifndef WIN32_LEAN_AND_MEAN
|
||||
# define WIN32_LEAN_AND_MEAN 1
|
||||
# endif
|
||||
# ifndef NOMINMAX
|
||||
# define NOMINMAX
|
||||
# endif
|
||||
# include <windows.h>
|
||||
|
||||
/* Windows static library */
|
||||
# ifdef FREEGLUT_STATIC
|
||||
|
||||
#error Static linking is not supported with this build. Please remove the FREEGLUT_STATIC preprocessor directive, or download the source code from http://freeglut.sf.net/ and build against that.
|
||||
|
||||
/* Windows shared library (DLL) */
|
||||
# else
|
||||
|
||||
# define FGAPIENTRY __stdcall
|
||||
# if defined(FREEGLUT_EXPORTS)
|
||||
# define FGAPI __declspec(dllexport)
|
||||
# else
|
||||
# define FGAPI __declspec(dllimport)
|
||||
|
||||
/* Link with Win32 shared freeglut lib */
|
||||
# if FREEGLUT_LIB_PRAGMAS
|
||||
# pragma comment (lib, "freeglut.lib")
|
||||
# endif
|
||||
|
||||
# endif
|
||||
|
||||
# endif
|
||||
|
||||
/* Drag in other Windows libraries as required by FreeGLUT */
|
||||
# if FREEGLUT_LIB_PRAGMAS
|
||||
# pragma comment (lib, "glu32.lib") /* link OpenGL Utility lib */
|
||||
# pragma comment (lib, "opengl32.lib") /* link Microsoft OpenGL lib */
|
||||
# pragma comment (lib, "gdi32.lib") /* link Windows GDI lib */
|
||||
# pragma comment (lib, "winmm.lib") /* link Windows MultiMedia lib */
|
||||
# pragma comment (lib, "user32.lib") /* link Windows user lib */
|
||||
# endif
|
||||
|
||||
#else
|
||||
|
||||
/* Non-Windows definition of FGAPI and FGAPIENTRY */
|
||||
# define FGAPI
|
||||
# define FGAPIENTRY
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
* The freeglut and GLUT API versions
|
||||
*/
|
||||
#define FREEGLUT 1
|
||||
#define GLUT_API_VERSION 4
|
||||
#define GLUT_XLIB_IMPLEMENTATION 13
|
||||
/* Deprecated:
|
||||
cf. http://sourceforge.net/mailarchive/forum.php?thread_name=CABcAi1hw7cr4xtigckaGXB5X8wddLfMcbA_rZ3NAuwMrX_zmsw%40mail.gmail.com&forum_name=freeglut-developer */
|
||||
#define FREEGLUT_VERSION_2_0 1
|
||||
|
||||
/*
|
||||
* Always include OpenGL and GLU headers
|
||||
*/
|
||||
/* Note: FREEGLUT_GLES is only used to cleanly bootstrap headers
|
||||
inclusion here; use GLES constants directly
|
||||
(e.g. GL_ES_VERSION_2_0) for all other needs */
|
||||
#ifdef FREEGLUT_GLES
|
||||
# include <EGL/egl.h>
|
||||
# include <GLES/gl.h>
|
||||
# include <GLES2/gl2.h>
|
||||
#elif __APPLE__
|
||||
# include <OpenGL/gl.h>
|
||||
# include <OpenGL/glu.h>
|
||||
#else
|
||||
# include <GL/gl.h>
|
||||
# include <GL/glu.h>
|
||||
#endif
|
||||
|
||||
/*
|
||||
* GLUT API macro definitions -- the special key codes:
|
||||
*/
|
||||
#define GLUT_KEY_F1 0x0001
|
||||
#define GLUT_KEY_F2 0x0002
|
||||
#define GLUT_KEY_F3 0x0003
|
||||
#define GLUT_KEY_F4 0x0004
|
||||
#define GLUT_KEY_F5 0x0005
|
||||
#define GLUT_KEY_F6 0x0006
|
||||
#define GLUT_KEY_F7 0x0007
|
||||
#define GLUT_KEY_F8 0x0008
|
||||
#define GLUT_KEY_F9 0x0009
|
||||
#define GLUT_KEY_F10 0x000A
|
||||
#define GLUT_KEY_F11 0x000B
|
||||
#define GLUT_KEY_F12 0x000C
|
||||
#define GLUT_KEY_LEFT 0x0064
|
||||
#define GLUT_KEY_UP 0x0065
|
||||
#define GLUT_KEY_RIGHT 0x0066
|
||||
#define GLUT_KEY_DOWN 0x0067
|
||||
#define GLUT_KEY_PAGE_UP 0x0068
|
||||
#define GLUT_KEY_PAGE_DOWN 0x0069
|
||||
#define GLUT_KEY_HOME 0x006A
|
||||
#define GLUT_KEY_END 0x006B
|
||||
#define GLUT_KEY_INSERT 0x006C
|
||||
|
||||
/*
|
||||
* GLUT API macro definitions -- mouse state definitions
|
||||
*/
|
||||
#define GLUT_LEFT_BUTTON 0x0000
|
||||
#define GLUT_MIDDLE_BUTTON 0x0001
|
||||
#define GLUT_RIGHT_BUTTON 0x0002
|
||||
#define GLUT_DOWN 0x0000
|
||||
#define GLUT_UP 0x0001
|
||||
#define GLUT_LEFT 0x0000
|
||||
#define GLUT_ENTERED 0x0001
|
||||
|
||||
/*
|
||||
* GLUT API macro definitions -- the display mode definitions
|
||||
*/
|
||||
#define GLUT_RGB 0x0000
|
||||
#define GLUT_RGBA 0x0000
|
||||
#define GLUT_INDEX 0x0001
|
||||
#define GLUT_SINGLE 0x0000
|
||||
#define GLUT_DOUBLE 0x0002
|
||||
#define GLUT_ACCUM 0x0004
|
||||
#define GLUT_ALPHA 0x0008
|
||||
#define GLUT_DEPTH 0x0010
|
||||
#define GLUT_STENCIL 0x0020
|
||||
#define GLUT_MULTISAMPLE 0x0080
|
||||
#define GLUT_STEREO 0x0100
|
||||
#define GLUT_LUMINANCE 0x0200
|
||||
|
||||
/*
|
||||
* GLUT API macro definitions -- windows and menu related definitions
|
||||
*/
|
||||
#define GLUT_MENU_NOT_IN_USE 0x0000
|
||||
#define GLUT_MENU_IN_USE 0x0001
|
||||
#define GLUT_NOT_VISIBLE 0x0000
|
||||
#define GLUT_VISIBLE 0x0001
|
||||
#define GLUT_HIDDEN 0x0000
|
||||
#define GLUT_FULLY_RETAINED 0x0001
|
||||
#define GLUT_PARTIALLY_RETAINED 0x0002
|
||||
#define GLUT_FULLY_COVERED 0x0003
|
||||
|
||||
/*
|
||||
* GLUT API macro definitions -- fonts definitions
|
||||
*
|
||||
* Steve Baker suggested to make it binary compatible with GLUT:
|
||||
*/
|
||||
#if defined(_MSC_VER) || defined(__CYGWIN__) || defined(__MINGW32__) || defined(__WATCOMC__)
|
||||
# define GLUT_STROKE_ROMAN ((void *)0x0000)
|
||||
# define GLUT_STROKE_MONO_ROMAN ((void *)0x0001)
|
||||
# define GLUT_BITMAP_9_BY_15 ((void *)0x0002)
|
||||
# define GLUT_BITMAP_8_BY_13 ((void *)0x0003)
|
||||
# define GLUT_BITMAP_TIMES_ROMAN_10 ((void *)0x0004)
|
||||
# define GLUT_BITMAP_TIMES_ROMAN_24 ((void *)0x0005)
|
||||
# define GLUT_BITMAP_HELVETICA_10 ((void *)0x0006)
|
||||
# define GLUT_BITMAP_HELVETICA_12 ((void *)0x0007)
|
||||
# define GLUT_BITMAP_HELVETICA_18 ((void *)0x0008)
|
||||
#else
|
||||
/*
|
||||
* I don't really know if it's a good idea... But here it goes:
|
||||
*/
|
||||
extern void* glutStrokeRoman;
|
||||
extern void* glutStrokeMonoRoman;
|
||||
extern void* glutBitmap9By15;
|
||||
extern void* glutBitmap8By13;
|
||||
extern void* glutBitmapTimesRoman10;
|
||||
extern void* glutBitmapTimesRoman24;
|
||||
extern void* glutBitmapHelvetica10;
|
||||
extern void* glutBitmapHelvetica12;
|
||||
extern void* glutBitmapHelvetica18;
|
||||
|
||||
/*
|
||||
* Those pointers will be used by following definitions:
|
||||
*/
|
||||
# define GLUT_STROKE_ROMAN ((void *) &glutStrokeRoman)
|
||||
# define GLUT_STROKE_MONO_ROMAN ((void *) &glutStrokeMonoRoman)
|
||||
# define GLUT_BITMAP_9_BY_15 ((void *) &glutBitmap9By15)
|
||||
# define GLUT_BITMAP_8_BY_13 ((void *) &glutBitmap8By13)
|
||||
# define GLUT_BITMAP_TIMES_ROMAN_10 ((void *) &glutBitmapTimesRoman10)
|
||||
# define GLUT_BITMAP_TIMES_ROMAN_24 ((void *) &glutBitmapTimesRoman24)
|
||||
# define GLUT_BITMAP_HELVETICA_10 ((void *) &glutBitmapHelvetica10)
|
||||
# define GLUT_BITMAP_HELVETICA_12 ((void *) &glutBitmapHelvetica12)
|
||||
# define GLUT_BITMAP_HELVETICA_18 ((void *) &glutBitmapHelvetica18)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* GLUT API macro definitions -- the glutGet parameters
|
||||
*/
|
||||
#define GLUT_WINDOW_X 0x0064
|
||||
#define GLUT_WINDOW_Y 0x0065
|
||||
#define GLUT_WINDOW_WIDTH 0x0066
|
||||
#define GLUT_WINDOW_HEIGHT 0x0067
|
||||
#define GLUT_WINDOW_BUFFER_SIZE 0x0068
|
||||
#define GLUT_WINDOW_STENCIL_SIZE 0x0069
|
||||
#define GLUT_WINDOW_DEPTH_SIZE 0x006A
|
||||
#define GLUT_WINDOW_RED_SIZE 0x006B
|
||||
#define GLUT_WINDOW_GREEN_SIZE 0x006C
|
||||
#define GLUT_WINDOW_BLUE_SIZE 0x006D
|
||||
#define GLUT_WINDOW_ALPHA_SIZE 0x006E
|
||||
#define GLUT_WINDOW_ACCUM_RED_SIZE 0x006F
|
||||
#define GLUT_WINDOW_ACCUM_GREEN_SIZE 0x0070
|
||||
#define GLUT_WINDOW_ACCUM_BLUE_SIZE 0x0071
|
||||
#define GLUT_WINDOW_ACCUM_ALPHA_SIZE 0x0072
|
||||
#define GLUT_WINDOW_DOUBLEBUFFER 0x0073
|
||||
#define GLUT_WINDOW_RGBA 0x0074
|
||||
#define GLUT_WINDOW_PARENT 0x0075
|
||||
#define GLUT_WINDOW_NUM_CHILDREN 0x0076
|
||||
#define GLUT_WINDOW_COLORMAP_SIZE 0x0077
|
||||
#define GLUT_WINDOW_NUM_SAMPLES 0x0078
|
||||
#define GLUT_WINDOW_STEREO 0x0079
|
||||
#define GLUT_WINDOW_CURSOR 0x007A
|
||||
|
||||
#define GLUT_SCREEN_WIDTH 0x00C8
|
||||
#define GLUT_SCREEN_HEIGHT 0x00C9
|
||||
#define GLUT_SCREEN_WIDTH_MM 0x00CA
|
||||
#define GLUT_SCREEN_HEIGHT_MM 0x00CB
|
||||
#define GLUT_MENU_NUM_ITEMS 0x012C
|
||||
#define GLUT_DISPLAY_MODE_POSSIBLE 0x0190
|
||||
#define GLUT_INIT_WINDOW_X 0x01F4
|
||||
#define GLUT_INIT_WINDOW_Y 0x01F5
|
||||
#define GLUT_INIT_WINDOW_WIDTH 0x01F6
|
||||
#define GLUT_INIT_WINDOW_HEIGHT 0x01F7
|
||||
#define GLUT_INIT_DISPLAY_MODE 0x01F8
|
||||
#define GLUT_ELAPSED_TIME 0x02BC
|
||||
#define GLUT_WINDOW_FORMAT_ID 0x007B
|
||||
|
||||
/*
|
||||
* GLUT API macro definitions -- the glutDeviceGet parameters
|
||||
*/
|
||||
#define GLUT_HAS_KEYBOARD 0x0258
|
||||
#define GLUT_HAS_MOUSE 0x0259
|
||||
#define GLUT_HAS_SPACEBALL 0x025A
|
||||
#define GLUT_HAS_DIAL_AND_BUTTON_BOX 0x025B
|
||||
#define GLUT_HAS_TABLET 0x025C
|
||||
#define GLUT_NUM_MOUSE_BUTTONS 0x025D
|
||||
#define GLUT_NUM_SPACEBALL_BUTTONS 0x025E
|
||||
#define GLUT_NUM_BUTTON_BOX_BUTTONS 0x025F
|
||||
#define GLUT_NUM_DIALS 0x0260
|
||||
#define GLUT_NUM_TABLET_BUTTONS 0x0261
|
||||
#define GLUT_DEVICE_IGNORE_KEY_REPEAT 0x0262
|
||||
#define GLUT_DEVICE_KEY_REPEAT 0x0263
|
||||
#define GLUT_HAS_JOYSTICK 0x0264
|
||||
#define GLUT_OWNS_JOYSTICK 0x0265
|
||||
#define GLUT_JOYSTICK_BUTTONS 0x0266
|
||||
#define GLUT_JOYSTICK_AXES 0x0267
|
||||
#define GLUT_JOYSTICK_POLL_RATE 0x0268
|
||||
|
||||
/*
|
||||
* GLUT API macro definitions -- the glutLayerGet parameters
|
||||
*/
|
||||
#define GLUT_OVERLAY_POSSIBLE 0x0320
|
||||
#define GLUT_LAYER_IN_USE 0x0321
|
||||
#define GLUT_HAS_OVERLAY 0x0322
|
||||
#define GLUT_TRANSPARENT_INDEX 0x0323
|
||||
#define GLUT_NORMAL_DAMAGED 0x0324
|
||||
#define GLUT_OVERLAY_DAMAGED 0x0325
|
||||
|
||||
/*
|
||||
* GLUT API macro definitions -- the glutVideoResizeGet parameters
|
||||
*/
|
||||
#define GLUT_VIDEO_RESIZE_POSSIBLE 0x0384
|
||||
#define GLUT_VIDEO_RESIZE_IN_USE 0x0385
|
||||
#define GLUT_VIDEO_RESIZE_X_DELTA 0x0386
|
||||
#define GLUT_VIDEO_RESIZE_Y_DELTA 0x0387
|
||||
#define GLUT_VIDEO_RESIZE_WIDTH_DELTA 0x0388
|
||||
#define GLUT_VIDEO_RESIZE_HEIGHT_DELTA 0x0389
|
||||
#define GLUT_VIDEO_RESIZE_X 0x038A
|
||||
#define GLUT_VIDEO_RESIZE_Y 0x038B
|
||||
#define GLUT_VIDEO_RESIZE_WIDTH 0x038C
|
||||
#define GLUT_VIDEO_RESIZE_HEIGHT 0x038D
|
||||
|
||||
/*
|
||||
* GLUT API macro definitions -- the glutUseLayer parameters
|
||||
*/
|
||||
#define GLUT_NORMAL 0x0000
|
||||
#define GLUT_OVERLAY 0x0001
|
||||
|
||||
/*
|
||||
* GLUT API macro definitions -- the glutGetModifiers parameters
|
||||
*/
|
||||
#define GLUT_ACTIVE_SHIFT 0x0001
|
||||
#define GLUT_ACTIVE_CTRL 0x0002
|
||||
#define GLUT_ACTIVE_ALT 0x0004
|
||||
|
||||
/*
|
||||
* GLUT API macro definitions -- the glutSetCursor parameters
|
||||
*/
|
||||
#define GLUT_CURSOR_RIGHT_ARROW 0x0000
|
||||
#define GLUT_CURSOR_LEFT_ARROW 0x0001
|
||||
#define GLUT_CURSOR_INFO 0x0002
|
||||
#define GLUT_CURSOR_DESTROY 0x0003
|
||||
#define GLUT_CURSOR_HELP 0x0004
|
||||
#define GLUT_CURSOR_CYCLE 0x0005
|
||||
#define GLUT_CURSOR_SPRAY 0x0006
|
||||
#define GLUT_CURSOR_WAIT 0x0007
|
||||
#define GLUT_CURSOR_TEXT 0x0008
|
||||
#define GLUT_CURSOR_CROSSHAIR 0x0009
|
||||
#define GLUT_CURSOR_UP_DOWN 0x000A
|
||||
#define GLUT_CURSOR_LEFT_RIGHT 0x000B
|
||||
#define GLUT_CURSOR_TOP_SIDE 0x000C
|
||||
#define GLUT_CURSOR_BOTTOM_SIDE 0x000D
|
||||
#define GLUT_CURSOR_LEFT_SIDE 0x000E
|
||||
#define GLUT_CURSOR_RIGHT_SIDE 0x000F
|
||||
#define GLUT_CURSOR_TOP_LEFT_CORNER 0x0010
|
||||
#define GLUT_CURSOR_TOP_RIGHT_CORNER 0x0011
|
||||
#define GLUT_CURSOR_BOTTOM_RIGHT_CORNER 0x0012
|
||||
#define GLUT_CURSOR_BOTTOM_LEFT_CORNER 0x0013
|
||||
#define GLUT_CURSOR_INHERIT 0x0064
|
||||
#define GLUT_CURSOR_NONE 0x0065
|
||||
#define GLUT_CURSOR_FULL_CROSSHAIR 0x0066
|
||||
|
||||
/*
|
||||
* GLUT API macro definitions -- RGB color component specification definitions
|
||||
*/
|
||||
#define GLUT_RED 0x0000
|
||||
#define GLUT_GREEN 0x0001
|
||||
#define GLUT_BLUE 0x0002
|
||||
|
||||
/*
|
||||
* GLUT API macro definitions -- additional keyboard and joystick definitions
|
||||
*/
|
||||
#define GLUT_KEY_REPEAT_OFF 0x0000
|
||||
#define GLUT_KEY_REPEAT_ON 0x0001
|
||||
#define GLUT_KEY_REPEAT_DEFAULT 0x0002
|
||||
|
||||
#define GLUT_JOYSTICK_BUTTON_A 0x0001
|
||||
#define GLUT_JOYSTICK_BUTTON_B 0x0002
|
||||
#define GLUT_JOYSTICK_BUTTON_C 0x0004
|
||||
#define GLUT_JOYSTICK_BUTTON_D 0x0008
|
||||
|
||||
/*
|
||||
* GLUT API macro definitions -- game mode definitions
|
||||
*/
|
||||
#define GLUT_GAME_MODE_ACTIVE 0x0000
|
||||
#define GLUT_GAME_MODE_POSSIBLE 0x0001
|
||||
#define GLUT_GAME_MODE_WIDTH 0x0002
|
||||
#define GLUT_GAME_MODE_HEIGHT 0x0003
|
||||
#define GLUT_GAME_MODE_PIXEL_DEPTH 0x0004
|
||||
#define GLUT_GAME_MODE_REFRESH_RATE 0x0005
|
||||
#define GLUT_GAME_MODE_DISPLAY_CHANGED 0x0006
|
||||
|
||||
/*
|
||||
* Initialization functions, see fglut_init.c
|
||||
*/
|
||||
FGAPI void FGAPIENTRY glutInit( int* pargc, char** argv );
|
||||
FGAPI void FGAPIENTRY glutInitWindowPosition( int x, int y );
|
||||
FGAPI void FGAPIENTRY glutInitWindowSize( int width, int height );
|
||||
FGAPI void FGAPIENTRY glutInitDisplayMode( unsigned int displayMode );
|
||||
FGAPI void FGAPIENTRY glutInitDisplayString( const char* displayMode );
|
||||
|
||||
/*
|
||||
* Process loop function, see fg_main.c
|
||||
*/
|
||||
FGAPI void FGAPIENTRY glutMainLoop( void );
|
||||
|
||||
/*
|
||||
* Window management functions, see fg_window.c
|
||||
*/
|
||||
FGAPI int FGAPIENTRY glutCreateWindow( const char* title );
|
||||
FGAPI int FGAPIENTRY glutCreateSubWindow( int window, int x, int y, int width, int height );
|
||||
FGAPI void FGAPIENTRY glutDestroyWindow( int window );
|
||||
FGAPI void FGAPIENTRY glutSetWindow( int window );
|
||||
FGAPI int FGAPIENTRY glutGetWindow( void );
|
||||
FGAPI void FGAPIENTRY glutSetWindowTitle( const char* title );
|
||||
FGAPI void FGAPIENTRY glutSetIconTitle( const char* title );
|
||||
FGAPI void FGAPIENTRY glutReshapeWindow( int width, int height );
|
||||
FGAPI void FGAPIENTRY glutPositionWindow( int x, int y );
|
||||
FGAPI void FGAPIENTRY glutShowWindow( void );
|
||||
FGAPI void FGAPIENTRY glutHideWindow( void );
|
||||
FGAPI void FGAPIENTRY glutIconifyWindow( void );
|
||||
FGAPI void FGAPIENTRY glutPushWindow( void );
|
||||
FGAPI void FGAPIENTRY glutPopWindow( void );
|
||||
FGAPI void FGAPIENTRY glutFullScreen( void );
|
||||
|
||||
/*
|
||||
* Display-related functions, see fg_display.c
|
||||
*/
|
||||
FGAPI void FGAPIENTRY glutPostWindowRedisplay( int window );
|
||||
FGAPI void FGAPIENTRY glutPostRedisplay( void );
|
||||
FGAPI void FGAPIENTRY glutSwapBuffers( void );
|
||||
|
||||
/*
|
||||
* Mouse cursor functions, see fg_cursor.c
|
||||
*/
|
||||
FGAPI void FGAPIENTRY glutWarpPointer( int x, int y );
|
||||
FGAPI void FGAPIENTRY glutSetCursor( int cursor );
|
||||
|
||||
/*
|
||||
* Overlay stuff, see fg_overlay.c
|
||||
*/
|
||||
FGAPI void FGAPIENTRY glutEstablishOverlay( void );
|
||||
FGAPI void FGAPIENTRY glutRemoveOverlay( void );
|
||||
FGAPI void FGAPIENTRY glutUseLayer( GLenum layer );
|
||||
FGAPI void FGAPIENTRY glutPostOverlayRedisplay( void );
|
||||
FGAPI void FGAPIENTRY glutPostWindowOverlayRedisplay( int window );
|
||||
FGAPI void FGAPIENTRY glutShowOverlay( void );
|
||||
FGAPI void FGAPIENTRY glutHideOverlay( void );
|
||||
|
||||
/*
|
||||
* Menu stuff, see fg_menu.c
|
||||
*/
|
||||
FGAPI int FGAPIENTRY glutCreateMenu( void (* callback)( int menu ) );
|
||||
FGAPI void FGAPIENTRY glutDestroyMenu( int menu );
|
||||
FGAPI int FGAPIENTRY glutGetMenu( void );
|
||||
FGAPI void FGAPIENTRY glutSetMenu( int menu );
|
||||
FGAPI void FGAPIENTRY glutAddMenuEntry( const char* label, int value );
|
||||
FGAPI void FGAPIENTRY glutAddSubMenu( const char* label, int subMenu );
|
||||
FGAPI void FGAPIENTRY glutChangeToMenuEntry( int item, const char* label, int value );
|
||||
FGAPI void FGAPIENTRY glutChangeToSubMenu( int item, const char* label, int value );
|
||||
FGAPI void FGAPIENTRY glutRemoveMenuItem( int item );
|
||||
FGAPI void FGAPIENTRY glutAttachMenu( int button );
|
||||
FGAPI void FGAPIENTRY glutDetachMenu( int button );
|
||||
|
||||
/*
|
||||
* Global callback functions, see fg_callbacks.c
|
||||
*/
|
||||
FGAPI void FGAPIENTRY glutTimerFunc( unsigned int time, void (* callback)( int ), int value );
|
||||
FGAPI void FGAPIENTRY glutIdleFunc( void (* callback)( void ) );
|
||||
|
||||
/*
|
||||
* Window-specific callback functions, see fg_callbacks.c
|
||||
*/
|
||||
FGAPI void FGAPIENTRY glutKeyboardFunc( void (* callback)( unsigned char, int, int ) );
|
||||
FGAPI void FGAPIENTRY glutSpecialFunc( void (* callback)( int, int, int ) );
|
||||
FGAPI void FGAPIENTRY glutReshapeFunc( void (* callback)( int, int ) );
|
||||
FGAPI void FGAPIENTRY glutVisibilityFunc( void (* callback)( int ) );
|
||||
FGAPI void FGAPIENTRY glutDisplayFunc( void (* callback)( void ) );
|
||||
FGAPI void FGAPIENTRY glutMouseFunc( void (* callback)( int, int, int, int ) );
|
||||
FGAPI void FGAPIENTRY glutMotionFunc( void (* callback)( int, int ) );
|
||||
FGAPI void FGAPIENTRY glutPassiveMotionFunc( void (* callback)( int, int ) );
|
||||
FGAPI void FGAPIENTRY glutEntryFunc( void (* callback)( int ) );
|
||||
|
||||
FGAPI void FGAPIENTRY glutKeyboardUpFunc( void (* callback)( unsigned char, int, int ) );
|
||||
FGAPI void FGAPIENTRY glutSpecialUpFunc( void (* callback)( int, int, int ) );
|
||||
FGAPI void FGAPIENTRY glutJoystickFunc( void (* callback)( unsigned int, int, int, int ), int pollInterval );
|
||||
FGAPI void FGAPIENTRY glutMenuStateFunc( void (* callback)( int ) );
|
||||
FGAPI void FGAPIENTRY glutMenuStatusFunc( void (* callback)( int, int, int ) );
|
||||
FGAPI void FGAPIENTRY glutOverlayDisplayFunc( void (* callback)( void ) );
|
||||
FGAPI void FGAPIENTRY glutWindowStatusFunc( void (* callback)( int ) );
|
||||
|
||||
FGAPI void FGAPIENTRY glutSpaceballMotionFunc( void (* callback)( int, int, int ) );
|
||||
FGAPI void FGAPIENTRY glutSpaceballRotateFunc( void (* callback)( int, int, int ) );
|
||||
FGAPI void FGAPIENTRY glutSpaceballButtonFunc( void (* callback)( int, int ) );
|
||||
FGAPI void FGAPIENTRY glutButtonBoxFunc( void (* callback)( int, int ) );
|
||||
FGAPI void FGAPIENTRY glutDialsFunc( void (* callback)( int, int ) );
|
||||
FGAPI void FGAPIENTRY glutTabletMotionFunc( void (* callback)( int, int ) );
|
||||
FGAPI void FGAPIENTRY glutTabletButtonFunc( void (* callback)( int, int, int, int ) );
|
||||
|
||||
/*
|
||||
* State setting and retrieval functions, see fg_state.c
|
||||
*/
|
||||
FGAPI int FGAPIENTRY glutGet( GLenum query );
|
||||
FGAPI int FGAPIENTRY glutDeviceGet( GLenum query );
|
||||
FGAPI int FGAPIENTRY glutGetModifiers( void );
|
||||
FGAPI int FGAPIENTRY glutLayerGet( GLenum query );
|
||||
|
||||
/*
|
||||
* Font stuff, see fg_font.c
|
||||
*/
|
||||
FGAPI void FGAPIENTRY glutBitmapCharacter( void* font, int character );
|
||||
FGAPI int FGAPIENTRY glutBitmapWidth( void* font, int character );
|
||||
FGAPI void FGAPIENTRY glutStrokeCharacter( void* font, int character );
|
||||
FGAPI int FGAPIENTRY glutStrokeWidth( void* font, int character );
|
||||
FGAPI GLfloat FGAPIENTRY glutStrokeWidthf( void* font, int character ); /* GLUT 3.8 */
|
||||
FGAPI int FGAPIENTRY glutBitmapLength( void* font, const unsigned char* string );
|
||||
FGAPI int FGAPIENTRY glutStrokeLength( void* font, const unsigned char* string );
|
||||
FGAPI GLfloat FGAPIENTRY glutStrokeLengthf( void* font, const unsigned char *string ); /* GLUT 3.8 */
|
||||
|
||||
/*
|
||||
* Geometry functions, see fg_geometry.c
|
||||
*/
|
||||
|
||||
FGAPI void FGAPIENTRY glutWireCube( double size );
|
||||
FGAPI void FGAPIENTRY glutSolidCube( double size );
|
||||
FGAPI void FGAPIENTRY glutWireSphere( double radius, GLint slices, GLint stacks );
|
||||
FGAPI void FGAPIENTRY glutSolidSphere( double radius, GLint slices, GLint stacks );
|
||||
FGAPI void FGAPIENTRY glutWireCone( double base, double height, GLint slices, GLint stacks );
|
||||
FGAPI void FGAPIENTRY glutSolidCone( double base, double height, GLint slices, GLint stacks );
|
||||
FGAPI void FGAPIENTRY glutWireTorus( double innerRadius, double outerRadius, GLint sides, GLint rings );
|
||||
FGAPI void FGAPIENTRY glutSolidTorus( double innerRadius, double outerRadius, GLint sides, GLint rings );
|
||||
FGAPI void FGAPIENTRY glutWireDodecahedron( void );
|
||||
FGAPI void FGAPIENTRY glutSolidDodecahedron( void );
|
||||
FGAPI void FGAPIENTRY glutWireOctahedron( void );
|
||||
FGAPI void FGAPIENTRY glutSolidOctahedron( void );
|
||||
FGAPI void FGAPIENTRY glutWireTetrahedron( void );
|
||||
FGAPI void FGAPIENTRY glutSolidTetrahedron( void );
|
||||
FGAPI void FGAPIENTRY glutWireIcosahedron( void );
|
||||
FGAPI void FGAPIENTRY glutSolidIcosahedron( void );
|
||||
|
||||
/*
|
||||
* Teapot rendering functions, found in fg_teapot.c
|
||||
* NB: front facing polygons have clockwise winding, not counter clockwise
|
||||
*/
|
||||
FGAPI void FGAPIENTRY glutWireTeapot( double size );
|
||||
FGAPI void FGAPIENTRY glutSolidTeapot( double size );
|
||||
|
||||
/*
|
||||
* Game mode functions, see fg_gamemode.c
|
||||
*/
|
||||
FGAPI void FGAPIENTRY glutGameModeString( const char* string );
|
||||
FGAPI int FGAPIENTRY glutEnterGameMode( void );
|
||||
FGAPI void FGAPIENTRY glutLeaveGameMode( void );
|
||||
FGAPI int FGAPIENTRY glutGameModeGet( GLenum query );
|
||||
|
||||
/*
|
||||
* Video resize functions, see fg_videoresize.c
|
||||
*/
|
||||
FGAPI int FGAPIENTRY glutVideoResizeGet( GLenum query );
|
||||
FGAPI void FGAPIENTRY glutSetupVideoResizing( void );
|
||||
FGAPI void FGAPIENTRY glutStopVideoResizing( void );
|
||||
FGAPI void FGAPIENTRY glutVideoResize( int x, int y, int width, int height );
|
||||
FGAPI void FGAPIENTRY glutVideoPan( int x, int y, int width, int height );
|
||||
|
||||
/*
|
||||
* Colormap functions, see fg_misc.c
|
||||
*/
|
||||
FGAPI void FGAPIENTRY glutSetColor( int color, GLfloat red, GLfloat green, GLfloat blue );
|
||||
FGAPI GLfloat FGAPIENTRY glutGetColor( int color, int component );
|
||||
FGAPI void FGAPIENTRY glutCopyColormap( int window );
|
||||
|
||||
/*
|
||||
* Misc keyboard and joystick functions, see fg_misc.c
|
||||
*/
|
||||
FGAPI void FGAPIENTRY glutIgnoreKeyRepeat( int ignore );
|
||||
FGAPI void FGAPIENTRY glutSetKeyRepeat( int repeatMode );
|
||||
FGAPI void FGAPIENTRY glutForceJoystickFunc( void );
|
||||
|
||||
/*
|
||||
* Misc functions, see fg_misc.c
|
||||
*/
|
||||
FGAPI int FGAPIENTRY glutExtensionSupported( const char* extension );
|
||||
FGAPI void FGAPIENTRY glutReportErrors( void );
|
||||
|
||||
/* Comment from glut.h of classic GLUT:
|
||||
|
||||
Win32 has an annoying issue where there are multiple C run-time
|
||||
libraries (CRTs). If the executable is linked with a different CRT
|
||||
from the GLUT DLL, the GLUT DLL will not share the same CRT static
|
||||
data seen by the executable. In particular, atexit callbacks registered
|
||||
in the executable will not be called if GLUT calls its (different)
|
||||
exit routine). GLUT is typically built with the
|
||||
"/MD" option (the CRT with multithreading DLL support), but the Visual
|
||||
C++ linker default is "/ML" (the single threaded CRT).
|
||||
|
||||
One workaround to this issue is requiring users to always link with
|
||||
the same CRT as GLUT is compiled with. That requires users supply a
|
||||
non-standard option. GLUT 3.7 has its own built-in workaround where
|
||||
the executable's "exit" function pointer is covertly passed to GLUT.
|
||||
GLUT then calls the executable's exit function pointer to ensure that
|
||||
any "atexit" calls registered by the application are called if GLUT
|
||||
needs to exit.
|
||||
|
||||
Note that the __glut*WithExit routines should NEVER be called directly.
|
||||
To avoid the atexit workaround, #define GLUT_DISABLE_ATEXIT_HACK. */
|
||||
|
||||
/* to get the prototype for exit() */
|
||||
#include <stdlib.h>
|
||||
|
||||
#if defined(_WIN32) && !defined(GLUT_DISABLE_ATEXIT_HACK) && !defined(__WATCOMC__)
|
||||
FGAPI void FGAPIENTRY __glutInitWithExit(int *argcp, char **argv, void (__cdecl *exitfunc)(int));
|
||||
FGAPI int FGAPIENTRY __glutCreateWindowWithExit(const char *title, void (__cdecl *exitfunc)(int));
|
||||
FGAPI int FGAPIENTRY __glutCreateMenuWithExit(void (* func)(int), void (__cdecl *exitfunc)(int));
|
||||
#ifndef FREEGLUT_BUILDING_LIB
|
||||
#if defined(__GNUC__)
|
||||
#define FGUNUSED __attribute__((unused))
|
||||
#else
|
||||
#define FGUNUSED
|
||||
#endif
|
||||
static void FGAPIENTRY FGUNUSED glutInit_ATEXIT_HACK(int *argcp, char **argv) { __glutInitWithExit(argcp, argv, exit); }
|
||||
#define glutInit glutInit_ATEXIT_HACK
|
||||
static int FGAPIENTRY FGUNUSED glutCreateWindow_ATEXIT_HACK(const char *title) { return __glutCreateWindowWithExit(title, exit); }
|
||||
#define glutCreateWindow glutCreateWindow_ATEXIT_HACK
|
||||
static int FGAPIENTRY FGUNUSED glutCreateMenu_ATEXIT_HACK(void (* func)(int)) { return __glutCreateMenuWithExit(func, exit); }
|
||||
#define glutCreateMenu glutCreateMenu_ATEXIT_HACK
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
/*** END OF FILE ***/
|
||||
|
||||
#endif /* __FREEGLUT_STD_H__ */
|
||||
@@ -1,21 +0,0 @@
|
||||
#ifndef __GLUT_H__
|
||||
#define __GLUT_H__
|
||||
|
||||
/*
|
||||
* glut.h
|
||||
*
|
||||
* The freeglut library include file
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* PAWEL W. OLSZTA BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "freeglut_std.h"
|
||||
|
||||
/*** END OF FILE ***/
|
||||
|
||||
#endif /* __GLUT_H__ */
|
||||
Binary file not shown.
Binary file not shown.
3225
ref/glad/include/glad/glad.h
Normal file
3225
ref/glad/include/glad/glad.h
Normal file
File diff suppressed because it is too large
Load Diff
1850
ref/glad/src/glad.c
Normal file
1850
ref/glad/src/glad.c
Normal file
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
171
renderer.cpp
171
renderer.cpp
@@ -94,11 +94,20 @@ bool opengl_renderer::Init(GLFWwindow *Window)
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
glEnable(GL_BLEND);
|
||||
|
||||
glClearDepth(0.0f);
|
||||
if (!Global.use_gles)
|
||||
glClearDepth(0.0f);
|
||||
else
|
||||
glClearDepthf(0.0f);
|
||||
|
||||
glDepthFunc(GL_GEQUAL);
|
||||
|
||||
if (GLEW_ARB_clip_control)
|
||||
if (GLAD_GL_ARB_clip_control)
|
||||
glClipControl(GL_LOWER_LEFT, GL_ZERO_TO_ONE);
|
||||
else if (GLAD_GL_EXT_clip_control)
|
||||
glClipControlEXT(GL_LOWER_LEFT_EXT, GL_ZERO_TO_ONE_EXT);
|
||||
|
||||
if (!Global.use_gles)
|
||||
glEnable(GL_PROGRAM_POINT_SIZE);
|
||||
|
||||
gl::glsl_common_setup();
|
||||
|
||||
@@ -120,7 +129,7 @@ bool opengl_renderer::Init(GLFWwindow *Window)
|
||||
{
|
||||
|
||||
opengl_light light;
|
||||
light.id = GL_LIGHT1 + idx;
|
||||
light.id = 1 + idx;
|
||||
|
||||
light.is_directional = false;
|
||||
|
||||
@@ -173,7 +182,7 @@ bool opengl_renderer::Init(GLFWwindow *Window)
|
||||
scene_ubo->update(scene_ubs);
|
||||
|
||||
int samples = 1 << Global.iMultisampling;
|
||||
if (samples > 1)
|
||||
if (!Global.use_gles && samples > 1)
|
||||
glEnable(GL_MULTISAMPLE);
|
||||
|
||||
if (!Global.gfx_skippipeline)
|
||||
@@ -298,26 +307,29 @@ std::unique_ptr<gl::program> opengl_renderer::make_shader(std::string v, std::st
|
||||
|
||||
bool opengl_renderer::Render()
|
||||
{
|
||||
|
||||
Timer::subsystem.gfx_total.stop();
|
||||
Timer::subsystem.gfx_total.start(); // note: gfx_total is actually frame total, clean this up
|
||||
Timer::subsystem.gfx_color.start();
|
||||
|
||||
GLuint gl_time_ready = 0;
|
||||
if (m_gltimequery)
|
||||
GLuint gl_time_ready;
|
||||
if (!Global.use_gles)
|
||||
{
|
||||
glGetQueryObjectuiv(m_gltimequery, GL_QUERY_RESULT_AVAILABLE, &gl_time_ready);
|
||||
if (gl_time_ready)
|
||||
glGetQueryObjectui64v(m_gltimequery, GL_QUERY_RESULT, &m_gllasttime);
|
||||
}
|
||||
else
|
||||
{
|
||||
glGenQueries(1, &m_gltimequery);
|
||||
gl_time_ready = 1;
|
||||
}
|
||||
gl_time_ready = 0;
|
||||
if (m_gltimequery)
|
||||
{
|
||||
glGetQueryObjectuiv(m_gltimequery, GL_QUERY_RESULT_AVAILABLE, &gl_time_ready);
|
||||
if (gl_time_ready)
|
||||
glGetQueryObjectui64v(m_gltimequery, GL_QUERY_RESULT, &m_gllasttime);
|
||||
}
|
||||
else
|
||||
{
|
||||
glGenQueries(1, &m_gltimequery);
|
||||
gl_time_ready = 1;
|
||||
}
|
||||
|
||||
if (gl_time_ready)
|
||||
glBeginQuery(GL_TIME_ELAPSED, m_gltimequery);
|
||||
if (gl_time_ready)
|
||||
glBeginQuery(GL_TIME_ELAPSED, m_gltimequery);
|
||||
}
|
||||
|
||||
// fetch simulation data
|
||||
if (simulation::is_ready)
|
||||
@@ -334,17 +346,20 @@ bool opengl_renderer::Render()
|
||||
Render_pass(rendermode::color);
|
||||
Timer::subsystem.gfx_color.stop();
|
||||
|
||||
if (gl_time_ready)
|
||||
glEndQuery(GL_TIME_ELAPSED);
|
||||
|
||||
m_drawcount = m_cellqueue.size();
|
||||
m_debugtimestext.clear();
|
||||
m_debugtimestext += "cpu: " + to_string(Timer::subsystem.gfx_color.average(), 2) + " ms (" + std::to_string(m_cellqueue.size()) + " sectors)\n" +=
|
||||
"cpu swap: " + to_string(Timer::subsystem.gfx_swap.average(), 2) + " ms\n" += "uilayer: " + to_string(Timer::subsystem.gfx_gui.average(), 2) + "ms\n" +=
|
||||
"mainloop total: " + to_string(Timer::subsystem.mainloop_total.average(), 2) + "ms\n";
|
||||
|
||||
if (m_gllasttime)
|
||||
m_debugtimestext += "gpu: " + to_string((double)(m_gllasttime / 1000ULL) / 1000.0, 3) + "ms";
|
||||
if (!Global.use_gles)
|
||||
{
|
||||
if (gl_time_ready)
|
||||
glEndQuery(GL_TIME_ELAPSED);
|
||||
|
||||
if (m_gllasttime)
|
||||
m_debugtimestext += "gpu: " + to_string((double)(m_gllasttime / 1000ULL) / 1000.0, 3) + "ms";
|
||||
}
|
||||
|
||||
m_debugstatstext = "drawcalls: " + to_string(m_debugstats.drawcalls) + "\n" + " vehicles: " + to_string(m_debugstats.dynamics) + "\n" + " models: " + to_string(m_debugstats.models) + "\n" +
|
||||
" submodels: " + to_string(m_debugstats.submodels) + "\n" + " paths: " + to_string(m_debugstats.paths) + "\n" + " shapes: " + to_string(m_debugstats.shapes) + "\n" +
|
||||
@@ -395,10 +410,13 @@ void opengl_renderer::Render_pass(rendermode const Mode)
|
||||
|
||||
m_colorpass = m_renderpass;
|
||||
|
||||
if (Global.bWireFrame)
|
||||
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
|
||||
else
|
||||
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
|
||||
if (!Global.use_gles)
|
||||
{
|
||||
if (Global.bWireFrame)
|
||||
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
|
||||
else
|
||||
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
|
||||
}
|
||||
|
||||
setup_shadow_map(nullptr, m_renderpass);
|
||||
setup_env_map(nullptr);
|
||||
@@ -442,8 +460,9 @@ void opengl_renderer::Render_pass(rendermode const Mode)
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!Global.use_gles)
|
||||
glEnable(GL_FRAMEBUFFER_SRGB);
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
||||
glEnable(GL_FRAMEBUFFER_SRGB);
|
||||
glViewport(0, 0, Global.iWindowWidth, Global.iWindowHeight);
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
}
|
||||
@@ -523,7 +542,8 @@ void opengl_renderer::Render_pass(rendermode const Mode)
|
||||
setup_shadow_map(nullptr, m_renderpass);
|
||||
setup_env_map(nullptr);
|
||||
|
||||
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
|
||||
if (!Global.use_gles)
|
||||
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
|
||||
|
||||
if (!Global.gfx_skippipeline)
|
||||
{
|
||||
@@ -543,13 +563,15 @@ void opengl_renderer::Render_pass(rendermode const Mode)
|
||||
m_msaa_fb->blit_to(*m_main2_fb.get(), Global.gfx_framebuffer_width, Global.gfx_framebuffer_height, GL_COLOR_BUFFER_BIT, GL_COLOR_ATTACHMENT0);
|
||||
}
|
||||
|
||||
glEnable(GL_FRAMEBUFFER_SRGB);
|
||||
if (!Global.use_gles)
|
||||
glEnable(GL_FRAMEBUFFER_SRGB);
|
||||
glViewport(0, 0, Global.iWindowWidth, Global.iWindowHeight);
|
||||
m_pfx_tonemapping->apply(*m_main2_tex, nullptr);
|
||||
opengl_texture::reset_unit_cache();
|
||||
}
|
||||
|
||||
glDisable(GL_FRAMEBUFFER_SRGB);
|
||||
if (!Global.use_gles)
|
||||
glDisable(GL_FRAMEBUFFER_SRGB);
|
||||
|
||||
glDebug("uilayer render");
|
||||
Application.render_ui();
|
||||
@@ -753,7 +775,7 @@ bool opengl_renderer::Render_reflections()
|
||||
|
||||
glm::mat4 opengl_renderer::perspective_projection(float fovy, float aspect, float znear, float zfar)
|
||||
{
|
||||
if (GLEW_ARB_clip_control)
|
||||
if (GLAD_GL_ARB_clip_control || GLAD_GL_EXT_clip_control)
|
||||
{
|
||||
const float f = 1.0f / tan(fovy / 2.0f);
|
||||
|
||||
@@ -786,7 +808,7 @@ glm::mat4 opengl_renderer::perpsective_frustumtest_projection(float fovy, float
|
||||
glm::mat4 opengl_renderer::ortho_projection(float l, float r, float b, float t, float znear, float zfar)
|
||||
{
|
||||
glm::mat4 proj = glm::ortho(l, r, b, t, znear, zfar);
|
||||
if (GLEW_ARB_clip_control)
|
||||
if (GLAD_GL_ARB_clip_control || GLAD_GL_EXT_clip_control)
|
||||
// when clip_control available, use projection matrix with 1..0 Z range
|
||||
return glm::mat4( //
|
||||
1.0f, 0.0f, 0.0f, 0.0f, //
|
||||
@@ -1078,7 +1100,7 @@ void opengl_renderer::setup_shadow_map(opengl_texture *tex, renderpass_config co
|
||||
{
|
||||
glm::mat4 coordmove;
|
||||
|
||||
if (GLEW_ARB_clip_control)
|
||||
if (GLAD_GL_ARB_clip_control || GLAD_GL_EXT_clip_control)
|
||||
// transform 1..-1 NDC xy coordinates to 1..0
|
||||
coordmove = glm::mat4( //
|
||||
0.5, 0.0, 0.0, 0.0, //
|
||||
@@ -1341,7 +1363,7 @@ void opengl_renderer::Bind_Material(material_handle const Material, TSubModel *s
|
||||
else
|
||||
model_ubs.alpha_mult = 1.0f;
|
||||
|
||||
if (GLEW_ARB_multi_bind)
|
||||
if (GLAD_GL_ARB_multi_bind)
|
||||
{
|
||||
GLuint lastdiff = 0;
|
||||
size_t i;
|
||||
@@ -2293,14 +2315,14 @@ void opengl_renderer::Render(TSubModel *Submodel)
|
||||
{
|
||||
// fake fog halo
|
||||
float const fogfactor{interpolate(2.f, 1.f, clamp<float>(Global.fFogEnd / 2000, 0.f, 1.f)) * std::max(1.f, Global.Overcast)};
|
||||
glPointSize(pointsize * fogfactor * 2.0f);
|
||||
model_ubs.param[1].x = pointsize * fogfactor * 2.0f;
|
||||
model_ubs.param[0] = glm::vec4(glm::vec3(Submodel->f4Diffuse), Submodel->fVisible * std::min(1.f, lightlevel) * 0.5f);
|
||||
|
||||
glDepthMask(GL_FALSE);
|
||||
draw(Submodel->m_geometry);
|
||||
glDepthMask(GL_TRUE);
|
||||
}
|
||||
glPointSize(pointsize * 2.0f);
|
||||
model_ubs.param[1].x = pointsize * 2.0f;
|
||||
model_ubs.param[0] = glm::vec4(glm::vec3(Submodel->f4Diffuse), Submodel->fVisible * std::min(1.f, lightlevel));
|
||||
|
||||
draw(Submodel->m_geometry);
|
||||
@@ -2336,7 +2358,7 @@ void opengl_renderer::Render(TSubModel *Submodel)
|
||||
Bind_Material(Submodel->m_material, Submodel);
|
||||
|
||||
// main draw call
|
||||
glPointSize(2.0f * 2.0f);
|
||||
model_ubs.param[1].x = 2.0f * 2.0f;
|
||||
|
||||
draw(Submodel->m_geometry);
|
||||
}
|
||||
@@ -3245,11 +3267,11 @@ TSubModel const *opengl_renderer::Update_Pick_Control()
|
||||
glm::ivec2 pickbufferpos;
|
||||
pickbufferpos = glm::ivec2{mousepos.x * EU07_PICKBUFFERSIZE / std::max(1, Global.iWindowWidth), mousepos.y * EU07_PICKBUFFERSIZE / std::max(1, Global.iWindowHeight)};
|
||||
|
||||
unsigned char pickreadout[3];
|
||||
unsigned char pickreadout[4];
|
||||
|
||||
// m7t: ! replace with PBO and wait frame or two to improve performance
|
||||
m_pick_fb->bind();
|
||||
::glReadPixels(pickbufferpos.x, pickbufferpos.y, 1, 1, GL_RGB, GL_UNSIGNED_BYTE, pickreadout);
|
||||
::glReadPixels(pickbufferpos.x, pickbufferpos.y, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, pickreadout);
|
||||
m_pick_fb->unbind();
|
||||
|
||||
auto const controlindex = pick_index(glm::ivec3{pickreadout[0], pickreadout[1], pickreadout[2]});
|
||||
@@ -3396,9 +3418,18 @@ void opengl_renderer::Update(double const Deltatime)
|
||||
auto const glerror = ::glGetError();
|
||||
if (glerror != GL_NO_ERROR)
|
||||
{
|
||||
std::string glerrorstring((char *)::gluErrorString(glerror));
|
||||
win1250_to_ascii(glerrorstring);
|
||||
Global.LastGLError = std::to_string(glerror) + " (" + glerrorstring + ")";
|
||||
std::string glerrorstring;
|
||||
if (glerror == GL_INVALID_ENUM)
|
||||
glerrorstring = "GL_INVALID_ENUM";
|
||||
else if (glerror == GL_INVALID_VALUE)
|
||||
glerrorstring = "GL_INVALID_VALUE";
|
||||
else if (glerror == GL_INVALID_OPERATION)
|
||||
glerrorstring = "GL_INVALID_OPERATION";
|
||||
else if (glerror == GL_OUT_OF_MEMORY)
|
||||
glerrorstring = "GL_OUT_OF_MEMORY";
|
||||
else if (glerror == GL_INVALID_FRAMEBUFFER_OPERATION)
|
||||
glerrorstring = "GL_INVALID_FRAMEBUFFER_OPERATION";
|
||||
Global.LastGLError = std::to_string(glerror) + " (" + glerrorstring + ")";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3512,16 +3543,12 @@ void opengl_renderer::Update_Lights(light_array &Lights)
|
||||
|
||||
bool opengl_renderer::Init_caps()
|
||||
{
|
||||
WriteLog("MaSzyna GL3.3+ Renderer");
|
||||
WriteLog("MaSzyna OpenGL Renderer");
|
||||
WriteLog("Renderer: " + std::string((char *)glGetString(GL_RENDERER)));
|
||||
WriteLog("Vendor: " + std::string((char *)glGetString(GL_VENDOR)));
|
||||
WriteLog("GL version: " + std::string((char *)glGetString(GL_VERSION)));
|
||||
|
||||
if (!GLEW_VERSION_3_3)
|
||||
{
|
||||
ErrorLog("requires OpenGL >= 3.3!");
|
||||
return false;
|
||||
}
|
||||
WriteLog("--------");
|
||||
|
||||
GLint extCount = 0;
|
||||
glGetIntegerv(GL_NUM_EXTENSIONS, &extCount);
|
||||
@@ -3534,20 +3561,46 @@ bool opengl_renderer::Init_caps()
|
||||
}
|
||||
WriteLog("--------");
|
||||
|
||||
if (!GLEW_EXT_texture_sRGB)
|
||||
ErrorLog("EXT_texture_sRGB not supported!");
|
||||
if (!Global.use_gles)
|
||||
{
|
||||
if (!GLAD_GL_VERSION_3_3)
|
||||
{
|
||||
ErrorLog("requires OpenGL >= 3.3!");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!GLEW_EXT_texture_compression_s3tc)
|
||||
ErrorLog("EXT_texture_compression_s3tc not supported!");
|
||||
if (!GLAD_GL_EXT_texture_sRGB)
|
||||
ErrorLog("EXT_texture_sRGB not supported!");
|
||||
|
||||
if (GLEW_ARB_multi_bind)
|
||||
WriteLog("ARB_multi_bind supported!");
|
||||
if (!GLAD_GL_EXT_texture_compression_s3tc)
|
||||
ErrorLog("EXT_texture_compression_s3tc not supported!");
|
||||
|
||||
if (GLEW_ARB_direct_state_access)
|
||||
WriteLog("ARB_direct_state_access supported!");
|
||||
if (GLAD_GL_ARB_texture_filter_anisotropic)
|
||||
WriteLog("ARB_texture_filter_anisotropic supported!");
|
||||
|
||||
if (GLEW_ARB_clip_control)
|
||||
WriteLog("ARB_clip_control supported!");
|
||||
if (GLAD_GL_ARB_multi_bind)
|
||||
WriteLog("ARB_multi_bind supported!");
|
||||
|
||||
if (GLAD_GL_ARB_direct_state_access)
|
||||
WriteLog("ARB_direct_state_access supported!");
|
||||
|
||||
if (GLAD_GL_ARB_clip_control)
|
||||
WriteLog("ARB_clip_control supported!");
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!GLAD_GL_ES_VERSION_3_0)
|
||||
{
|
||||
ErrorLog("requires OpenGL ES >= 3.0!");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (GLAD_GL_EXT_texture_filter_anisotropic)
|
||||
WriteLog("EXT_texture_filter_anisotropic supported!");
|
||||
|
||||
if (GLAD_GL_EXT_clip_control)
|
||||
WriteLog("EXT_clip_control supported!");
|
||||
}
|
||||
|
||||
glGetError();
|
||||
glLineWidth(2.0f);
|
||||
|
||||
@@ -9,7 +9,6 @@ http://mozilla.org/MPL/2.0/.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "GL/glew.h"
|
||||
#include "openglgeometrybank.h"
|
||||
#include "material.h"
|
||||
#include "light.h"
|
||||
@@ -188,7 +187,7 @@ class opengl_renderer
|
||||
std::string const &info_stats() const;
|
||||
|
||||
// members
|
||||
GLenum static const sunlight{GL_LIGHT0};
|
||||
GLenum static const sunlight{0};
|
||||
std::size_t m_drawcount{0};
|
||||
|
||||
private:
|
||||
|
||||
@@ -4,14 +4,29 @@
|
||||
#include "Logs.h"
|
||||
#include <png.h>
|
||||
|
||||
void screenshot_manager::screenshot_save_thread( char *img )
|
||||
void screenshot_manager::screenshot_save_thread( char *img, int w, int h )
|
||||
{
|
||||
png_image png;
|
||||
memset(&png, 0, sizeof(png_image));
|
||||
png.version = PNG_IMAGE_VERSION;
|
||||
png.width = Global.iWindowWidth;
|
||||
png.height = Global.iWindowHeight;
|
||||
png.format = PNG_FORMAT_RGB;
|
||||
png.width = w;
|
||||
png.height = h;
|
||||
|
||||
int stride;
|
||||
if (Global.use_gles)
|
||||
{
|
||||
png.format = PNG_FORMAT_RGBA;
|
||||
stride = -w * 4;
|
||||
|
||||
for (int y = 0; y < h; y++)
|
||||
for (int x = 0; x < w; x++)
|
||||
img[(y * w + x) * 4 + 3] = 0xFF;
|
||||
}
|
||||
else
|
||||
{
|
||||
png.format = PNG_FORMAT_RGB;
|
||||
stride = -w * 3;
|
||||
}
|
||||
|
||||
char datetime[64];
|
||||
time_t timer;
|
||||
@@ -32,7 +47,7 @@ void screenshot_manager::screenshot_save_thread( char *img )
|
||||
std::string filename = Global.screenshot_dir + "/" + std::string(datetime) +
|
||||
"_" + std::to_string(perf) + ".png";
|
||||
|
||||
if (png_image_write_to_file(&png, filename.c_str(), 0, img, -Global.iWindowWidth * 3, nullptr) == 1)
|
||||
if (png_image_write_to_file(&png, filename.c_str(), 0, img, stride, nullptr) == 1)
|
||||
WriteLog("saved " + filename);
|
||||
else
|
||||
WriteLog("failed to save " + filename);
|
||||
@@ -42,11 +57,11 @@ void screenshot_manager::screenshot_save_thread( char *img )
|
||||
|
||||
void screenshot_manager::make_screenshot()
|
||||
{
|
||||
char *img = new char[Global.iWindowWidth * Global.iWindowHeight * 3];
|
||||
glReadPixels(0, 0, Global.iWindowWidth, Global.iWindowHeight, GL_RGB, GL_UNSIGNED_BYTE, (GLvoid*)img);
|
||||
char *img = new char[Global.iWindowWidth * Global.iWindowHeight * 4];
|
||||
glReadPixels(0, 0, Global.iWindowWidth, Global.iWindowHeight, Global.use_gles ? GL_RGBA : GL_RGB, GL_UNSIGNED_BYTE, (GLvoid*)img);
|
||||
//m7t: use pbo
|
||||
|
||||
std::thread t(screenshot_save_thread, img);
|
||||
std::thread t(screenshot_save_thread, img, Global.iWindowWidth, Global.iWindowHeight);
|
||||
t.detach();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
class screenshot_manager
|
||||
{
|
||||
static void screenshot_save_thread( char *img );
|
||||
static void screenshot_save_thread(char *img , int w, int h);
|
||||
|
||||
public:
|
||||
static void make_screenshot();
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
#version 330
|
||||
|
||||
in vec2 f_coord;
|
||||
|
||||
#texture (tex1, 0, sRGB_A)
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
#version 330
|
||||
|
||||
in vec3 f_normal;
|
||||
in vec2 f_coord;
|
||||
|
||||
@@ -9,15 +7,20 @@ uniform sampler2D tex1;
|
||||
#include <common>
|
||||
#include <tonemapping.glsl>
|
||||
|
||||
layout(location = 0) out vec4 out_color;
|
||||
#if MOTIONBLUR_ENABLED
|
||||
layout(location = 1) out vec4 out_motion;
|
||||
#endif
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 tex_color = texture(tex1, f_coord);
|
||||
#if POSTFX_ENABLED
|
||||
gl_FragData[0] = tex_color * param[0];
|
||||
out_color = tex_color * param[0];
|
||||
#else
|
||||
gl_FragData[0] = tonemap(tex_color * param[0]);
|
||||
out_color = tonemap(tex_color * param[0]);
|
||||
#endif
|
||||
#if MOTIONBLUR_ENABLED
|
||||
gl_FragData[1] = vec4(0.0f);
|
||||
out_motion = vec4(0.0f);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -1,18 +1,21 @@
|
||||
#version 330
|
||||
|
||||
in vec3 f_color;
|
||||
|
||||
#include <common>
|
||||
#include <tonemapping.glsl>
|
||||
|
||||
layout(location = 0) out vec4 out_color;
|
||||
#if MOTIONBLUR_ENABLED
|
||||
layout(location = 1) out vec4 out_motion;
|
||||
#endif
|
||||
|
||||
void main()
|
||||
{
|
||||
#if POSTFX_ENABLED
|
||||
gl_FragData[0] = vec4(f_color, 1.0f);
|
||||
out_color = vec4(f_color, 1.0f);
|
||||
#else
|
||||
gl_FragData[0] = tonemap(vec4(f_color, 1.0f));
|
||||
out_color = tonemap(vec4(f_color, 1.0f));
|
||||
#endif
|
||||
#if MOTIONBLUR_ENABLED
|
||||
gl_FragData[1] = vec4(0.0f);
|
||||
out_motion = vec4(0.0f);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -1,11 +1,14 @@
|
||||
#version 330
|
||||
|
||||
#include <common>
|
||||
#include <tonemapping.glsl>
|
||||
|
||||
in vec4 f_clip_pos;
|
||||
in vec4 f_clip_future_pos;
|
||||
|
||||
layout(location = 0) out vec4 out_color;
|
||||
#if MOTIONBLUR_ENABLED
|
||||
layout(location = 1) out vec4 out_motion;
|
||||
#endif
|
||||
|
||||
void main()
|
||||
{
|
||||
float x = (gl_PointCoord.x - 0.5f) * 2.0f;
|
||||
@@ -15,16 +18,16 @@ void main()
|
||||
discard;
|
||||
vec4 color = vec4(param[0].rgb * emission, mix(param[0].a, 0.0f, dist * 2.0f));
|
||||
#if POSTFX_ENABLED
|
||||
gl_FragData[0] = color;
|
||||
out_color = color;
|
||||
#else
|
||||
gl_FragData[0] = tonemap(color);
|
||||
out_color = tonemap(color);
|
||||
#endif
|
||||
#if MOTIONBLUR_ENABLED
|
||||
{
|
||||
vec2 a = (f_clip_future_pos.xy / f_clip_future_pos.w) * 0.5 + 0.5;;
|
||||
vec2 b = (f_clip_pos.xy / f_clip_pos.w) * 0.5 + 0.5;;
|
||||
|
||||
gl_FragData[1] = vec4(a - b, 0.0f, 0.0f);
|
||||
out_motion = vec4(a - b, 0.0f, 0.0f);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
#version 330
|
||||
|
||||
layout(location = 0) in vec3 v_vert;
|
||||
layout(location = 1) in vec3 v_normal;
|
||||
layout(location = 2) in vec2 v_coord;
|
||||
@@ -15,4 +13,5 @@ void main()
|
||||
f_clip_future_pos = (projection * future * modelview) * vec4(v_vert, 1.0f);
|
||||
|
||||
gl_Position = f_clip_pos;
|
||||
gl_PointSize = param[1].x;
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ float calc_shadow()
|
||||
|
||||
//sampler PCF + PCF
|
||||
float shadow = 0.0;
|
||||
vec2 texel = 1.0 / textureSize(shadowmap, 0);
|
||||
vec2 texel = vec2(1.0) / vec2(textureSize(shadowmap, 0));
|
||||
for (float y = -1.5; y <= 1.5; y += 1.0)
|
||||
for (float x = -1.5; x <= 1.5; x += 1.0)
|
||||
shadow += texture(shadowmap, coords.xyz + vec3(vec2(x, y) * texel, 0.0));
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
#version 330
|
||||
|
||||
#include <common>
|
||||
|
||||
layout(location = 0) out vec4 out_color;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_FragData[0] = vec4(1.0f);
|
||||
out_color = vec4(1.0f);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
#version 330
|
||||
|
||||
layout(location = 0) in vec3 v_vert;
|
||||
|
||||
#include <common>
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
#version 330
|
||||
|
||||
in vec3 f_normal;
|
||||
in vec2 f_coord;
|
||||
in vec4 f_pos;
|
||||
@@ -10,15 +8,20 @@ uniform sampler2D tex1;
|
||||
#include <common>
|
||||
#include <tonemapping.glsl>
|
||||
|
||||
layout(location = 0) out vec4 out_color;
|
||||
#if MOTIONBLUR_ENABLED
|
||||
layout(location = 1) out vec4 out_motion;
|
||||
#endif
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 tex_color = texture(tex1, f_coord);
|
||||
#if POSTFX_ENABLED
|
||||
gl_FragData[0] = tex_color * param[0];
|
||||
out_color = tex_color * param[0];
|
||||
#else
|
||||
gl_FragData[0] = tonemap(tex_color * param[0]);
|
||||
out_color = tonemap(tex_color * param[0]);
|
||||
#endif
|
||||
#if MOTIONBLUR_ENABLED
|
||||
gl_FragData[1] = vec4(0.0f);
|
||||
out_motion = vec4(0.0f);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
#version 330
|
||||
|
||||
in vec3 f_normal;
|
||||
in vec2 f_coord;
|
||||
in vec4 f_pos;
|
||||
@@ -26,6 +24,11 @@ uniform samplerCube envmap;
|
||||
#include <light_common.glsl>
|
||||
#include <tonemapping.glsl>
|
||||
|
||||
layout(location = 0) out vec4 out_color;
|
||||
#if MOTIONBLUR_ENABLED
|
||||
layout(location = 1) out vec4 out_motion;
|
||||
#endif
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 tex_color = vec4(pow(param[0].rgb, vec3(2.2)), param[0].a);
|
||||
@@ -64,16 +67,16 @@ void main()
|
||||
|
||||
vec4 color = vec4(apply_fog(result * tex_color.rgb), tex_color.a * alpha_mult);
|
||||
#if POSTFX_ENABLED
|
||||
gl_FragData[0] = color;
|
||||
out_color = color;
|
||||
#else
|
||||
gl_FragData[0] = tonemap(color);
|
||||
out_color = tonemap(color);
|
||||
#endif
|
||||
#if MOTIONBLUR_ENABLED
|
||||
{
|
||||
vec2 a = (f_clip_future_pos.xy / f_clip_future_pos.w) * 0.5 + 0.5;;
|
||||
vec2 b = (f_clip_pos.xy / f_clip_pos.w) * 0.5 + 0.5;;
|
||||
|
||||
gl_FragData[1] = vec4(a - b, 0.0f, 0.0f);
|
||||
out_motion = vec4(a - b, 0.0f, 0.0f);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
#version 330
|
||||
|
||||
in vec3 f_normal;
|
||||
in vec2 f_coord;
|
||||
in vec4 f_pos;
|
||||
@@ -26,6 +24,11 @@ uniform sampler2DShadow shadowmap;
|
||||
uniform samplerCube envmap;
|
||||
#endif
|
||||
|
||||
layout(location = 0) out vec4 out_color;
|
||||
#if MOTIONBLUR_ENABLED
|
||||
layout(location = 1) out vec4 out_motion;
|
||||
#endif
|
||||
|
||||
#include <light_common.glsl>
|
||||
#include <tonemapping.glsl>
|
||||
|
||||
@@ -70,9 +73,9 @@ void main()
|
||||
|
||||
vec4 color = vec4(apply_fog(result * tex_color.rgb), tex_color.a * alpha_mult);
|
||||
#if POSTFX_ENABLED
|
||||
gl_FragData[0] = color;
|
||||
out_color = color;
|
||||
#else
|
||||
gl_FragData[0] = tonemap(color);
|
||||
out_color = tonemap(color);
|
||||
#endif
|
||||
|
||||
#if MOTIONBLUR_ENABLED
|
||||
@@ -80,7 +83,7 @@ void main()
|
||||
vec2 a = (f_clip_future_pos.xy / f_clip_future_pos.w) * 0.5 + 0.5;;
|
||||
vec2 b = (f_clip_pos.xy / f_clip_pos.w) * 0.5 + 0.5;;
|
||||
|
||||
gl_FragData[1] = vec4(a - b, 0.0f, tex_color.a * alpha_mult);
|
||||
out_motion = vec4(a - b, 0.0f, tex_color.a * alpha_mult);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -1,17 +1,20 @@
|
||||
#version 330
|
||||
|
||||
#include <common>
|
||||
#include <tonemapping.glsl>
|
||||
|
||||
layout(location = 0) out vec4 out_color;
|
||||
#if MOTIONBLUR_ENABLED
|
||||
layout(location = 1) out vec4 out_motion;
|
||||
#endif
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 color = vec4(1.0, 0.0, 1.0, 1.0);
|
||||
#if POSTFX_ENABLED
|
||||
gl_FragData[0] = color;
|
||||
out_color = color;
|
||||
#else
|
||||
gl_FragData[0] = tonemap(color);
|
||||
out_color = tonemap(color);
|
||||
#endif
|
||||
#if MOTIONBLUR_ENABLED
|
||||
gl_FragData[1] = vec4(0.0f);
|
||||
out_motion = vec4(0.0f);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
#version 330
|
||||
|
||||
in vec3 f_normal;
|
||||
in vec2 f_coord;
|
||||
in vec4 f_pos;
|
||||
@@ -11,6 +9,11 @@ in vec4 f_clip_future_pos;
|
||||
|
||||
#include <common>
|
||||
|
||||
layout(location = 0) out vec4 out_color;
|
||||
#if MOTIONBLUR_ENABLED
|
||||
layout(location = 1) out vec4 out_motion;
|
||||
#endif
|
||||
|
||||
#param (color, 0, 0, 4, diffuse)
|
||||
#param (diffuse, 1, 0, 1, diffuse)
|
||||
#param (specular, 1, 1, 1, specular)
|
||||
@@ -75,16 +78,16 @@ void main()
|
||||
|
||||
vec4 color = vec4(apply_fog(result * tex_color.rgb), tex_color.a * alpha_mult);
|
||||
#if POSTFX_ENABLED
|
||||
gl_FragData[0] = color;
|
||||
out_color = color;
|
||||
#else
|
||||
gl_FragData[0] = tonemap(color);
|
||||
out_color = tonemap(color);
|
||||
#endif
|
||||
#if MOTIONBLUR_ENABLED
|
||||
{
|
||||
vec2 a = (f_clip_future_pos.xy / f_clip_future_pos.w) * 0.5 + 0.5;;
|
||||
vec2 b = (f_clip_pos.xy / f_clip_pos.w) * 0.5 + 0.5;;
|
||||
|
||||
gl_FragData[1] = vec4(a - b, 0.0f, 0.0f);
|
||||
out_motion = vec4(a - b, 0.0f, 0.0f);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
#version 330
|
||||
|
||||
in vec3 f_normal;
|
||||
in vec2 f_coord;
|
||||
in vec4 f_pos;
|
||||
@@ -10,6 +8,11 @@ in vec4 f_clip_future_pos;
|
||||
|
||||
#include <common>
|
||||
|
||||
layout(location = 0) out vec4 out_color;
|
||||
#if MOTIONBLUR_ENABLED
|
||||
layout(location = 1) out vec4 out_motion;
|
||||
#endif
|
||||
|
||||
#param (color, 0, 0, 4, diffuse)
|
||||
#param (diffuse, 1, 0, 1, diffuse)
|
||||
#param (specular, 1, 1, 1, specular)
|
||||
@@ -73,16 +76,16 @@ void main()
|
||||
|
||||
vec4 color = vec4(apply_fog(result * tex_color.rgb), tex_color.a * alpha_mult);
|
||||
#if POSTFX_ENABLED
|
||||
gl_FragData[0] = color;
|
||||
out_color = color;
|
||||
#else
|
||||
gl_FragData[0] = tonemap(color);
|
||||
out_color = tonemap(color);
|
||||
#endif
|
||||
#if MOTIONBLUR_ENABLED
|
||||
{
|
||||
vec2 a = (f_clip_future_pos.xy / f_clip_future_pos.w) * 0.5 + 0.5;;
|
||||
vec2 b = (f_clip_pos.xy / f_clip_pos.w) * 0.5 + 0.5;;
|
||||
|
||||
gl_FragData[1] = vec4(a - b, 0.0f, 0.0f);
|
||||
out_motion = vec4(a - b, 0.0f, 0.0f);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -1,10 +1,13 @@
|
||||
#version 330
|
||||
|
||||
#include <common>
|
||||
#include <tonemapping.glsl>
|
||||
|
||||
flat in vec3 f_normal_raw;
|
||||
|
||||
layout(location = 0) out vec4 out_color;
|
||||
#if MOTIONBLUR_ENABLED
|
||||
layout(location = 1) out vec4 out_motion;
|
||||
#endif
|
||||
|
||||
void main()
|
||||
{
|
||||
float x = (gl_PointCoord.x - 0.5f) * 2.0f;
|
||||
@@ -16,11 +19,11 @@ void main()
|
||||
// color data space is shared with normals, ugh
|
||||
vec4 color = vec4(pow(f_normal_raw.bgr, vec3(2.2)), 1.0f);
|
||||
#if POSTFX_ENABLED
|
||||
gl_FragData[0] = color;
|
||||
out_color = color;
|
||||
#else
|
||||
gl_FragData[0] = tonemap(color);
|
||||
out_color = tonemap(color);
|
||||
#endif
|
||||
#if MOTIONBLUR_ENABLED
|
||||
gl_FragData[1] = vec4(0.0f);
|
||||
out_motion = vec4(0.0f);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
#version 330
|
||||
|
||||
#include <common>
|
||||
|
||||
layout(location = 0) out vec4 out_color;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_FragColor = vec4(param[0].rgb, 1.0);
|
||||
out_color = vec4(param[0].rgb, 1.0);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
#version 330 core
|
||||
|
||||
in vec2 f_coords;
|
||||
layout(location = 0) out vec4 out_color;
|
||||
|
||||
#texture (color_tex, 0, RGB)
|
||||
uniform sampler2D color_tex;
|
||||
@@ -26,5 +25,5 @@ void main()
|
||||
}
|
||||
oResult /= float(nSamples);
|
||||
|
||||
gl_FragData[0] = oResult;
|
||||
out_color = oResult;
|
||||
}
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
#version 330 core
|
||||
out vec4 FragColor;
|
||||
|
||||
in vec2 f_coords;
|
||||
|
||||
layout(location = 0) out vec4 out_color;
|
||||
|
||||
#texture (tex1, 0, RGB)
|
||||
uniform sampler2D tex1;
|
||||
|
||||
@@ -14,5 +13,5 @@ void main()
|
||||
vec3 hdr_color = texture(tex1, texcoord).xyz;
|
||||
|
||||
vec3 mapped = tonemap(hdr_color);
|
||||
gl_FragColor = vec4(mapped, 1.0);
|
||||
out_color = vec4(mapped, 1.0);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
#version 330
|
||||
|
||||
in vec2 f_coord;
|
||||
|
||||
#texture (tex1, 0, sRGB_A)
|
||||
@@ -7,6 +5,11 @@ uniform sampler2D tex1;
|
||||
|
||||
#include <common>
|
||||
|
||||
layout(location = 0) out vec4 out_color;
|
||||
#if MOTIONBLUR_ENABLED
|
||||
layout(location = 1) out vec4 out_motion;
|
||||
#endif
|
||||
|
||||
in vec4 f_clip_pos;
|
||||
in vec4 f_clip_future_pos;
|
||||
|
||||
@@ -17,16 +20,16 @@ void main()
|
||||
vec4 tex_color = texture(tex1, vec2(f_coord.x, f_coord.y + param[1].x));
|
||||
vec4 color = tex_color * param[0];
|
||||
#if POSTFX_ENABLED
|
||||
gl_FragData[0] = color;
|
||||
out_color = color;
|
||||
#else
|
||||
gl_FragData[0] = tonemap(color);
|
||||
out_color = tonemap(color);
|
||||
#endif
|
||||
#if MOTIONBLUR_ENABLED
|
||||
{
|
||||
vec2 a = (f_clip_future_pos.xy / f_clip_future_pos.w) * 0.5 + 0.5;
|
||||
vec2 b = (f_clip_pos.xy / f_clip_pos.w) * 0.5 + 0.5;
|
||||
|
||||
gl_FragData[1] = vec4(a - b, 0.0f, tex_color.a * alpha_mult);
|
||||
out_motion = vec4(a - b, 0.0f, tex_color.a * alpha_mult);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
#version 330
|
||||
|
||||
layout(location = 0) in vec3 v_vert;
|
||||
layout(location = 1) in vec2 v_coord;
|
||||
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
#version 330 core
|
||||
|
||||
const vec2 vert[4] = vec2[]
|
||||
(
|
||||
vec2(-1.0, 1.0),
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
#version 330
|
||||
|
||||
in vec2 f_coord;
|
||||
|
||||
void main()
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
#version 330
|
||||
|
||||
layout(location = 0) in vec3 v_vert;
|
||||
layout(location = 2) in vec2 v_coord;
|
||||
|
||||
|
||||
@@ -1,19 +1,22 @@
|
||||
#version 330
|
||||
|
||||
#include <common>
|
||||
|
||||
in vec4 f_clip_pos;
|
||||
in vec4 f_clip_future_pos;
|
||||
|
||||
layout(location = 0) out vec4 out_color;
|
||||
#if MOTIONBLUR_ENABLED
|
||||
layout(location = 1) out vec4 out_motion;
|
||||
#endif
|
||||
|
||||
#include <tonemapping.glsl>
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 color = vec4(pow(param[0].rgb, vec3(2.2)), param[0].a);
|
||||
#if POSTFX_ENABLED
|
||||
gl_FragData[0] = color;
|
||||
out_color = color;
|
||||
#else
|
||||
gl_FragData[0] = tonemap(color);
|
||||
out_color = tonemap(color);
|
||||
#endif
|
||||
|
||||
#if MOTIONBLUR_ENABLED
|
||||
@@ -21,7 +24,7 @@ void main()
|
||||
vec2 a = (f_clip_future_pos.xy / f_clip_future_pos.w) * 0.5 + 0.5;;
|
||||
vec2 b = (f_clip_pos.xy / f_clip_pos.w) * 0.5 + 0.5;;
|
||||
|
||||
gl_FragData[1] = vec4(a - b, 0.0f, 0.0f);
|
||||
out_motion = vec4(a - b, 0.0f, 0.0f);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
#version 330
|
||||
|
||||
layout(location = 0) in vec3 v_vert;
|
||||
layout(location = 1) in vec3 v_normal;
|
||||
layout(location = 2) in vec2 v_coord;
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
#version 330
|
||||
|
||||
layout(location = 0) in vec3 v_vert;
|
||||
layout(location = 1) in vec3 v_color;
|
||||
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
#version 330
|
||||
|
||||
layout(location = 0) in vec3 v_vert;
|
||||
layout(location = 1) in vec3 v_normal;
|
||||
layout(location = 2) in vec2 v_coord;
|
||||
@@ -31,6 +29,7 @@ void main()
|
||||
f_clip_future_pos = (projection * future * modelview) * vec4(v_vert, 1.0f);
|
||||
|
||||
gl_Position = f_clip_pos;
|
||||
gl_PointSize = param[1].x;
|
||||
|
||||
vec3 T = normalize(modelviewnormal * v_tangent.xyz);
|
||||
vec3 B = normalize(modelviewnormal * cross(v_normal, v_tangent.xyz) * v_tangent.w);
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
#version 330
|
||||
|
||||
layout(location = 0) in vec3 v_vert;
|
||||
|
||||
#include <common>
|
||||
|
||||
20
stdafx.h
20
stdafx.h
@@ -76,16 +76,11 @@
|
||||
#define GLFW_DLL
|
||||
#endif // _windows
|
||||
#endif // build_static
|
||||
#ifndef __ANDROID__
|
||||
#include "GL/glew.h"
|
||||
#else
|
||||
#include <GL/gl.h>
|
||||
#include <GL/glu.h>
|
||||
#endif
|
||||
#ifdef _WIN32
|
||||
#include "GL/wglew.h"
|
||||
#endif
|
||||
#define GLFW_INCLUDE_GLU
|
||||
|
||||
#include "glad/glad.h"
|
||||
|
||||
#define GLFW_INCLUDE_NONE
|
||||
//#define GLFW_INCLUDE_GLU
|
||||
#include <GLFW/glfw3.h>
|
||||
|
||||
#define GLM_ENABLE_EXPERIMENTAL
|
||||
@@ -104,8 +99,7 @@ int const null_handle = 0;
|
||||
#include "openglmatrixstack.h"
|
||||
#define STRINGIZE_DETAIL(x) #x
|
||||
#define STRINGIZE(x) STRINGIZE_DETAIL(x)
|
||||
#define glDebug(x) if (GLEW_GREMEDY_string_marker) glStringMarkerGREMEDY(0, __FILE__ ":" STRINGIZE(__LINE__) ": " x);
|
||||
#include "openglcolor.h"
|
||||
#define glDebug(x) if (GLAD_GL_GREMEDY_string_marker) glStringMarkerGREMEDY(0, __FILE__ ":" STRINGIZE(__LINE__) ": " x);
|
||||
|
||||
#ifdef DBG_NEW
|
||||
#pragma push_macro("new")
|
||||
@@ -125,4 +119,4 @@ int const null_handle = 0;
|
||||
#pragma pop_macro("new")
|
||||
#else
|
||||
#include "imgui/imgui.h"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
8
sun.cpp
8
sun.cpp
@@ -15,15 +15,15 @@ cSun::cSun() {
|
||||
m_observer.temp = 15.0; // ambient dry-bulb temperature, degrees C
|
||||
}
|
||||
|
||||
cSun::~cSun() { gluDeleteQuadric( sunsphere ); }
|
||||
cSun::~cSun()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
cSun::init() {
|
||||
|
||||
m_observer.timezone = -1.0 * simulation::Time.zone_bias();
|
||||
|
||||
sunsphere = gluNewQuadric();
|
||||
gluQuadricNormals( sunsphere, GLU_SMOOTH );
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
5
sun.h
5
sun.h
@@ -1,9 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
//#include "windows.h"
|
||||
#include "GL/glew.h"
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
// cSun -- class responsible for dynamic calculation of position and intensity of the Sun,
|
||||
// given current weather, time and geographic location.
|
||||
@@ -58,7 +54,6 @@ protected:
|
||||
void irradiance();
|
||||
|
||||
// members:
|
||||
GLUquadricObj *sunsphere; // temporary handler for sun positioning test
|
||||
|
||||
struct celestialbody { // main planet parameters
|
||||
|
||||
|
||||
@@ -139,7 +139,10 @@ bool ui_layer::init(GLFWwindow *Window)
|
||||
ImGui_ImplOpenGL2_Init();
|
||||
ImGui_ImplOpenGL2_NewFrame();
|
||||
#else
|
||||
ImGui_ImplOpenGL3_Init("#version 130");
|
||||
if (Global.use_gles)
|
||||
ImGui_ImplOpenGL3_Init("#version 300 es\nprecision highp float;");
|
||||
else
|
||||
ImGui_ImplOpenGL3_Init("#version 330 core");
|
||||
ImGui_ImplOpenGL3_NewFrame();
|
||||
#endif
|
||||
|
||||
|
||||
@@ -443,3 +443,13 @@ deserialize_random_set( cParser &Input, char const *Break ) {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
int count_trailing_zeros(uint32_t val)
|
||||
{
|
||||
int r = 0;
|
||||
|
||||
for (uint32_t shift = 1; !(val & shift); shift <<= 1)
|
||||
r++;
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
@@ -314,6 +314,8 @@ glm::dvec3 LoadPoint( class cParser &Input );
|
||||
std::string
|
||||
deserialize_random_set( cParser &Input, char const *Break = "\n\r\t ;" );
|
||||
|
||||
int count_trailing_zeros(uint32_t val);
|
||||
|
||||
namespace threading {
|
||||
|
||||
// simple POD pairing of a data item and a mutex
|
||||
|
||||
Reference in New Issue
Block a user