Expanding dot example

master
sigonasr2 1 year ago
parent d493d60fe5
commit 173ac6e344
  1. 159
      Dot/Dot.vcxproj
  2. 38
      Dot/Dot.vcxproj.filters
  3. 39
      Dot/ShaderError.h
  4. 11
      Dot/fragShader.glsl
  5. BIN
      Dot/glew32.dll
  6. 57
      Dot/main.cpp
  7. 74
      Dot/utils.h
  8. 5
      Dot/vertShader.glsl
  9. 10
      OpenGLTemplate.sln
  10. 4
      OpenGLTemplate/OpenGLTemplate.vcxproj
  11. 11
      OpenGLTemplate/main.cpp

@ -0,0 +1,159 @@
<?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>{58758496-b3f4-482c-93ba-740c847a58cb}</ProjectGuid>
<RootNamespace>Dot</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" />
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<AdditionalIncludeDirectories>C:\Users\sigon\Documents\OpenGL\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<LanguageStandard>stdcpp17</LanguageStandard>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalLibraryDirectories>C:\Users\sigon\Documents\OpenGL\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalDependencies>glfw3.lib;glew32.lib;soil2-debug.lib;opengl32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</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>
<AdditionalIncludeDirectories>C:\Users\sigon\Documents\OpenGL\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<LanguageStandard>stdcpp17</LanguageStandard>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalLibraryDirectories>C:\Users\sigon\Documents\OpenGL\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalDependencies>glfw3.lib;glew32.lib;soil2-debug.lib;opengl32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<AdditionalIncludeDirectories>C:\Users\sigon\Documents\OpenGL\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<LanguageStandard>stdcpp17</LanguageStandard>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalLibraryDirectories>C:\Users\sigon\Documents\OpenGL\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalDependencies>glfw3.lib;glew32.lib;soil2-debug.lib;opengl32.lib;%(AdditionalDependencies)</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>
<AdditionalIncludeDirectories>C:\Users\sigon\Documents\OpenGL\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<LanguageStandard>stdcpp17</LanguageStandard>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalLibraryDirectories>C:\Users\sigon\Documents\OpenGL\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalDependencies>glfw3.lib;glew32.lib;soil2-debug.lib;opengl32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="main.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="ShaderError.h" />
<ClInclude Include="utils.h" />
</ItemGroup>
<ItemGroup>
<None Include="fragShader.glsl" />
<None Include="vertShader.glsl" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

@ -0,0 +1,38 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd</Extensions>
</Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="main.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="ShaderError.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="utils.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="fragShader.glsl">
<Filter>Resource Files</Filter>
</None>
<None Include="vertShader.glsl">
<Filter>Resource Files</Filter>
</None>
</ItemGroup>
</Project>

@ -0,0 +1,39 @@
#pragma once
#include <GL/glew.h>
#include <cstdlib>
#include <iostream>
namespace ErrorCheck{
inline void printShaderLog(GLuint shader) {
int len = 0;
int chWrittn = 0;
char *log;
glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &len);
if (len > 0) {
log = (char *)malloc(len);
glGetShaderInfoLog(shader, len, &chWrittn, log);
std::cout << "Shader Info Log: " << log << std::endl;
free(log);
} }
inline void printProgramLog(int prog) {
int len = 0;
int chWrittn = 0;
char *log;
glGetProgramiv(prog, GL_INFO_LOG_LENGTH, &len);
if (len > 0) {
log = (char *)malloc(len);
glGetProgramInfoLog(prog, len, &chWrittn, log);
std::cout << "Program Info Log: " << log << std::endl;
free(log);
} }
inline bool checkOpenGLError() {
bool foundError = false;
int glErr = glGetError();
while (glErr != GL_NO_ERROR) {
std::cout << "glError: " << glErr << std::endl;
foundError = true;
glErr = glGetError();
}
return foundError;
}
}

@ -0,0 +1,11 @@
#version 430
out vec4 color;
void main(void)
{
color=vec4(
(gl_FragCoord.x) / 600.f,
0.0,
1-(gl_FragCoord.x) / 600.f,
1.0
);
}

Binary file not shown.

@ -0,0 +1,57 @@
#include <GL/glew.h>
#include <GLFW/glfw3.h>
#include "utils.h"
#include <algorithm>
#define numVAOs 1
GLuint renderingProgram;
GLuint vao[numVAOs];
void init(GLFWwindow* window) {
renderingProgram=utils::createShaderProgram("vertShader.glsl","fragShader.glsl");
glGenVertexArrays(numVAOs,vao);
glBindVertexArray(vao[0]);
}
float size=0;
float inc=150;
double lastTime=0;
void display(GLFWwindow* window, double currentTime) {
double elapsedTime=currentTime-lastTime;
lastTime=currentTime;
glClear(GL_DEPTH_BUFFER_BIT);
glClearColor(0,0,0.2,1);
glClear(GL_COLOR_BUFFER_BIT);
glUseProgram(renderingProgram);
size+=inc*elapsedTime;
if(size>300||size<1){inc*=-1;size=std::clamp(size,1.f,300.f);}
glPointSize(size);
glDrawArrays(GL_POINTS,0,1);
}
int main(void) {
if (!glfwInit()) { exit(EXIT_FAILURE); }
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 4);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
GLFWwindow* window = glfwCreateWindow(300, 300, "Expanding Dot", 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);
}

@ -0,0 +1,74 @@
#pragma once
#include <string>
#include <fstream>
#include <GL/glew.h>
#include "ShaderError.h"
class utils{
inline static std::string readShaderSource(const char *filePath){
std::string content;
std::ifstream fileStream(filePath, std::ios::in);
std::string line = "";
if(fileStream.fail()){
std::cout<<"Could not open shader "<<filePath<<"!"<<std::endl;
throw;
}
while (fileStream.good()) {
getline(fileStream, line);
content.append(line + "\n");
}
fileStream.close();
return content;
}
inline static void CompileShader(GLuint shader,std::string type){
GLint compiled;
glCompileShader(shader);
ErrorCheck::checkOpenGLError();
glGetShaderiv(shader,GL_COMPILE_STATUS,&compiled);
if(compiled!=1){
std::cout<<type<<" Compilation Failed!"<<std::endl;
ErrorCheck::printShaderLog(shader);
throw;
}
}
inline static void CreateShader(GLuint type,std::string shaderName,const char*source,GLuint vfProgram){
if(source!=nullptr){
GLuint vShader=glCreateShader(type);
std::string shaderFile=readShaderSource(source);
const char*vertShaderSrc=shaderFile.c_str();
glShaderSource(vShader,1,&vertShaderSrc,NULL);
CompileShader(vShader,shaderName);
glAttachShader(vfProgram,vShader);
}
};
public:
inline static GLuint createShaderProgram(const char*vertex,const char*fragment){
return createShaderProgram(vertex,nullptr,nullptr,nullptr,fragment);
}
inline static GLuint createShaderProgram(const char*vertex,const char*geometry,const char*fragment){
return createShaderProgram(vertex,nullptr,nullptr,geometry,fragment);
}
inline static GLuint createShaderProgram(const char*vertex,const char*tesselationCS,const char*tesselationES,const char*fragment){
return createShaderProgram(vertex,tesselationCS,tesselationES,nullptr,fragment);
}
inline static GLuint createShaderProgram(const char*vertex,const char*tesselationCS,const char*tesselationES,const char*geometry,const char*fragment){
GLuint vfProgram=glCreateProgram();
CreateShader(GL_VERTEX_SHADER,"Vertex",vertex,vfProgram);
CreateShader(GL_FRAGMENT_SHADER,"Fragment",fragment,vfProgram);
CreateShader(GL_TESS_CONTROL_SHADER,"Tesselation Control",tesselationCS,vfProgram);
CreateShader(GL_TESS_EVALUATION_SHADER,"Tesselation Evaluation",tesselationES,vfProgram);
CreateShader(GL_GEOMETRY_SHADER,"Geometry",geometry,vfProgram);
GLint linked;
glLinkProgram(vfProgram);
ErrorCheck::checkOpenGLError();
glGetProgramiv(vfProgram,GL_LINK_STATUS,&linked);
if(linked!=1){
std::cout<<"Linking Failed!"<<std::endl;
ErrorCheck::printProgramLog(vfProgram);
}
return vfProgram;
}
};

@ -0,0 +1,5 @@
#version 430
void main(void)
{
gl_Position=vec4(0.0,0.0,0.0,1.0);
}

@ -5,6 +5,8 @@ VisualStudioVersion = 17.5.33516.290
MinimumVisualStudioVersion = 10.0.40219.1 MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "OpenGLTemplate", "OpenGLTemplate\OpenGLTemplate.vcxproj", "{5A265FC1-C688-45C2-8668-124D5B4AFA81}" Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "OpenGLTemplate", "OpenGLTemplate\OpenGLTemplate.vcxproj", "{5A265FC1-C688-45C2-8668-124D5B4AFA81}"
EndProject EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Dot", "Dot\Dot.vcxproj", "{58758496-B3F4-482C-93BA-740C847A58CB}"
EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64 Debug|x64 = Debug|x64
@ -21,6 +23,14 @@ Global
{5A265FC1-C688-45C2-8668-124D5B4AFA81}.Release|x64.Build.0 = Release|x64 {5A265FC1-C688-45C2-8668-124D5B4AFA81}.Release|x64.Build.0 = Release|x64
{5A265FC1-C688-45C2-8668-124D5B4AFA81}.Release|x86.ActiveCfg = Release|Win32 {5A265FC1-C688-45C2-8668-124D5B4AFA81}.Release|x86.ActiveCfg = Release|Win32
{5A265FC1-C688-45C2-8668-124D5B4AFA81}.Release|x86.Build.0 = Release|Win32 {5A265FC1-C688-45C2-8668-124D5B4AFA81}.Release|x86.Build.0 = Release|Win32
{58758496-B3F4-482C-93BA-740C847A58CB}.Debug|x64.ActiveCfg = Debug|x64
{58758496-B3F4-482C-93BA-740C847A58CB}.Debug|x64.Build.0 = Debug|x64
{58758496-B3F4-482C-93BA-740C847A58CB}.Debug|x86.ActiveCfg = Debug|Win32
{58758496-B3F4-482C-93BA-740C847A58CB}.Debug|x86.Build.0 = Debug|Win32
{58758496-B3F4-482C-93BA-740C847A58CB}.Release|x64.ActiveCfg = Release|x64
{58758496-B3F4-482C-93BA-740C847A58CB}.Release|x64.Build.0 = Release|x64
{58758496-B3F4-482C-93BA-740C847A58CB}.Release|x86.ActiveCfg = Release|Win32
{58758496-B3F4-482C-93BA-740C847A58CB}.Release|x86.Build.0 = Release|Win32
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE

@ -77,6 +77,7 @@
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions> <PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode> <ConformanceMode>true</ConformanceMode>
<AdditionalIncludeDirectories>C:\Users\sigon\Documents\OpenGL\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <AdditionalIncludeDirectories>C:\Users\sigon\Documents\OpenGL\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<LanguageStandard>stdcpp17</LanguageStandard>
</ClCompile> </ClCompile>
<Link> <Link>
<SubSystem>Console</SubSystem> <SubSystem>Console</SubSystem>
@ -94,6 +95,7 @@
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions> <PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode> <ConformanceMode>true</ConformanceMode>
<AdditionalIncludeDirectories>C:\Users\sigon\Documents\OpenGL\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <AdditionalIncludeDirectories>C:\Users\sigon\Documents\OpenGL\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<LanguageStandard>stdcpp17</LanguageStandard>
</ClCompile> </ClCompile>
<Link> <Link>
<SubSystem>Console</SubSystem> <SubSystem>Console</SubSystem>
@ -111,6 +113,7 @@
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions> <PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode> <ConformanceMode>true</ConformanceMode>
<AdditionalIncludeDirectories>C:\Users\sigon\Documents\OpenGL\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <AdditionalIncludeDirectories>C:\Users\sigon\Documents\OpenGL\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<LanguageStandard>stdcpp17</LanguageStandard>
</ClCompile> </ClCompile>
<Link> <Link>
<SubSystem>Console</SubSystem> <SubSystem>Console</SubSystem>
@ -128,6 +131,7 @@
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions> <PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode> <ConformanceMode>true</ConformanceMode>
<AdditionalIncludeDirectories>C:\Users\sigon\Documents\OpenGL\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <AdditionalIncludeDirectories>C:\Users\sigon\Documents\OpenGL\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<LanguageStandard>stdcpp17</LanguageStandard>
</ClCompile> </ClCompile>
<Link> <Link>
<SubSystem>Console</SubSystem> <SubSystem>Console</SubSystem>

@ -1,6 +1,7 @@
#include <GL/glew.h> #include <GL/glew.h>
#include <GLFW/glfw3.h> #include <GLFW/glfw3.h>
#include "utils.h" #include "utils.h"
#include <algorithm>
#define numVAOs 1 #define numVAOs 1
@ -13,8 +14,8 @@ void init(GLFWwindow* window) {
glBindVertexArray(vao[0]); glBindVertexArray(vao[0]);
} }
float x=0; float size=0;
float inc=0.01; float inc=2;
double lastTime=0; double lastTime=0;
void display(GLFWwindow* window, double currentTime) { void display(GLFWwindow* window, double currentTime) {
@ -26,11 +27,11 @@ void display(GLFWwindow* window, double currentTime) {
glClear(GL_COLOR_BUFFER_BIT); glClear(GL_COLOR_BUFFER_BIT);
glUseProgram(renderingProgram); glUseProgram(renderingProgram);
x+=inc;//*elapsedTime; size+=inc*elapsedTime;
if(x>1||x<-1){inc*=-1;} if(size>1||size<-1){inc*=-1;size=std::clamp(size,-1.f,1.f);}
GLuint offsetLoc=glGetUniformLocation(renderingProgram,"offset"); GLuint offsetLoc=glGetUniformLocation(renderingProgram,"offset");
glProgramUniform1f(renderingProgram,offsetLoc,x); glProgramUniform1f(renderingProgram,offsetLoc,size);
glDrawArrays(GL_TRIANGLES,0,3); glDrawArrays(GL_TRIANGLES,0,3);
} }

Loading…
Cancel
Save