Hi all,
In my application I’m giving set of points to create curves .Now I have 3 set of points.The problem is that the 3rd curve is not displayed in the view.Can anybody plz help me with this.The code looks like this.
#include <GL/glew.h>
#include <GLFW/glfw3.h>
#include <iostream>
#include <sstream>
#include <fstream>
#define SCREEN_WIDTH 1064
#define SCREEN_HEIGHT 980
void keyCallback(GLFWwindow* window, int key, int scancode, int action, int mods);
GLfloat rotationX = 0.0f;
GLfloat rotationY = 0.0f;
GLfloat rotationZ = 0.0f;
int main(void)
{
GLFWwindow* window;
// Initialize the library
if (!glfwInit())
{
return -1;
}
// Create a windowed mode window and its OpenGL context
window = glfwCreateWindow(SCREEN_WIDTH, SCREEN_HEIGHT, "Hello World", NULL, NULL);
glfwSetKeyCallback(window, keyCallback);
glfwSetInputMode(window, GLFW_STICKY_KEYS, 1);
int screenWidth, screenHeight;
glfwGetFramebufferSize(window, &screenWidth, &screenHeight);
if (!window)
{
glfwTerminate();
return -1;
}
// Make the window's context current
glfwMakeContextCurrent(window);
glViewport(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0, SCREEN_WIDTH, -SCREEN_HEIGHT, SCREEN_HEIGHT, 0, 1000);
glMatrixMode(GL_MODELVIEW);
glFrustum(-1, 1, -1, 1, 1, 2);
glLoadIdentity();
GLfloat halfScreenWidth = SCREEN_WIDTH / 2;
GLfloat halfScreenHeight = SCREEN_HEIGHT / 2;
GLfloat lineVertices[] =
{
0.880204 , 60.1862 , 4.91689,//77
0.966022 , 60.1704 ,4.72757,
1.03989 , 60.1549 , 4.53326,
1.10158 , 60.1399 , 4.33471,
1.15083 , 60.1254 , 4.13268,
1.18746 , 60.1115 , 3.92793,
1.21133 , 60.0985 , 3.72125,
1.22234 , 60.0863 , 3.51345,
1.22047 , 60.0751 , 3.3053,
1.2057 , 60.0648 , 3.09763,
1.1781 , 60.0554 , 2.89122,
1.13777 , 60.0471 , 2.68687,
1.08487 , 60.0398 , 2.48537,
1.01959 , 60.0334 , 2.2875,
0.942182 ,60.0278 , 2.09403,
0.852942 ,60.0231 , 1.9057,
0.752209 ,60.0192 , 1.72324,
0.640367 ,60.0159 , 1.54736,
0.517845 , 60.0131 , 1.37874,
0.385107 , 60.0107 , 1.21802,
0.242664 , 60.0087 , 1.06584,
0.0910581 , 60.0068 , 0.922777,
-0.0691285 , 60.005 , 0.789395,
-0.237282 , 60.0031 , 0.666208,
-0.412757 , 60.0011 , 0.553698,
-0.594876 , 59.9987 , 0.452303,
-0.782939 , 59.996 , 0.362421,
-0.976218 , 59.9927 , 0.284403,
-1.17397 , 59.9889 , 0.218556,
-1.37541 , 59.9845 , 0.165141,
-1.57978 , 59.9793 , 0.124368,
-1.78627 , 59.9735 , 0.096401,
-1.99408 , 59.9669 , 0.0813497,
-2.2024 , 59.9596, 0.0792746,
-2.41041 , 59.9516 , 0.0901881,
-2.61732 , 59.943 , 0.114046,
-2.82231 , 59.9338 , 0.150758,
-3.02459 , 59.924 , 0.200182,
-3.22338 , 59.9139 , 0.262124,
-3.41789 , 59.9035 , 0.336345,
-3.60739 , 59.8929 , 0.422556,
-3.79114 , 59.8823 , 0.520422,
-3.96843 , 59.8718 , 0.629564,
-4.13859 , 59.8616 , 0.749557,
-4.30095 , 59.8519 , 0.879936,
-4.45489 , 59.8428 , 1.0202,
-4.59982 , 59.8345 , 1.16979,
-4.73521 , 59.8271 , 1.32813,
-4.86049 , 59.8209 , 1.49462//88
};
GLfloat lineVertices2[] =
{
-4.42182 , 99.9075 , 0.824627,//99
-4.31062 , 99.9111 , 0.721159,
-4.19317 , 99.9151 , 0.624857,
-4.06995 , 99.9194 , 0.536074,
-3.94142 , 99.9239 , 0.455173,
-3.80809 , 99.9286 , 0.382475,
-3.67047 , 99.9334 , 0.318266,
-3.5291 , 99.9382 , 0.262798,
-3.38454 , 99.9431 , 0.216293,
-3.23734 , 99.9478 , 0.178935,
-3.08809 , 99.9525 , 0.150869,
-2.93738 , 99.957 , 0.132209,
-2.78577 , 99.9613 , 0.123026,
-2.63388 , 99.9654 , 0.123359,
-2.4823 , 99.9693 , 0.133205,
-2.33163 , 99.973 , 0.152526,
-2.18246 , 99.9764 , 0.181248,
-2.03538 , 99.9797 , 0.219254,
-1.89097 , 99.9827 , 0.266397,
-1.74978 , 99.9855 , 0.322491,
-1.61238 , 99.9882 , 0.387315,
-1.47931 , 99.9907 , 0.460617,
-1.35108 , 99.9932 , 0.542106,
-1.22821 , 99.9956 , 0.631463,
-1.11118 , 99.998 , 0.728338,
-1.00044 , 100 , 0.832349,
-0.896426 , 100.003 , 0.943089,
-0.799553 , 100.006 , 1.06012,
-0.710198 , 100.008 , 1.18299,
-0.628712 , 100.011 , 1.3112,
-0.555414 , 100.015 , 1.44426,
-0.490593 , 100.018 , 1.58164,
-0.4345 , 100.022 , 1.7228,
-0.387355 , 100.026 , 1.86719,
-0.349345 , 100.031 , 2.01423,
-0.320616 , 100.036 , 2.16336,
-0.301283 , 100.041 , 2.31398,
-0.29142 , 100.047 , 2.4655,
-0.291068 , 100.053 , 2.61733,
-0.30023 , 100.059 , 2.76887,
-0.318871 , 100.065 , 2.91953,
-0.346923 , 100.072 , 3.06872,
-0.384278 , 100.079 , 3.21584,
-0.430792 , 100.086 , 3.36031,
-0.486289 , 100.093 , 3.50158,
-0.550557 , 100.101 , 3.63908,
-0.623346 , 100.108 , 3.77227,
-0.704365 , 100.115 , 3.90063,
-0.793325 , 100.121 , 4.02362//10
};
GLfloat lineVertices3[] =
{
-2.46627 , 140.043 , 3.13066,
-2.37507 , 140.042 , 3.07554,
-2.28758 , 140.041 , 3.0147,
-2.20413 , 140.04 , 2.94842,
-2.12509 , 140.038 , 2.87696,
-2.05076 , 140.037 , 2.80061,
-1.98146 , 140.035 , 2.71968,
-1.91745 , 140.033 , 2.6345,
-1.85901 , 140.03 , 2.54541,
-1.80637 , 140.028 , 2.45278,
-1.75974 , 140.026 , 2.35698,
-1.71932 , 140.023 , 2.25841,
-1.68526 , 140.021 , 2.15746,
-1.65771 , 140.018 , 2.05454,
-1.63678 , 140.016 , 1.95008,
-1.62254 , 140.013 , 1.84449,
-1.61507 , 140.011 , 1.73821,
-1.61438 , 140.008 , 1.63167,
-1.62049 , 140.006 , 1.5253,
-1.63336 , 140.004 , 1.41953,
-1.65295 , 140.002 , 1.3148,
-1.67917 , 140 ,1.21153,
-1.71191 , 139.998 , 1.11013,
-1.75105 , 139.996 , 1.01103,
-1.79642 , 139.994 , 0.914618,
-1.84785 , 139.992 , 0.821293,
-1.90511 , 139.991 , 0.731432,
-1.96799 , 139.989 , 0.645401,
-2.03621 , 139.987 , 0.56355,
-2.10951 , 139.986 , 0.486212,
-2.18759 , 139.984 , 0.413699,
-2.27013 , 139.982 , 0.346308,
-2.3568 , 139.981 , 0.284313,
-2.44723 , 139.979 , 0.227965,
-2.54108 , 139.977 , 0.177493,
-2.63794 , 139.975 , 0.133103,
-2.73744 , 139.973 , 0.0949755,
-2.83916 , 139.971 , 0.063265,
-2.94269 , 139.969 , 0.0381,
-3.04762 , 139.967 , 0.0195844,
-3.15351 , 139.964 , 0.0077915,
-3.25993 , 139.962 , 0.00277062,
-3.36646 , 139.96 , 0.004542,
-3.47265 , 139.957 , 0.0130972,
-3.57808 , 139.954 , 0.028403,
-3.68232 , 139.952 , 0.0503979,
-3.78495 , 139.949 , 0.0789915,
-3.88555 , 139.946 , 0.114059,
-3.9837 , 139.943 , 0.15548
};
// Loop until the user closes the window
while (!glfwWindowShouldClose(window))
{
glClear(GL_COLOR_BUFFER_BIT);
glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
//glColor3f(0.0f, 1.0f, 0.0f);
glNormal3f(1.0, 1.0, 1.0);
glPushMatrix();
glTranslatef(500, 0, 0);
glRotatef(rotationX, 1, 0, 0);
glRotatef(rotationY, 0, 1, 0);
glRotatef(rotationZ, 0, 0, 1);
glScaled(10.0f, 10.0f, 10.0f);
glPointSize(50);
glFrontFace(GL_CW);
glPointSize(5);
glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer(3, GL_FLOAT, 0, lineVertices);
glDrawArrays(GL_LINE_STRIP, 0, 49);
glDisableClientState(GL_VERTEX_ARRAY);
glPointSize(5);
glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer(3, GL_FLOAT, 0, lineVertices2);
glDrawArrays(GL_LINE_STRIP, 0, 49);
glDisableClientState(GL_VERTEX_ARRAY);
glPointSize(5);
glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer(3, GL_FLOAT, 0, lineVertices3);
glDrawArrays(GL_LINE_STRIP, 0, 49);
glDisableClientState(GL_VERTEX_ARRAY);
glPopMatrix();
// Swap front and back buffers
glfwSwapBuffers(window);
// Poll for and process events
glfwPollEvents();
}
glfwTerminate();
return 0;
}
void keyCallback(GLFWwindow* window, int key, int scancode, int action, int mods)
{
std::cout << key << std::endl;
const GLfloat rotationSpeed = 10;
// actions are GLFW_PRESS, GLFW_RELEASE or GLFW_REPEAT
if (action == GLFW_PRESS || action == GLFW_REPEAT)
{
switch (key)
{
case GLFW_KEY_UP:
rotationX -= rotationSpeed;
break;
case GLFW_KEY_DOWN:
rotationX += rotationSpeed;
break;
case GLFW_KEY_RIGHT:
rotationY += rotationSpeed;
break;
case GLFW_KEY_LEFT:
rotationY -= rotationSpeed;
break;
}
}
}
Thank you in advance.