|
1 | 1 |
|
2 | 2 | # Setting up graphics.h in VS Code(C++)
|
3 | 3 |
|
4 |
| -1. Download graphics header file. (https://drive.google.com/file/d/16xZBvFXf7yFjxwTpuyevK1KPuLgUeZFh/view) |
| 4 | +1. Download graphics header file from [here](https://drive.google.com/file/d/16xZBvFXf7yFjxwTpuyevK1KPuLgUeZFh/view) |
5 | 5 | 2. Download and install tdm-gcc 32bit compiler.
|
6 | 6 | 3. Copy files from include and lib folder from graphics folder file you downloaded in step 1 to include and lib folder of tdm-gcc 32bit.
|
7 | 7 | 4. Open VS Code and create a new project folder and open C/C++ configuration.
|
|
98 | 98 | ```
|
99 | 99 |
|
100 | 100 |
|
| 101 | +#Setting up OpenGL(freeglut) in Visual Studio |
| 102 | +
|
| 103 | +1. Download free glew and glut from [here](http://www.mediafire.com/file/cmlnr0pj0pyha5d/Glew_and_Glut.zip/file) |
| 104 | +2. Extract the files in a folder you desire.(you need the folder so never delete it unless you donot want to do opengl anymore) |
| 105 | +3. Open Visual Studio and create a C++ solution/project. |
| 106 | +4. Go to the properties of your project. |
| 107 | +  |
| 108 | +5. Inside properties go to C/C++ and in additional include directories include the include folders from the files you dowloaded before. |
| 109 | + |
| 110 | +6. Go to general of linker section and in additional library directories include the lib folders from the files you downloaded before. |
| 111 | + |
| 112 | +7. In the input of linker section add following in additional dependencies. |
| 113 | + -freeglut.lib |
| 114 | + -glew32.lib |
| 115 | +  |
| 116 | +8. Copy and paste following files you downloaded before in System32 folder. |
| 117 | + |
| 118 | +9. Now copy the code and build your project and run it, then you are good to go. |
| 119 | +``` |
| 120 | + #include<Gl/glut.h> |
| 121 | + |
| 122 | + void display() { |
| 123 | + |
| 124 | + glClear(GL_COLOR_BUFFER_BIT); |
| 125 | + |
| 126 | + glBegin(GL_POLYGON); |
| 127 | + glVertex3f(-0.6, -0.75, 0.5); |
| 128 | + glVertex3f(0.6, -0.75, 0); |
| 129 | + glVertex3f(0, 0.75, 0); |
| 130 | + |
| 131 | + glEnd(); |
| 132 | + |
| 133 | + glFlush(); |
| 134 | + } |
| 135 | + |
| 136 | + int main(int argc, char** argv) { |
| 137 | + |
| 138 | + glutInit(&argc, argv); |
| 139 | + glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB); |
| 140 | + |
| 141 | + |
| 142 | + glutInitWindowPosition(80, 80); |
| 143 | + glutInitWindowSize(400, 300); |
| 144 | + glutCreateWindow("A Simple Triangle"); |
| 145 | + |
| 146 | + glutDisplayFunc(display); |
| 147 | + glutMainLoop(); |
| 148 | + } |
| 149 | +``` |
| 150 | +
|
| 151 | +
|
101 | 152 |
|
102 | 153 |
|
103 | 154 |
|
|
0 commit comments