windows Visual Studio 2022 opengl开发环境配置

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.rhkb.cn/news/141849.html

如若内容造成侵权/违法违规/事实不符,请联系长河编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

python过滤敏感词

敏感词一般是指带有敏感政治倾向&#xff08;或反执政党倾向&#xff09;、暴力倾向、不健康色彩的词或不文明用语&#xff0c;论坛、网站管理员一般会设定一些敏感词&#xff0c;以防不当发言影响论坛、网站环境。若论坛、网站设置了敏感词&#xff0c;用户编辑的内容又含有敏…

Vue模板语法【下】事件处理器,表单、自定义组件、通信组件

目录 一、事件处理器 1.1常用的事件修饰符 1.2常用的按键修饰符 二&#xff0c;vue中的表单 三、自定义组件 四&#xff0c;通信组件 一、事件处理器 1.1常用的事件修饰符 Vue的事件修饰符是用来改变事件的默认行为或者添加额外的功能。以下是一些常用的事件修饰符及其…

checksec使用

checksec Relro&#xff1a;Full Relro&#xff08;重定位表只读&#xff09; Relocation Read Only&#xff0c; 重定位表只读。重定位表即.got 和 .plt个表。 Stack&#xff1a;No Canary found&#xff08;能栈溢出&#xff09; 栈保护。栈溢出保护是一种缓冲区溢出攻击缓解…

Lostash同步Mysql数据到ElasticSearch(二)logstash脚本配置和常见坑点

1. logstash脚本编写&#xff08;采用单文件对应单表实例&#xff09; 新建脚本文件夹 cd /usr/local/logstash mkdir sql & cd sql vim 表名称.conf #如: znyw_data_gkb_logstash.conf 建立文件夹&#xff0c;保存资源文件更新Id mkdir -p /data/logstash/data/last_r…

深入理解 Swift 新并发模型中 Actor 的重入(Reentrancy)问题

问题现象 我们知道,Swift 5.5 引入的新并发模型极大简化了并行逻辑代码的开发,更重要的是:使用新并发模型中的 Actor 原语可以大大降低并发数据竞争的可能性。 不过,即便 Actor 有如此神奇之功效,它也不是“万能药”,仍不能防止误用带来的问题。比如:Actor 重入(Reen…

Centos7安装go解释器

Centos7安装go解释器 下载解压go压缩包编辑go变量结果验证 下载解压go压缩包 # 下载 wget -c https://go.dev/dl/go1.20.2.linux-amd64.tar.gz# 解压到指定目录 tar xvf go1.20.2.linux-amd64.tar.gz -C /usr/local/编辑go变量 /etc/profile.d/go.sh # 指定go执行程序位置 e…

【软件测试】资深测试聊,自动化测试分层实践,彻底打通高阶...

目录&#xff1a;导读 前言一、Python编程入门到精通二、接口自动化项目实战三、Web自动化项目实战四、App自动化项目实战五、一线大厂简历六、测试开发DevOps体系七、常用自动化测试工具八、JMeter性能测试九、总结&#xff08;尾部小惊喜&#xff09; 前言 自动化测试的分层…

spring6概述

spring6 1、概述1.1、Spring是什么&#xff1f;1.2、Spring 的狭义和广义1.3、Spring Framework特点1.4、Spring模块组成1.5、Spring6特点1.5.1、版本要求 2.2、构建模块2.3、程序开发2.3.1、引入依赖2.3.3、创建配置文件2.3.4、创建测试类测试2.3.5、运行测试程序 2.4、程序分…

LeetCode算法二叉树—144. 二叉树的前序遍历

目录 144. 二叉树的前序遍历 - 力扣&#xff08;LeetCode&#xff09; 代码&#xff1a; 运行结果&#xff1a; 示例 1&#xff1a; 输入&#xff1a;root [1,null,2,3] 输出&#xff1a;[1,2,3]示例 2&#xff1a; 输入&#xff1a;root [] 输出&#xff1a;[]示例 3&am…

Leetcode 386. 字典序排数

文章目录 题目代码&#xff08;9.22 首刷看解析&#xff09; 题目 Leetcode 386. 字典序排数 代码&#xff08;9.22 首刷看解析&#xff09; 迭代DFS class Solution { public:vector<int> lexicalOrder(int n) {vector<int> ret(n);int number 1;for(int i 0…

可视化工具Datart踩(避)坑指南(4)——丢失的精度

作为目前国内开源版本最好用的可视化工具&#xff0c;Datart无疑是低成本高效率可供二开的可视化神兵利器。当然&#xff0c;免费的必然要付出一些踩坑的代价。本篇我们来讲一讲可视化工具Datart踩&#xff08;避&#xff09;坑指南&#xff08;4&#xff09;之丢失的精度。 版…

麦肯锡:中国生成式AI市场现状和未来发展趋势

本文来自《麦肯锡中国金融业CEO季刊》&#xff0c;版权归麦肯锡所有。该季刊主要围绕生成式AI&#xff08;以下简称“GenAI”&#xff09;主题&#xff0c;通过4大章节共8篇文章&#xff0c;全面深入分析了GenAI对各主要行业的影响、价值链投资机会、中国GenAI市场现状和未来趋…

【QandA C++】内存泄漏、进程地址空间、堆和栈、内存对齐、大小端和判断、虚拟内存等重点知识汇总

目录 内存泄漏 内存模型 、进程地址空间 堆和栈的区别 内存对齐 大端小端及判断 虚拟内存有什么作用 内存泄漏 概念: 是指因为疏忽或错误造成程序未能释放已经不再使用的内存的情况, 内存泄漏并不是指内存在物理上的消失, 而是应用程序分配了某段内存后, 因为设计错误…

Leetcode---363周赛

题目列表 2859. 计算 K 置位下标对应元素的和 2860. 让所有学生保持开心的分组方法数 2861. 最大合金数 2862. 完全子集的最大元素和 一、计算k置为下标对应元素的和 简单题&#xff0c;直接暴力模拟&#xff0c;代码如下 class Solution { public:int sumIndicesWithKS…

什么是关系模型? 关系模型的基本概念

关系模型由IBM公司研究员Edgar Frank Codd于1970年发表的论文中提出&#xff0c;经过多年的发展&#xff0c;已经成为目前最常用、最重要的模型之一。 在关系模型中有一些基本的概念&#xff0c;具体如下。 (1)关系(Relation)。关系一词与数学领域有关&#xff0c;它是集合基…

第二届全国高校计算机技能竞赛——Java赛道

第二届全国高校计算机技能竞赛——Java赛道 小赛跳高 签到题 import java.util.*; public class Main{public static void main(String []args) {Scanner sc new Scanner(System.in);double n sc.nextDouble();for(int i 0; i < 4; i) {n n * 0.9;}System.out.printf(&…

Jenkins+Allure+Pytest的持续集成

一、配置 allure 环境变量 1、下载 allure是一个命令行工具&#xff0c;可以去 github 下载最新版&#xff1a;https://github.com/allure-framework/allure2/releases 2、解压到本地 3、配置环境变量 复制路径如&#xff1a;F:\allure-2.13.7\bin 环境变量、Path、添加 F:\a…

Linux系统离线安装Python

目录 一、简介 二、前提准备 三、下载Python源码 四、将离线python包传输到Linux主机 五、编译以及创建软链接 一、简介 由于工作原因&#xff0c;我们经常会在内网环境下使用Linux&#xff0c;不过这样会让我们安装一些软件变得困难&#xff0c;例如需要安装Python。虽然…

解决Pycharm使用Conda激活环境失败的问题

Q:公司电脑终端使用powershell来激活conda环境时报错? 同时手动打开powershell报"profile.ps1” 无法被加载的错误 A: 1,手动打开powershell&#xff0c;设置管理员打开 2,打开powershell 打开 PowerShell 终端&#xff0c;并输入以下命令&#xff1a;Get-ExecutionPo…

气导耳机是什么样的?盘点五款好用的气传导耳机分享

​气传导耳机在运动、户外、办公等场景中具有独特的优势。然而&#xff0c;面对市场上琳琅满目的气传导耳机产品&#xff0c;很多用户不知如何下手。接下来&#xff0c;我将推荐市面上热销火爆&#xff0c;并性能出色、性价比高的气传导耳机给大家&#xff0c;希望大家都能选到…