RError.com

RError.com Logo RError.com Logo

RError.com Navigation

  • 主页

Mobile menu

Close
  • 主页
  • 系统&网络
    • 热门问题
    • 最新问题
    • 标签
  • Ubuntu
    • 热门问题
    • 最新问题
    • 标签
  • 帮助
主页 / user-298041

Luzifer's questions

Martin Hope
Luzifer
Asked: 2020-01-29 21:57:07 +0000 UTC

库的 CMake 配置

  • 2

大家好!

有一个任务

  1. 编写一个共享库(对于 windows .dll,对于 Linux .so)
  2. 库的头文件必须放在相应的文件夹中。(对于 Linux /usr/local/include/{library_name}/*)
  3. 应该可以在正在开发的应用程序中使用头文件。

目前我有 CMakeLists.txt

cmake_minimum_required(VERSION 3.13)

set(PROJECT_VERSION "0.0.1")

project(mylib VERSION ${PROJECT_VERSION})

set(CMAKE_CXX_STANDARD 17)

include(CMakeSources.cmake)
add_library(mylib SHARED ${MY_LIB_HEADERS} ${MY_LIB_SOURCES})

set_target_properties(mylib PROPERTIES
        VERSION ${PROJECT_VERSION}
        SOVERSION ${PROJECT_VERSION})

include(GNUInstallDirs)
set(MY_LIB_LIBRARY_DESTINATION ${CMAKE_INSTALL_LIBDIR})
set(MY_LIB_HEADERS_DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/mylib)

INSTALL(TARGETS mylib
        LIBRARY DESTINATION ${MY_LIB_LIBRARY_DESTINATION})

INSTALL(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/
        PUBLIC_HEADER DESTINATION ${MY_LIB_HEADERS_DESTINATION}
        FILES_MATCHING PATTERN "*.h")

几乎可以满足所有要求。第 3 点有错误。

例如:我有两个头文件Ah和Bh,Bh包含Ah(#include "Ah")。

执行 make install 命令后,这些文件被移动到

  • /usr/local/include/mylib/啊
  • /usr/local/include/mylib/Bh

现在,当我尝试在另一个项目中使用 Bh 时,我得到了错误

/usr/local/include/mylib/Bh:1:致命错误:找不到“Ah”文件#include“Ah”

请帮我解决这个问题。

cmake
  • 1 个回答
  • 10 Views
Martin Hope
Luzifer
Asked: 2020-07-02 04:37:11 +0000 UTC

如何为给定顶点和索引的立方体组织法线?

  • 1

如何正确组织立方体照明的法线?

  1. 立方体顶点:

    std::vector<Vertex> vertices = {
            Vertex {Position: glm::vec3(-0.5, -0.5, -0.5)},
            Vertex {Position: glm::vec3(-0.5,  0.5, -0.5)},
            Vertex {Position: glm::vec3( 0.5,  0.5, -0.5)},
            Vertex {Position: glm::vec3( 0.5, -0.5, -0.5)},
            Vertex {Position: glm::vec3(-0.5, -0.5,  0.5)},
            Vertex {Position: glm::vec3(-0.5,  0.5,  0.5)},
            Vertex {Position: glm::vec3( 0.5,  0.5,  0.5)},
            Vertex {Position: glm::vec3( 0.5, -0.5,  0.5)}};
    
  2. 立方体索引:

    std::vector<unsigned int> indices = {
            0, 1, 2,  0, 2, 3, // front
            4, 5, 6,  4, 6, 7, // back
            0, 1, 5,  0, 5, 4, // left
            2, 6, 3,  3, 6, 7, // right
            1, 5, 2,  2, 5, 6, // up
            9, 4, 3,  3, 4, 7  // bottom
    };
    
  3. 立方体是使用 drawElements 方法绘制的。

如果我正确理解了理论......那么计算颜色,立方体的每个顶点应该有3个法线,如图所示。

但我不知道如何将 3 个法线传递给一个顶点的着色器?

并且如果仍然成功转移,如何确定当前人脸所需的法线?(因为我们每个顶点有 3 个法线)

opengl
  • 1 个回答
  • 10 Views
Martin Hope
Luzifer
Asked: 2020-05-26 21:30:29 +0000 UTC

如何读取 64 位值?

  • 2

我需要将有关 ELF 的信息放入标题结构中,其中结构的字段是 64 位值。当我尝试以通常的方式阅读它们时,我在所有领域都得到 0。您能告诉我如何使下面的代码正常工作吗?

  1. 用于读取 ELF 字节的 hexdump 文件

    00000000  7f 45 4c 46 02 01 01 00  00 00 00 00 00 00 00 00  |.ELF............|
    00000010  01 00 3e 00 01 00 00 00  00 00 00 00 00 00 00 00  |..>.............|
    00000020  00 00 00 00 00 00 00 00  40 00 00 00 00 00 00 00  |........@.......|
    00000030  00 00 00 00 40 00 00 00  00 00 40 00 05 00 02 00  |....@.....@.....|
    00000040  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
    *
    00000080  01 00 00 00 01 00 00 00  06 00 00 00 00 00 00 00  |................|
    00000090  00 00 00 00 00 00 00 00  80 01 00 00 00 00 00 00  |................|
    000000a0  0c 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
    000000b0  10 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
    000000c0  07 00 00 00 03 00 00 00  00 00 00 00 00 00 00 00  |................|
    000000d0  00 00 00 00 00 00 00 00  90 01 00 00 00 00 00 00  |................|
    000000e0  21 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |!...............|
    000000f0  01 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
    00000100  11 00 00 00 02 00 00 00  00 00 00 00 00 00 00 00  |................|
    00000110  00 00 00 00 00 00 00 00  c0 01 00 00 00 00 00 00  |................|
    00000120  60 00 00 00 00 00 00 00  04 00 00 00 03 00 00 00  |`...............|
    00000130  04 00 00 00 00 00 00 00  18 00 00 00 00 00 00 00  |................|
    00000140  19 00 00 00 03 00 00 00  00 00 00 00 00 00 00 00  |................|
    00000150  00 00 00 00 00 00 00 00  20 02 00 00 00 00 00 00  |........ .......|
    00000160  0e 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
    00000170  01 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
    00000180  b8 3c 00 00 00 bf 00 00  00 00 0f 05 00 00 00 00  |.<..............|
    00000190  00 2e 74 65 78 74 00 2e  73 68 73 74 72 74 61 62  |..text..shstrtab|
    000001a0  00 2e 73 79 6d 74 61 62  00 2e 73 74 72 74 61 62  |..symtab..strtab|
    000001b0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
    *
    000001d0  00 00 00 00 00 00 00 00  01 00 00 00 04 00 f1 ff  |................|
    000001e0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
    000001f0  00 00 00 00 03 00 01 00  00 00 00 00 00 00 00 00  |................|
    00000200  00 00 00 00 00 00 00 00  07 00 00 00 10 00 01 00  |................|
    00000210  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
    00000220  00 65 78 31 2e 73 00 5f  73 74 61 72 74 00 00 00  |.ex1.s._start...|
    
  2. 将ELF读入结构的源代码

    #include <iostream>
    #include <fstream>
    #include <stdint.h>
    
    /* Type for a 16-bit quantity.  */
    typedef uint16_t Elf64_Half;
    
    /* Types for signed and unsigned 32-bit quantities.  */
    typedef uint32_t Elf64_Word;
    
    /* Type of addresses.  */
    typedef uint64_t Elf64_Addr;
    
    /* Type of file offsets.  */
    typedef uint64_t Elf64_Off;
    
    /* The ELF file header.  This appears at the start of every ELF file.  */
    
    #define EI_NIDENT (16)
    
    typedef struct
    {
      unsigned char e_ident[EI_NIDENT]; /* Magic number and other info */
      Elf64_Half      e_type;                   /* Object file type */
      Elf64_Half      e_machine;              /* Architecture */
      Elf64_Word      e_version;            /* Object file version */
      Elf64_Addr      e_entry;            /* Entry point virtual address */
      Elf64_Off     e_phoff;              /* Program header table file offset */
      Elf64_Off     e_shoff;              /* Section header table file offset */
      Elf64_Word      e_flags;            /* Processor-specific flags */
      Elf64_Half    e_ehsize;             /* ELF header size in bytes */
      Elf64_Half    e_phentsize;            /* Program header table entry size */
      Elf64_Half    e_phnum;                /* Program header table entry count */
      Elf64_Half      e_shentsize;          /* Section header table entry size */
      Elf64_Half    e_shnum;                /* Section header table entry count */
      Elf64_Half      e_shstrndx;           /* Section header string table index */
    } Elf64_Ehdr;
    
    int main(int argc, char const *argv[])
    {
        Elf64_Ehdr ehdr = {};
    
        std::ifstream ifs;
    
        ifs.open("ex1.o", std::ios::binary|std::ios::in);
    
        for (int i = 0; i < EI_NIDENT; i++)
        {
          ifs >> ehdr.e_ident[i];
        }
    
        ifs >> ehdr.e_type;
        ifs >> ehdr.e_machine;
        ifs >> ehdr.e_version;
        ifs >> ehdr.e_entry;
        ifs >> ehdr.e_phoff;
        ifs >> ehdr.e_shoff;
        ifs >> ehdr.e_flags;
        ifs >> ehdr.e_ehsize;
        ifs >> ehdr.e_phentsize;
        ifs >> ehdr.e_phnum;
        ifs >> ehdr.e_shentsize;
        ifs >> ehdr.e_shnum;
        ifs >> ehdr.e_shstrndx;
    
        return 0;
    }
    
  3. 结果:除 e_ident 之外的所有字段都包含 0

c++
  • 1 个回答
  • 10 Views

Sidebar

Stats

  • 问题 10021
  • Answers 30001
  • 最佳答案 8000
  • 用户 6900
  • 常问
  • 回答
  • Marko Smith

    我看不懂措辞

    • 1 个回答
  • Marko Smith

    请求的模块“del”不提供名为“default”的导出

    • 3 个回答
  • Marko Smith

    "!+tab" 在 HTML 的 vs 代码中不起作用

    • 5 个回答
  • Marko Smith

    我正在尝试解决“猜词”的问题。Python

    • 2 个回答
  • Marko Smith

    可以使用哪些命令将当前指针移动到指定的提交而不更改工作目录中的文件?

    • 1 个回答
  • Marko Smith

    Python解析野莓

    • 1 个回答
  • Marko Smith

    问题:“警告:检查最新版本的 pip 时出错。”

    • 2 个回答
  • Marko Smith

    帮助编写一个用值填充变量的循环。解决这个问题

    • 2 个回答
  • Marko Smith

    尽管依赖数组为空,但在渲染上调用了 2 次 useEffect

    • 2 个回答
  • Marko Smith

    数据不通过 Telegram.WebApp.sendData 发送

    • 1 个回答
  • Martin Hope
    Alexandr_TT 2020年新年大赛! 2020-12-20 18:20:21 +0000 UTC
  • Martin Hope
    Alexandr_TT 圣诞树动画 2020-12-23 00:38:08 +0000 UTC
  • Martin Hope
    Air 究竟是什么标识了网站访问者? 2020-11-03 15:49:20 +0000 UTC
  • Martin Hope
    Qwertiy 号码显示 9223372036854775807 2020-07-11 18:16:49 +0000 UTC
  • Martin Hope
    user216109 如何为黑客设下陷阱,或充分击退攻击? 2020-05-10 02:22:52 +0000 UTC
  • Martin Hope
    Qwertiy 并变成3个无穷大 2020-11-06 07:15:57 +0000 UTC
  • Martin Hope
    koks_rs 什么是样板代码? 2020-10-27 15:43:19 +0000 UTC
  • Martin Hope
    Sirop4ik 向 git 提交发布的正确方法是什么? 2020-10-05 00:02:00 +0000 UTC
  • Martin Hope
    faoxis 为什么在这么多示例中函数都称为 foo? 2020-08-15 04:42:49 +0000 UTC
  • Martin Hope
    Pavel Mayorov 如何从事件或回调函数中返回值?或者至少等他们完成。 2020-08-11 16:49:28 +0000 UTC

热门标签

javascript python java php c# c++ html android jquery mysql

Explore

  • 主页
  • 问题
    • 热门问题
    • 最新问题
  • 标签
  • 帮助

Footer

RError.com

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

帮助

© 2023 RError.com All Rights Reserve   沪ICP备12040472号-5