windows Visual Studio 2022 opengl开发环境配置

news2024/9/25 11:10:36

1. 安装glew(GL), GLFW, glm, soil2-debug

还需要premake生成visual studio solution

cmake for windows也要安装一个, 但是不用安装MinGW64, bug多

下载源码,找到xxx.sln文件用visual stidio打开solution编译代码,找到xxx.lib, xxx.dll文件

include头文件结构: 

 

编译完了创建目录  OpenGLtemplate/{include,lib,bin}

动态库glew32d.dll放到bin目录下,并把E:\library\OpenGLtemplate\bin追加到path环境变量

lib目录下放静态库*.lib

glew32sd.lib是静态库,glew32d.lib其实是动态库,后缀改成dll放到bin目录

 或者把依赖的动态库放到项目编译完了.exe文件同级目录,方便发布

visual studio 2022创建console控制台项目

新建cpp文件

// simple_glfw.cpp : This file contains the 'main' function. Program execution begins and ends there.
//
#pragma comment(lib , "glew32d.lib")
// E:\library\OpenGLtemplate\bin\glew32d.dll, add "E:\library\OpenGLtemplate\bin" to Path env

#include <iostream>
#include <GL/glew.h>
#include <GLFW/glfw3.h>

using namespace std;

void init(GLFWwindow * window) {}

void display(GLFWwindow *window, double currentTime) {
    glClearColor(1.0, 0.0, 0.0, 1.0);
    glClear(GL_COLOR_BUFFER_BIT);
}

int main()
{
    if (!glfwInit()) {
        exit(EXIT_FAILURE);
    }
    glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 4);
    glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 4);
    GLFWwindow* window = glfwCreateWindow(600, 600, "Chapter2 - program1", NULL, NULL);
    glfwMakeContextCurrent(window);
    if (glewInit() != GLEW_OK) {
        exit(EXIT_FAILURE);
    }
    glfwSwapInterval(1);
    init(window);
    while (!glfwWindowShouldClose(window)) {
        display(window, glfwGetTime());
        glfwSwapBuffers(window);
        glfwPollEvents();
    }
    glfwDestroyWindow(window);
    glfwTerminate();
    exit(EXIT_SUCCESS);
}

// Run program: Ctrl + F5 or Debug > Start Without Debugging menu
// Debug program: F5 or Debug > Start Debugging menu

// Tips for Getting Started: 
//   1. Use the Solution Explorer window to add/manage files
//   2. Use the Team Explorer window to connect to source control
//   3. Use the Output window to see build output and other messages
//   4. Use the Error List window to view errors
//   5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project
//   6. In the future, to open this project again, go to File > Open > Project and select the .sln file

直接修改.vcxproj文件,等效于Makefile文件

指定依赖的静态库    -l

<AdditionalDependencies>%(AdditionalDependencies);glew32d.lib;glfw3.lib;opengl32.lib;soil2-debug.lib;</AdditionalDependencies>

指定-I, include目录,-L库的路径

  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
    <PublicIncludeDirectories>$(PublicIncludeDirectories);E:\library\OpenLtemplate\include;</PublicIncludeDirectories>
    <IncludePath>$(IncludePath);E:\library\OpenGLtemplate\include;</IncludePath>
    <ReferencePath>$(ReferencePath)</ReferencePath>
    <LibraryPath>$(LibraryPath);E:\library\OpenGLtemplate\lib;</LibraryPath>
  </PropertyGroup>

完整版:

<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <ItemGroup Label="ProjectConfigurations">
    <ProjectConfiguration Include="Debug|Win32">
      <Configuration>Debug</Configuration>
      <Platform>Win32</Platform>
    </ProjectConfiguration>
    <ProjectConfiguration Include="Release|Win32">
      <Configuration>Release</Configuration>
      <Platform>Win32</Platform>
    </ProjectConfiguration>
    <ProjectConfiguration Include="Debug|x64">
      <Configuration>Debug</Configuration>
      <Platform>x64</Platform>
    </ProjectConfiguration>
    <ProjectConfiguration Include="Release|x64">
      <Configuration>Release</Configuration>
      <Platform>x64</Platform>
    </ProjectConfiguration>
  </ItemGroup>
  <PropertyGroup Label="Globals">
    <VCProjectVersion>16.0</VCProjectVersion>
    <Keyword>Win32Proj</Keyword>
    <ProjectGuid>{54721bc3-8a74-4187-8468-d0a3707553f1}</ProjectGuid>
    <RootNamespace>simpleglfw</RootNamespace>
    <WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
  </PropertyGroup>
  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
    <ConfigurationType>Application</ConfigurationType>
    <UseDebugLibraries>true</UseDebugLibraries>
    <PlatformToolset>v143</PlatformToolset>
    <CharacterSet>Unicode</CharacterSet>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
    <ConfigurationType>Application</ConfigurationType>
    <UseDebugLibraries>false</UseDebugLibraries>
    <PlatformToolset>v143</PlatformToolset>
    <WholeProgramOptimization>true</WholeProgramOptimization>
    <CharacterSet>Unicode</CharacterSet>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
    <ConfigurationType>Application</ConfigurationType>
    <UseDebugLibraries>true</UseDebugLibraries>
    <PlatformToolset>v143</PlatformToolset>
    <CharacterSet>Unicode</CharacterSet>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
    <ConfigurationType>Application</ConfigurationType>
    <UseDebugLibraries>false</UseDebugLibraries>
    <PlatformToolset>v143</PlatformToolset>
    <WholeProgramOptimization>true</WholeProgramOptimization>
    <CharacterSet>Unicode</CharacterSet>
  </PropertyGroup>
  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
  <ImportGroup Label="ExtensionSettings">
  </ImportGroup>
  <ImportGroup Label="Shared">
  </ImportGroup>
  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
  </ImportGroup>
  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
  </ImportGroup>
  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
  </ImportGroup>
  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
  </ImportGroup>
  <PropertyGroup Label="UserMacros" />
  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
    <PublicIncludeDirectories>$(PublicIncludeDirectories);E:\library\OpenLtemplate\include;</PublicIncludeDirectories>
    <IncludePath>$(IncludePath);E:\library\OpenGLtemplate\include;</IncludePath>
    <ReferencePath>$(ReferencePath)</ReferencePath>
    <LibraryPath>$(LibraryPath);E:\library\OpenGLtemplate\lib;</LibraryPath>
  </PropertyGroup>
  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
    <ClCompile>
      <WarningLevel>Level3</WarningLevel>
      <SDLCheck>true</SDLCheck>
      <PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
      <ConformanceMode>true</ConformanceMode>
    </ClCompile>
    <Link>
      <SubSystem>Console</SubSystem>
      <GenerateDebugInformation>true</GenerateDebugInformation>
    </Link>
  </ItemDefinitionGroup>
  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
    <ClCompile>
      <WarningLevel>Level3</WarningLevel>
      <FunctionLevelLinking>true</FunctionLevelLinking>
      <IntrinsicFunctions>true</IntrinsicFunctions>
      <SDLCheck>true</SDLCheck>
      <PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
      <ConformanceMode>true</ConformanceMode>
    </ClCompile>
    <Link>
      <SubSystem>Console</SubSystem>
      <EnableCOMDATFolding>true</EnableCOMDATFolding>
      <OptimizeReferences>true</OptimizeReferences>
      <GenerateDebugInformation>true</GenerateDebugInformation>
    </Link>
  </ItemDefinitionGroup>
  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
    <ClCompile>
      <WarningLevel>Level3</WarningLevel>
      <SDLCheck>true</SDLCheck>
      <PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
      <ConformanceMode>true</ConformanceMode>
    </ClCompile>
    <Link>
      <SubSystem>Console</SubSystem>
      <GenerateDebugInformation>true</GenerateDebugInformation>
      <AdditionalLibraryDirectories>%(AdditionalLibraryDirectories);E:\library\OpenGLtemplate\lib</AdditionalLibraryDirectories>
      <AdditionalDependencies>%(AdditionalDependencies);glew32d.lib;glfw3.lib;opengl32.lib;soil2-debug.lib;</AdditionalDependencies>
    </Link>
  </ItemDefinitionGroup>
  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
    <ClCompile>
      <WarningLevel>Level3</WarningLevel>
      <FunctionLevelLinking>true</FunctionLevelLinking>
      <IntrinsicFunctions>true</IntrinsicFunctions>
      <SDLCheck>true</SDLCheck>
      <PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
      <ConformanceMode>true</ConformanceMode>
    </ClCompile>
    <Link>
      <SubSystem>Console</SubSystem>
      <EnableCOMDATFolding>true</EnableCOMDATFolding>
      <OptimizeReferences>true</OptimizeReferences>
      <GenerateDebugInformation>true</GenerateDebugInformation>
    </Link>
  </ItemDefinitionGroup>
  <ItemGroup>
    <ClCompile Include="simple_glfw.cpp" />
  </ItemGroup>
  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
  <ImportGroup Label="ExtensionTargets">
  </ImportGroup>
</Project>

在界面上并不好找,不如直接改xml,reload solution

等效进入Properties配置

Build

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/1026808.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

嵌入式Linux--进程间通讯--消息队列

1.需要知道的问题&#xff1a; 1、如何创建消息队列&#xff08;A\B使用同一个队列通信&#xff09; 2、如何加消息到队列&#xff08;队列是链表&#xff09; 3、如何从队列拿到消息 消息队列&#xff1a; 消息队列&#xff0c;是消息的链接表&#xff0c;存放在内核中。一个…

爬虫异常处理技巧分享

在进行爬虫数据采集的过程中&#xff0c;我们常常会遇到网络波动和自动化验证等异常情况。这些问题可能导致爬虫运行中断或被识别为机器请求而受到限制。本文将分享一些实用的爬虫异常处理技巧&#xff0c;帮助您规避网络波动和自动化验证&#xff0c;提高数据采集的稳定性和成…

轻量型服务器能支撑多少人访问?

一、服务器配置影响访问人数 服务器的配置是影响轻量型服务器能够支撑的访问人数的关键因素之一。通常而言&#xff0c;轻量型服务器的配置普遍不高&#xff0c;适合小型团队或个人使用。如果服务器配置较低&#xff0c;那么支撑访问人数的能力也会受到限制。较为简单的应用程序…

在GIS(地理信息系统)中,常见的地理文件记录

在GIS&#xff08;地理信息系统&#xff09;中&#xff0c;常见的地理文件包括以下几种&#xff1a; .cpg&#xff08;Code Page文件&#xff09;&#xff1a;这个文件是指定地理数据文件编码的文件&#xff0c;它告诉软件如何正确地读取和解释地理数据文件中的字符编码。比如…

[BJDCTF2020]EasySearch Apache SSI漏洞

这道题有点意思 是SSI 漏洞 照样 我们先熟悉SSI漏洞是什么 SSI 服务端包含 SSI 提供了对现有html增加动态的效果是嵌入 html的指令 只有网页被调用了 才会执行允许执行命令 所以会造成rce 使用条件 当文件上传的时候 无法上传php但是服务器开启了 SSI CGI支持就可以通过 …

第二证券:算力概念强势拉升,竞业达涨停,南凌科技等大涨

算力概念20日盘中强势拉升&#xff0c;到发稿&#xff0c;竞业达涨停&#xff0c;南凌科技涨近10%&#xff0c;拓维信息涨近9%&#xff0c;亚康股份、神州数码涨约5%&#xff0c;青云科技涨逾4%。 音讯面上&#xff0c;9月19日&#xff0c;国际大学生程序设计竞赛&#xff08;…

Vue语法

目录 事件处理器 是什么 案列 表单的综合案列 定义 常用功能 组件通信 定义 父传子 ​编辑 子传父 事件处理器 是什么 事件处理器是一种函数&#xff0c;用于响应和处理事件的触发。在编程中&#xff0c;当特定事件发生时&#xff0c;可以通过事件处理器来执行相应的…

正则表达式的学习笔记

[!note] 其实这个正则表达式整体上不难, 自从这个 gpt 出来之后这种正则表达式已经不需要我们去写了, 我们并不需要自己能够去写特别深奥的代码, 我们可以将这个正则表达式交给 gpt 去做, 我们只需要能够看懂就行了, 所以学习这个正则表达式, 自己写不出来那种比较难的正则没有…

Apache Doris 快速入门

1. 基本概念 FE&#xff0c;Frontend&#xff0c;前端节点&#xff0c;接收用户查询请求&#xff0c;SQL解析&#xff0c;执行计划生成&#xff0c;元数据管理&#xff0c;节点管理等 BE&#xff0c;Backend&#xff0c;后端节点&#xff0c;数据存储&#xff0c;执行查询计划…

什么是SVG(可缩放矢量图形)?它与普通图像格式有何不同?

聚沙成塔每天进步一点点 ⭐ 专栏简介⭐ 什么是SVG&#xff1f;⭐ 与普通图像格式的不同⭐ 写在最后 ⭐ 专栏简介 前端入门之旅&#xff1a;探索Web开发的奇妙世界 欢迎来到前端入门之旅&#xff01;感兴趣的可以订阅本专栏哦&#xff01;这个专栏是为那些对Web开发感兴趣、刚刚…

Docker部署jar包、数据库、中间件

centos7下载docker&#xff1a;https://blog.csdn.net/qq_39997939/article/details/131005939 1、编写dockerfile https://blog.csdn.net/liben0429/article/details/126858971 2、如何确定在dockerfile安装jdk11 https://www.5axxw.com/questions/content/mc5fpt 打包镜…

python使用websocket实现多端数据同步,多个websocket同步消息,断开链接自动清理

我使用的是flask_sock这个模块&#xff0c;我的使用场景是&#xff1a;可以让数据多端实时同步。在游戏控制后台和游戏选手的ipad上都可以实时调整角色的技能和点数什么的&#xff0c;所以需要这样的一个功能来实现数据实时同步。 下面是最小的demo案例&#xff1a; from fla…

【Docker-MyCat】分库分表中间件mycat安装使用(docker版)

分库分表中间件mycat安装使用&#xff08;docker版&#xff09; 1.创建Mycat文件夹2.创建Docker文件夹3.下载Mycat并解压4.编写Dockerfile文件5.打包镜像6.启动镜像7.连接测试 想使用mycat实现mysql分库分表功能&#xff0c;但是docker镜像里&#xff0c;几乎没有mycat&#xf…

IntelliJ IDEA - Maven 在控制台Maven编译正常,但是在IDEA中不正常,表现不一致

文章目录 现象原因解决验证 现象 一个Maven项目&#xff0c;当导入到IDEA后&#xff0c;无法在IDEA中正常的编译和下载jar依赖&#xff0c;类似下面的截图。 但是在Windows控制台却可以正常编译&#xff0c;类似下面的截图。 CMD执行&#xff1a;mvn clean install -Dmaven.te…

flink集群与资源@k8s源码分析-资源I 资源请求

1 资源 资源分析分3部分,资源请求,资源提供,声明式资源管理,本文是第一部分资源请求 2 场景 资源处理有声明式处理资源和细粒度处理资源 是两个实现,两者不是并行的两种实现策略,声明式是资源申请和分配方式,粒度是指资源分割方式,细粒度按需可变的资源,粗粒度是固定…

注入之mssql数据库(手工注入)

sa最高权限&#xff08;可以获取系统权限&#xff09; 打开一个mssql数据库 要拼接一个参数 拼接这个参数?xxser1 检查是否是mssql数据库 and exists (select * from%20sysobjects) 为真是属于mssql 查询当前数据库系统的用户名 and system_user0 (由于版本问题谷歌不可以)…

flink集群与资源@k8s源码分析-总述

1 简介 集群和资源模块提供动态资源能力,是分布式系统关键基础设施,分布式datax,分布式索引,事件引擎都需要集群和资源的弹性资源能力,提高伸缩性和作业处理能力。本文分析flink的集群和资源的k8s模块,深入了解其设计原理,为开发自有的集群和资源组件做技术准备, 同时涉…

【大数据】HDFS 的常用命令

HDFS 的常用命令 1.操作命令1.1 创建文件夹1.2 列出指定的文件和目录1.3 新建文件1.4 上传文件1.5 将本地文件移动到 HDFS1.6 下载文件1.7 查看文件1.8 追写文件1.9 删除目录或者文件1.10 显示占用的磁盘空间大小1.11 HDFS 中的文件复制1.12 HDFS 中的文件移动 2.管理命令2.1 报…

什么是虚拟DOM(Virtual DOM)?它在前端框架中的作用是什么?

聚沙成塔每天进步一点点 ⭐ 专栏简介⭐ 什么是虚拟DOM&#xff08;Virtual DOM&#xff09;&#xff1f;⭐ 虚拟DOM 在前端框架中的作用⭐ 写在最后 ⭐ 专栏简介 前端入门之旅&#xff1a;探索Web开发的奇妙世界 欢迎来到前端入门之旅&#xff01;感兴趣的可以订阅本专栏哦&…

设计模式_解释器模式

解释器模式 案例 角色 1 解释器基类 &#xff08;BaseInterpreter&#xff09; 2 具体解释器1 2 3... (Interperter 1 2 3 ) 3 内容 (Context) 4 用户 (user) 流程 (上下文) ---- 传…