Witam
Mam projekt w OpenGl. I Wyskakuję mi taki ciekawy błąd. Szukałem na Google ale za bardzo nie rozumiem.
Error 16 error LNK2019: unresolved external symbol __imp__GetCursorPos@4 referenced in function "void __cdecl display(void)" (?display@@YAXXZ) C:\Users\łukasz\Documents\Visual Studio 2012\Projects\ConsoleApplication1\ConsoleApplication1\main.obj ConsoleApplication1
Kod projektu wygląda mniej więcej tak.
#include <glut.h>
#include <stdio.h>
#include <stdlib.h>
#include <windows.h>
#include "tga.h"
#include <glm.h>
#include <WinUser.h>
#include <string.h>
#include <math.h>
#include <gl\GLU.h>
#include <gl\GL.h>
#define M_PI 3.14159265358979323846
#define ESC 27
#pragma comment(lib,"opengl32.lib")
#pragma comment(lib,"glaux.lib")
#pragma comment(lib,"glu32.lib")
#pragma comment(lib, "glut32.lib" )
// Protótipos de funçőes
void init(void);
void display(void);
void reshape(GLsizei w, GLsizei h);
void load_tga_image(void);
float x = 0.0, y = -5.0; // initially 5 units south of origin
float deltaMove = 0.0; // initially camera doesn't move
// Camera direction
float lx = 0.0, ly = 1.0; // camera points initially along y-axis
float angle = 0.0; // angle of rotation for the camera direction
float deltaAngle = 0.0;
float ydeltaAngle= 0.0; // additional angle change when dragging
// Mouse drag control
int isDragging = 0; // true when dragging
int xDragStart = 0; // records the x-coordinate when dragging starts
int yDragStart = 0;
// Variáveis globais
tgaInfo *im;
tgaInfo *mar;
GLuint texture[10];
GLUquadric *mysolid;
GLUquadric *mars;
GLfloat spin = 0.05;
//void update(void)
//{
// if (deltaMove) { // update camera position
// x += deltaMove * lx * 0.1;
// y += deltaMove * ly * 0.1;
// }
// glutPostRedisplay(); // redisplay everything
//}
void init(void)
{
// Define técnica de shading: GL_FLAT, GL_SMOOTH
glShadeModel(GL_SMOOTH);
glEnable(GL_DEPTH_TEST);
}
int c,v;
float xrotation, yrotation;
float lo,yy;
void ArrowKeys(int key, int x, int y)
{
switch (key)
{
case GLUT_KEY_LEFT:
lo += 0.5f;
break;
case GLUT_KEY_RIGHT:
lo -= 0.5f;
break;
case GLUT_KEY_UP:
xrotation-= 0.5f;
break;
case GLUT_KEY_DOWN:
xrotation+= 0.5f;
break;
case GLUT_KEY_PAGE_UP:
yrotation+= 0.1f;
break;
case GLUT_KEY_PAGE_DOWN:
yrotation-=0.1f;
default:
break;
}
glutPostRedisplay();
}
void draworbits(float x, float y, float z, GLint radius)
{
glBegin(GL_LINE_LOOP);
for(float i=0;i<(3.14*2);i+=3.14/180)
{
x=sin(i)*radius;
z=cos(i)*radius;
glVertex3f(x,0,z);
}
glEnd();
}
int xxmouse, yymouse;
void mouseMove(int x, int y)
{
//if (isDragging) { // only when dragging
// // update the change in angle
// deltaAngle = (x - xDragStart) * 0.005;
//
// // camera's direction is set to angle + deltaAngle
// lx = -sin(angle + deltaAngle);
//}
// char zzz [5];
xxmouse = x;
yymouse = y;
//itoa(yrotation, zzaz, 10);
// drawText(zzz, 12, 50,0);
}
void drawText(const char * text, int length, int x, int y)
{
glMatrixMode(GL_PROJECTION);
double *matrix = new double[16];
glGetDoublev(GL_PROJECTION_MATRIX, matrix );
glLoadIdentity();
glOrtho(0,800,0,600, -5,5);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glPushMatrix();
glLoadIdentity();
glRasterPos2i(x,y);
for (int i =0; i<length; i++)
{
glutBitmapCharacter(GLUT_BITMAP_9_BY_15, int(text[i]));
}
glPopMatrix();
glMatrixMode(GL_PROJECTION);
glLoadMatrixd(matrix);
glMatrixMode(GL_MODELVIEW);
POINT lpPoint;
//GetCursorPos(&lpPoint);
// lo = lpPoint.x;
// yy = lpPoint.y;
gluLookAt(xrotation, yrotation, lo,
-100, 0.0 , 0,
0, 1, 0);
}
void display(void)
{
float d2r;
static float theta = 0.0f, thetar, phi =0.0f, phir = 0.0;
d2r = 3.14159265/180;
thetar = theta *d2r;
phir = phi * d2r;
int mxold,myold;
int x1,y1;
//glClearColor(1.0, 1.0, 1.0, 1.0);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
//widok kamera
//int lo,yy;
//lo=15;
/*POINT lpPoint;
GetCursorPos(&lpPoint);
lo = lpPoint.x;
yy = lpPoint.y;
*/
/*gluLookAt(0, 0, lo,
xrotation, 2 , 0,
0, -1,-10);*/
glEnable(GL_TEXTURE_2D);
char xxx [5];
char yyy [5];
char zzz [5];
char xmouse [5];
char ymouse [5];
itoa(xrotation, xxx, 10);
itoa(lo, yyy,10);
itoa(yrotation, zzz, 10);
drawText(xxx, 12, 0 ,0);
drawText(yyy,12, 25,0);
drawText(zzz, 12, 50,0);
itoa(xxmouse, xmouse, 10);
itoa(yymouse, ymouse,10);
drawText(xmouse, 12, 100 ,0);
drawText(ymouse,12, 125,0);
// sprintf(c,"FPS: %4.2f");
glColor3f( 255, 255, 255);
glRasterPos2f(10, 10);
// glutBitmapCharacter("dasd");
glRasterPos3f(10, 10, 0.0);
// glutBitmapCharacter(GLUT_BITMAP_HELVETICA_18, lo);
glColor4f(1.0, 1.0, 1.0, 1.0);
// Select texture
glBindTexture(GL_TEXTURE_2D, texture[0]);
glPushMatrix();
glRotatef(90, 1.0, 0.0, 0.0);
glRotatef(spin, 0.0, 1.0, 0.0);
gluSphere(mysolid, 1, 100, 100);
glPopMatrix();
//glEnd ();
glBindTexture(GL_TEXTURE_2D, texture[1]);
//glBegin(GL_QUADS);
glPushMatrix();
draworbits(0,0,0, 5);
glTranslatef(5*sin(thetar) ,0.0f, 5* cos(thetar));
static POINT screenPoint;
static char posX[10];
static char posY[10];
GetCursorPos(&screenPoint);
printf(posX, "%d", screenPoint.x);
printf(posY, "%d", screenPoint.y);
//glTranslated(float(5.0f) * cos(2 * 3.14 * spin / 360), 0, 0);
//glRotatef(spin, spin , 0.0, spin );
//glRotatef(spin, 0.0 , 1.0, 0.0 );
gluSphere(mars, 0.2, 50, 50);
theta+=0.4;
//glPopMatrix();
//glEnd ();
// Planet Orbit
spin = spin + 0.5;
if(spin > 360.0) spin = spin - 360.0;
glDisable(GL_TEXTURE_2D);
glutSwapBuffers();
glFlush();
}
void pressSpecialKey(int key, int xx, int yy)
{
switch (key) {
case GLUT_KEY_UP : deltaMove = 1.0; break;
case GLUT_KEY_DOWN : deltaMove = -1.0; break;
}
}
//void releaseSpecialKey(int key, int x, int y)
//{
// switch (key) {
// case GLUT_KEY_UP : deltaMove = 0.0; break;
// case GLUT_KEY_DOWN : deltaMove = 0.0; break;
// }
//}
void mouseButton(int button, int state, int x, int y)
{
if (button == GLUT_LEFT_BUTTON) {
if (state == GLUT_DOWN) { // left mouse button pressed
isDragging = 1; // start dragging
xDragStart = x; // save x where button first pressed
}
else { /* (state = GLUT_UP) */
angle += deltaAngle; // update camera turning angle
isDragging = 0; // no longer dragging
}
}
}
void processNormalKeys(unsigned char key, int xx, int yy)
{
if (key == ESC || key == 'q' || key == 'Q') exit(0);
}
void reshape(GLsizei w, GLsizei h)
{
glViewport(0, 0, w, h);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(60.0, (GLfloat) w / (GLfloat) h, 0.5, 200.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glTranslatef(0.0, 0.0, -5.0);
}
void load_tga_image(void)
{
char impathfile[255] = "earth.tga";
char marsik[255] = "mars.tga";
im = tgaLoad(impathfile);
mar = tgaLoad(marsik);
printf("IMAGE INFO: %s\nstatus: %d\ntype: %d\npixelDepth: %d\nsize%d x %d\n", impathfile, im->status, im->type, im->pixelDepth, im->width, im->height);
// printf(x
// allocate one texture name
glGenTextures(2, texture);
// select our current texture
glBindTexture(GL_TEXTURE_2D, texture[0]);
mysolid = gluNewQuadric();
gluQuadricDrawStyle(mysolid, GLU_FILL);
gluQuadricTexture(mysolid, GL_TRUE);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, im->width, im->height, 0, GL_RGB, GL_UNSIGNED_BYTE, im->imageData);
tgaDestroy(im);
glBindTexture(GL_TEXTURE_2D, texture[1]);
mars = gluNewQuadric();
gluQuadricDrawStyle(mars, GLU_FILL);
gluQuadricTexture(mars, GL_TRUE);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, mar->width, mar->height, 0, GL_RGB, GL_UNSIGNED_BYTE, mar->imageData);
tgaDestroy(mar);
// // set up quadric object and turn on FILL draw style for it
glEnable(GL_TEXTURE_2D);
}
int main(int argc, char** argv)
{
int width, height;
// Inicializaçăo do GLUT
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_DEPTH | GLUT_RGBA);
width = glutGet(GLUT_SCREEN_WIDTH);
height = glutGet(GLUT_SCREEN_HEIGHT);
//glutGameModeString( "1024×768:32@75" );
//glutEnterGameMode();
// Cria a janela de visualizaçăo
glutInitWindowPosition(0, 0);
// glutInitWindowSize(width-14, height-76);
// glutFullScreen();
glutCreateWindow("Projekt");
// Inicializaçőes
init();
load_tga_image();
// Registar funçőes de callback
glutDisplayFunc(display);
//glutIdleFunc(update);
glutReshapeFunc(reshape);
glutFullScreen();
glutIdleFunc(display);
glutMotionFunc(mouseMove);
glutMouseFunc(mouseButton); // process mouse button push/release
// process mouse dragging motion
//glutKeyboardFunc(ArrowKeys);
// process standard key clicks
lo=10;
xrotation = 10;
yrotation = 10;
glutKeyboardFunc(processNormalKeys);
glutSpecialFunc(ArrowKeys); // process special key pressed
// Warning: Nonstandard function! Delete if desired.
//glutSpecialUpFunc(releaseSpecialKey);
glEnable(GL_DEPTH_TEST);
// Ciclo infinito do GLUT
glutMainLoop();
return 0;
}
A tutaj obraz jak wyglądają headery itd..
- Untitled.jpg (28 KB) - ściągnięć: 162