Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Adam Lastowka
- Linking GLEW/GLFW with Visual Studio 2013 Express C++
- 1. Download GLEW and the Win32 GLFW binaries (even if you have a 64-bit OS!!) and unzip. Put in an easily accessible folder (I put mine in a folder called VS_DEV_LIB)
- 2. Open Visual Studio and make a new empty C++ project.
- 3. Right click on the project (not the solution) in the solution explorer and go to properties.
- 4. In the upper left hand corner of the properties tab, switch the configuration to All Configurations.
- 5. Under Configuration Properties->VC++ Directories, add the following to Include Directories:
- VS_DEV_LIB\glfw-3.0.4.bin.WIN32\include
- VS_DEV_LIB\glew-1.10.0-win32\include
- Then add the following to Library Directories:
- VS_DEV_LIB\glfw-3.0.4.bin.WIN32\lib-msvc120
- VS_DEV_LIB\glew-1.10.0-win32\lib
- 6. Under Configuration Properties->Linker->Input, add the following to Additional Dependencies:
- opengl32.lib
- glu32.lib
- glew32.lib
- glfw3.lib
- 7. Put glew32.dll into the folder with your .vcxproj file (Visual Studio 2013\Projects\OpenGLTest\OpenGLTest\).
- 8. You are now done! Test your project’s link with this code:
- */
- //Include GLEW
- #include <GL/glew.h>
- //Include GLFW
- #include <GLFW/glfw3.h>
- //Include the standard C++ headers
- #include <stdio.h>
- #include <stdlib.h>
- //Printing stuff ya'know
- #include <iostream>
- //Yay math
- #include <math.h>
- double tickNum = 0.0;
- int resSX;
- int resSY;
- void setProjections() {
- glViewport(0, 0, resSX, resSY);
- glLoadIdentity();
- }
- int main() {
- fprintf(stdout, "/////CORE INITIALIZATION STARTED/////\n");
- //Initialize GLFW//
- if (!glfwInit()) {
- fprintf(stderr, "Failed to initialize GLFW\n");
- system("PAUSE");
- return -1;
- } else
- fprintf(stdout, "GLFW initialized successfully!\n");
- //FSAA because AWESOME//
- //glfwWindowHint(GLFW_SAMPLES, 1);
- //Create GLFW window//
- GLFWwindow* window;
- window = glfwCreateWindow(1280, 720, "AuLC++Port", NULL, NULL);
- if (!window) {
- fprintf(stderr, "Failed to open GLFW window.\n");
- glfwTerminate();
- exit(EXIT_FAILURE);
- } else
- fprintf(stdout, "GLFW window created successfully!.\n");
- glfwMakeContextCurrent(window);
- //Print Version//
- printf("OpenGL Version: %s\n", glGetString(GL_VERSION));
- //Initialize GLEW after context creation//
- if (glewInit() != GLEW_OK) {
- fprintf(stderr, "Failed to initialize GLEW\n");
- system("PAUSE");
- return -1;
- } else
- fprintf(stdout, "GLEW initialized successfully!\n");
- fprintf(stdout, "/////CORE INITIALIZATION COMPLETED/////\n\n");
- //Peach clear color//
- glClearColor(1.0f, 0.6f, 0.3f, 1.0f);
- //Update Loop//
- do {
- //Clear color and depth//
- glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
- //This is bad outdated practice, don't do it lol//
- float r = 1.0;
- glBegin(GL_TRIANGLES);
- glColor3f(1.0f, 0.0f, 0.0f);
- glVertex2f(-0.5f*r, -0.7f*r);
- glColor3f(1.0f, 1.0f, 0.0f);
- glVertex2f(0.1f*r, 0.7f*r);
- glColor3f(static_cast<float>(sin(tickNum / 100.0f)*1.0f), 1.0f, 1.0f);
- glVertex2f(0.7f*r, 0.0f - 0.6f);
- glEnd();
- //Swap buffers//
- glfwSwapBuffers(window);
- //Poll events, this is like check if window closed, key pressed, etc.//
- glfwPollEvents();
- //Increase tick//
- tickNum++;
- //Refresh Resolution//
- glfwGetWindowSize(window, &resSX, &resSY);
- setProjections();
- } while (!glfwWindowShouldClose(window));
- //Close window and end GLFW when finished//
- glfwDestroyWindow(window);
- glfwTerminate();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement