PDA

View Full Version : setting up a project



nick2price
11-15-2008, 10:22 AM
I am using visual C++ with open gl for my applications. I am just a bit confused as to the proper way to set up a project.
So i start by creating a new project, console32 application as i was told by tutor. And then i have a project folder created. This is ok and works fine when i do programs with just one class. What i dont understand is the way to add like .h files to my project or other .c classes.
I normally just go to new-file and then choose the file type, but then say if i create a new .h file, and then add #include "new.h" to my main c++ file, i always get returned the error: skipped looking for new.h .......
So my question is, what is the proper way to add .c and .h files to my project. And secondly, can anyone just briefly explain to me what exactly a .h file is?
cheers

trinitrotoluene
11-15-2008, 10:48 AM
Look at the video on this web page (http://msdn.microsoft.com/en-us/beginner/bb964629.aspx). The first 10 minutes can be boring but after the introduction, the information you want are there.

nick2price
11-15-2008, 11:09 AM
I actually figured out a way, but i will watch the video aswell. Can you just quickly help me with somthing.
I am trying to put a texture on a cube. I have a texture c++ file and a texture .h file which works because i have used it in somthing else. And then i created my own class like so

#include "stdafx.h"
#include <GL\glut.h>
#include <GL\glaux.h> //Used for loading the textures
#include <windows.h>
#include "textures.h"

COGLTexture Tex1, Tex2;

void InitTextures(void)
{
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);

glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_NEAREST);

Tex1.LoadFromFile("tex1.bmp");
Tex2.LoadFromFile("tex2.bmp");

glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);

}

void DrawCube(void)
{
//Draws a cube with two shaded, two one-colored and two textured faces
glBegin(GL_QUADS);
glColor3f(1.0,0.0,0.0);
//front:
glVertex3f(-0.5,-0.5,0.5);
glVertex3f(-0.5,0.5,0.5);
glVertex3f(0.5,0.5,0.5);
glVertex3f(0.5,-0.5,0.5);

//back:
glColor3f(0.0,0.0,1.0);
glVertex3f(-0.5,-0.5,-0.5);
glVertex3f(0.5,-0.5,-0.5);
glVertex3f(0.5,0.5,-0.5);
glVertex3f(-0.5,0.5,-0.5);

//top:
glColor3f(0.0,0.6,1.0);
glVertex3f(-0.5,0.5,-0.5);
glVertex3f(0.5,0.5,-0.5 );
glColor3f(1.0,0.6,1.0);
glVertex3f(0.5,0.5,0.5);
glVertex3f(-0.5,0.5,0.5);

//bottom:
glColor3f(0.0,0.6,0.0);
glVertex3f(-0.5,-0.5,-0.5);
glColor3f(0.6,0.6,0.6);
glVertex3f(-0.5,-0.5,0.5);
glColor3f(1.0,1.0,0.3);
glVertex3f(0.5,-0.5,0.5);
glColor3f(0.0,1.0,0.0);
glVertex3f(0.5,-0.5,-0.5);
glEnd();
glEnable(GL_TEXTURE_2D);

Tex1.SetActive();
glBegin(GL_QUADS);
//left:
glTexCoord2f(1.0,0.0);
glVertex3f(-0.5,-0.5,-0.5);
glTexCoord2f(1.0,1.0);
glVertex3f(-0.5,0.5,-0.5);
glTexCoord2f(0.0,1.0);
glVertex3f(-0.5,0.5,0.5);
glTexCoord2f(0.0,0.0);
glVertex3f(-0.5,-0.5,0.5);
glEnd();
//right:
Tex2.SetActive();
glBegin(GL_QUADS);
glTexCoord2f(0.0,0.0);
glVertex3f(0.5,-0.5,-0.5);
glTexCoord2f(1.0,0.0);
glVertex3f(0.5,-0.5,0.5);
glTexCoord2f(1.0,1.0);
glVertex3f(0.5,0.5,0.5);
glTexCoord2f(0.0,1.0);
glVertex3f(0.5,0.5,-0.5);
glEnd();
glDisable(GL_TEXTURE_2D);


}

void reshape(int x, int y)
{
if (y == 0 || x == 0) return;

glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(40.0,(GLdouble)x/(GLdouble)y,0.5,20.0);

glMatrixMode(GL_MODELVIEW);
glViewport(0,0,x,y);
}

void Display(void)
{
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
DrawCube();
glFlush();
glutSwapBuffers();

}

int main(int argc, char **argv)
{
glutInit(&amp;argc, argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
glutInitWindowSize(300,300);
glutCreateWindow("Coursework2");
glFrontFace(GL_CW); //Clockwise is front in "DrawCube()"
glCullFace(GL_BACK);
glEnable(GL_CULL_FACE);
glEnable(GL_DEPTH_TEST);
InitTextures();
glutDisplayFunc(Display);
glutReshapeFunc(reshape);
glutMainLoop();
return 0;
}

When i compile it, i am being returned the error

1>------ Build started: Project: coursework2, Configuration: Debug Win32 ------
1>Compiling...
1>coursework2.cpp
1>Linking...
1>textures.obj : error LNK2019: unresolved external symbol _auxDIBImageLoadA@4 referenced in function "public: void __thiscall COGLTexture::LoadFromFile(char *)" (?LoadFromFile@COGLTexture@@QAEXPAD@Z)
1>C:\Users\Nick\Desktop\University\Graphics, C++\coursework2\Debug\coursework2.exe : fatal error LNK1120: 1 unresolved externals
1>Build log was saved at "file://c:\Users\Nick\Desktop\University\Graphics, C++\coursework2\coursework2\Debug\BuildLog.htm"
1>coursework2 - 2 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

but when i double click on it, it doesnt point me to any line. Do you know why i would be recieving this error?

trinitrotoluene
11-15-2008, 11:37 AM
I think, but I am not sure for this one, that COGLTexture object require a library provided by glaux. Search if you can find a library (not the include file) with the name glaux (glaux.lib maybe) on your system and add it where you have added the glut library.

Edit: after searching, it seem that you forget to add the glaux.lib in your project. Look at this (http://www.experts-exchange.com/Programming/Languages/CPP/Q_20278170.html) at the bottom of the page.

nick2price
11-15-2008, 12:01 PM
Now i really am confused. Apparantly, the glaux lib has been depreciated. So how would i now put a texture onto my cube?

trinitrotoluene
11-15-2008, 12:15 PM
Read this article (http://www.gamedev.net/reference/articles/article1966.asp).That may help you.

Jittar
12-17-2010, 01:27 PM
HI gays!

i m using the same texture mapping code and i also receiving the same error:: error LNK2019

plzz. help me........

MaxH
12-17-2010, 06:34 PM
I have a demo that loads .bmp files and displays them as images with glDrawPixels or as textures. The demo contains the code that loads the images, so glaux is not needed. It's at -

http://www.mfwweb.com/OpenGL/Loading_Textures/

Have fun. Let me know if it was helpful.