-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPlanarMesh.cpp
More file actions
79 lines (66 loc) · 2.41 KB
/
Copy pathPlanarMesh.cpp
File metadata and controls
79 lines (66 loc) · 2.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#include "PlanarMesh.h"
#include "common\texture.hpp"
PLANARMESH::PLANARMESH () {}
PLANARMESH::~PLANARMESH ()
{
glDeleteBuffers ( 1, &vertexbuffer );
glDeleteBuffers ( 1, &uvbuffer );
glDeleteTextures ( 1, &TextureID1 );
glDeleteTextures ( 1, &TextureID2 );
glDeleteTextures ( 1, &TextureID3 );
glDeleteTextures ( 1, &TextureID4 );
}
void PLANARMESH::LoadTexture ( textureNumbers _textureNumber, const char * fragment_file_path )
{
int result = loadBMP_custom ( fragment_file_path );
if ( result )
{
switch ( _textureNumber )
{
case PLANARMESH::first:
//glDeleteTextures ( 1, &TextureID1 );
Textures[ 0 ] = result; TextureID1 = glGetUniformLocation ( programID, "Texture1" );
break;
case PLANARMESH::second:
//glDeleteTextures ( 1, &TextureID2 );
Textures[ 1 ] = result; TextureID2 = glGetUniformLocation ( programID, "Texture2" );
break;
case PLANARMESH::third:
//glDeleteTextures ( 1, &TextureID3 );
Textures[ 2 ] = result; TextureID3 = glGetUniformLocation ( programID, "Texture3" );
break;
case PLANARMESH::fourth:
//glDeleteTextures ( 1, &TextureID4 );
Textures[ 3 ] = result; TextureID4 = glGetUniformLocation ( programID, "Texture4" );
break;
default:
break;
}
}
}
void PLANARMESH::ChangeMeshSize ( int _x, int _y )
{
Vertices[ 0 ] = -STEP*_x; Vertices[ 1 ] = 0; Vertices[ 2 ] = STEP*_y;
Vertices[ 3 ] = STEP*_x; Vertices[ 4 ] = 0; Vertices[ 5 ] = STEP*_y;
Vertices[ 6 ] = -STEP*_x; Vertices[ 7 ] = 0; Vertices[ 8 ] = -STEP*_y;
Vertices[ 9 ] = -STEP*_x; Vertices[ 10 ] = 0; Vertices[ 11 ] = -STEP*_y;
Vertices[ 12 ] = STEP*_x; Vertices[ 13 ] = 0; Vertices[ 14 ] = STEP*_y;
Vertices[ 15 ] = STEP*_x; Vertices[ 16 ] = 0; Vertices[ 17 ] = -STEP*_y;
glDeleteBuffers ( 1, &vertexbuffer );
glGenBuffers ( 1, &vertexbuffer );
glBindBuffer ( GL_ARRAY_BUFFER, vertexbuffer );
glBufferData ( GL_ARRAY_BUFFER, sizeof ( Vertices ), Vertices, GL_STATIC_DRAW );
}
void PLANARMESH::CreateUVBuffer ()
{
uvVertices[ 0 ] = 0; uvVertices[ 1 ] = 1;
uvVertices[ 2 ] = 1; uvVertices[ 3 ] = 1;
uvVertices[ 4 ] = 0; uvVertices[ 5 ] = 0;
uvVertices[ 6 ] = 0; uvVertices[ 7 ] = 0;
uvVertices[ 8 ] = 1; uvVertices[ 9 ] = 1;
uvVertices[ 10 ] = 1; uvVertices[ 11 ] = 0;
glDeleteBuffers ( 1, &uvbuffer );
glGenBuffers ( 1, &uvbuffer );
glBindBuffer ( GL_ARRAY_BUFFER, uvbuffer );
glBufferData ( GL_ARRAY_BUFFER, sizeof ( uvVertices ), uvVertices, GL_STATIC_DRAW );
}