Coder Social home page Coder Social logo

opengl_test's Introduction

OpenGL

https://learnopengl-cn.github.io/

https://github.com/parallel101/opengltutor

https://docs.gl/

https://threejs.org/

https://github.com/ocornut/imgui

https://github.com/yocover/start-learning-opengl

编译安装

glfw

assimp

编译指南

检查 CMakeLists.txt 中的ASSIMP_BUILD_ZLIB 选项是否开启, ON

mkdir build && cd build
cmake ..
make -j9

获取 libassimp.a 和 libzlibstatic.a

target_link_libraries(main PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/lib/libassimp.a)
target_link_libraries(main PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/lib/libzlibstatic.a)

OpenGL仅当3D坐标在3个轴(x、y和z)上-1.0到1.0的范围内时才处理它。 所有在这个范围内的坐标叫做标准化设备坐标,此范围内的坐标最终显示在屏幕上。

一旦你的顶点坐标已经在顶点着色器中处理过,它们就应该是标准化设备坐标了, 标准化设备坐标是一个x、y和z值在-1.0到1.0的一小段空间。任何落在范围外的坐标都会被丢弃/裁剪,不会显示在你的屏幕上。

OpenGL 绘制字体

https://freetype.org/

libfreetype.a 依赖于以下库

  • Brotli 库

    sudo apt-get install libbrotli-dev
  • libpng 库

    sudo apt-get install libpng-dev
  • zlib 库

    sudo apt-get install zlib1g-dev
  • HarfBuzz 库

    sudo apt-get install libharfbuzz-dev
aux_source_directory(./imgui DIR_SRCS)
aux_source_directory(./examples/text_rendering DIR_SRCS)
add_executable (text_rendering ${DIR_SRCS})
target_link_libraries(text_rendering PUBLIC glm)
target_link_libraries(text_rendering PUBLIC glfw)
target_link_libraries(text_rendering PUBLIC glad)
target_link_libraries(text_rendering PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/lib/libfreetype.a)
target_link_libraries(text_rendering PUBLIC brotlidec)
target_link_libraries(text_rendering PUBLIC png)
target_link_libraries(text_rendering PUBLIC z)
target_link_libraries(text_rendering PUBLIC harfbuzz)

曲率运动

float rotate = glfwGetTime() * 0.2f;
glm::qua<float> qu = glm::qua<float>(glm::vec3(rotate, rotate, rotate));
model = glm::mat4_cast(qu);

开启模板缓冲

glEnable(GL_STENCIL_TEST);

清除模板缓冲

glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);

模板掩码

glStencilMask(0xFF); // 每一位写入模板缓冲时都保持原样
glStencilMask(0x00); // 每一位在写入模板缓冲时都会变成0(禁用写入)

模板函数

glStencilFunc(GLenum func, GLint ref, GLuint mask)
glStencilOp(GLenum sfail, GLenum dpfail, GLenum dppass)

裁剪测试

opengl_test's People

Contributors

yrxns avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.