Sign in to follow this  
nightangel

Problem in tutorial 1

Recommended Posts

nightangel    122
When i was download the NeHe Production tutorial 1 and try to compile with my Microsoft Visual Studio 6, it come out 2 error message which are: --------------------Configuration: Lesson1 - Win32 Debug-------------------- Linking... libcd.lib(crt0.obj) : error LNK2001: unresolved external symbol _main Debug/Lesson1.exe : fatal error LNK1120: 1 unresolved externals Error executing link.exe. Lesson1.exe - 2 error(s), 0 warning(s) Can anyone solve for me? pls help...

Share this post


Link to post
Share on other sites
lc_overlord    436
You compiled it as a win32console, console apps use the main() as a start point.
What you need to do is to compile it as a win32application, it uses winmain() as a entry point, which is what lesson 1 use.

Share this post


Link to post
Share on other sites
nightangel    122
Oh great!! It solve my problem, now i can compile and run the program.

But another problem come out with Microsoft Visual Studio 8, which is the new version of visual studio 2005.

I open project with "Win32 Project" which is not project of Console Win32, and when compiling the tutorial 1, it come out many errors which are something like:

---------------------------------------------------------------------------------------------------------------------------------------
1. error C2664: 'MessageBoxW' : cannot convert parameter 2 from 'const char [29]' to 'LPCWSTR'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast

2. error C2664: 'UnregisterClassW' : cannot convert parameter 1 from 'const char [7]' to 'LPCWSTR'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast

3. error C2440: '=' : cannot convert from 'const char [7]' to 'LPCWSTR'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast

4. error C2664: 'CreateWindowExW' : cannot convert parameter 2 from 'const char [7]' to 'LPCWSTR'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast

---------------------------------------------------------------------------------------------------------------------------------------

##in the tutorial 1 actual code is MessageBox, but is it the complier itself took it as MessageBoxW??? Take 1 example in the coding:

##MessageBox(NULL,"Release Of DC And RC Failed.","SHUTDOWN ERROR",MB_OK | MB_ICONINFORMATION);##

the debugger error on the ("Release Of DC And RC Failed.","SHUTDOWN ERROR") for cannot converting parameter 2 from const char to LPCWSTR... can any1 help??

Share this post


Link to post
Share on other sites
modolove    122
I think language is just a tool,so you needn't change your tool frequent.The tool can finish your work best is the enough.(I am China So My English is poor,^_^)

Share this post


Link to post
Share on other sites
nightangel    122
Thanks Darren, i have solve the VS 2005 problem ad, thanks for all ur helping, now i can start learn all those tutorial...

Still...have any1 expert in OpenGL? i need urs expertise information. i was doing a project is about using OpenGL to develop a building block, i know it is very hard, but is that possible for a newbie done in 4~5 months? is that enough time for complete the project? the bulding block scope quite big....is about a College Academic block...

hear u soon, thanks

Share this post


Link to post
Share on other sites
eSCHEn    394
No problems Kevin, we all have to start somewhere [smile].

Well I'm definately not an expert in OpenGL but I'll offer you some advice on your project. Learning OpenGL to develop a set of buildings is certainly possible within the timeframe you mentioned but it really is dependent on how experienced you are with C++ (I assume that this the language you have chosen) and how fast a learner you are. You have two options when it comes to modelling your buildings, you can either specify how the buildings are made using pure code (very timeconsuming) or you are going to want to learn how to create models in a modelling package and then import them into an application which then displays them.

The slightly more difficult way will be to model the buildings in a modelling package such as Blender or Milkshape3D (these are just examples, there are loads to choose from) and then import these models into your application. It will be more difficult to write an importer for your models but the time you will save by being able to create buildings, trees and other stuff inside a package which was designed for that purpose can not be over-stressed.

If you want textures on your buildings and other models then you're going to need to write a texture loader or use a pre-built one such as DevIL to do some of the work for you.

In conclusion, if you're a confident coder and put a lot of energy and time into your project then sure, I think it would be possible to do it in 4-5 months.

I wish you the best of luck and if you have problems then have a look at the NeHe tutorials and articles, check Google and definately post back here for help and advice. Speak to you later [smile].

Share this post


Link to post
Share on other sites
nightangel    122
Thanks for ur advice Darren.

But 1 thing that from my project, it only can use pure code to develop my project, becuase i'm having my software engineering degree, so i think i cannot have another choice (application sofware etc) except using coding...

From the C++ language, seriously i never learn before but, i had learn C before, so the coding for the C++ is still understandable for me.

I will try all my best, and any problem i will post in this forum, i really need all ur helps...and again, thx a million!;)

Share this post


Link to post
Share on other sites
nightangel    122
O yea Darren, do u have any website or references on how to code an bulding block for OpenGL? and 1 thing im might considering, as u say use pure code will very time-consuming, so how about i use the texture mapping techniques to build it? is that more easier? and any suggestion that i can learn more faster in OpenGL? (within my scope) becoz it i learn the Nehe tutorial lesson i dun think that is enough information for me...and Thanks again~~~ :)

Share this post


Link to post
Share on other sites
eSCHEn    394
Well when I said to use code, I meant that you would be using texture maps, otherwise you'll never finish the project [wink]. Essentially what you would do is see if you can get an aerial shot of your campus or a blueprint/landscape layout diagram would be even better. From your drawings you can then plan where you are going to put your buldings and if you have height data then you can decide how tall they are going to be. If you don't have any of this data then it's more difficult but a good guess can look just as convincing as real data in terms of sizing.

Once you have your rough size data then you would create cuboids (blocks) to make up the buldings, I'm not sure what average buildings look like in Malaysia so I'm going to use an example of a typical house from here in Scotland (very boxy). First you would use some vertices to define the shape of the box, for example:
glBegin(GL_QUADS);
// front face
glVertex3f(-10.0f, -10.0f, 10.0f);
glVertex3f( 10.0f, -10.0f, 10.0f);
glVertex3f( 10.0f, 10.0f, 10.0f);
glVertex3f(-10.0f, 10.0f, 10.0f);
// left face
glVertex3f(-10.0f, -10.0f, -10.0f);
glVertex3f(-10.0f, -10.0f, 10.0f);
glVertex3f(-10.0f, 10.0f, 10.0f);
glVertex3f(-10.0f, 10.0f, -10.0f);
// right face
glVertex3f( 10.0f, -10.0f, 10.0f);
glVertex3f( 10.0f, -10.0f, -10.0f);
glVertex3f( 10.0f, 10.0f, -10.0f);
glVertex3f( 10.0f, 10.0f, 10.0f);
// back face
glVertex3f( 10.0f, -10.0f, -10.0f);
glVertex3f(-10.0f, -10.0f, -10.0f);
glVertex3f(-10.0f, 10.0f, -10.0f);
glVertex3f( 10.0f, 10.0f, -10.0f);
// top face
glVertex3f(-10.0f, 10.0f, 10.0f);
glVertex3f( 10.0f, 10.0f, 10.0f);
glVertex3f( 10.0f, 10.0f, -10.0f);
glVertex3f(-10.0f, 10.0f, -10.0f);
// bottom face
glVertex3f( 10.0f, -10.0f, 10.0f);
glVertex3f( 10.0f, -10.0f, -10.0f);
glVertex3f(-10.0f, -10.0f, -10.0f);
glVertex3f(-10.0f, -10.0f, 10.0f);
glEnd();



Now this will define you a box that looks something like this (I've overlayed triangles so don't worry about that):
A picture of an untextured cube

Now that you have your box you would then go and take some pictures of the building it represents from the sides and so on, trying to get as 'face on' (square to) as you can. Now it's snowing and miserable outside my house at the moment so I've drawn a picture of the front of a house instead of taking a picture, excuse my poor artistic skills:
A picture of the front of a house (badly drawn)

Now you need to apply this image to your box for your building. To do this you use texture co-ordinates, I explained them to someone else earlier so I will just point you towards the thread for that information, clicky. So let's put the texture on the front face only, just to demonstrate the effect:
glBegin(GL_QUADS);
// enable texturing so that we can see our texture
glEnable(GL_TEXTURE_2D);
// now bind the texture id (I assume you know how to do this from your other thread)
glBindTexture(GL_TEXTURE_2D, an_example_id_for_your_texture);
// front face
glTexCoord2f(0.0f, 0.0f);
glVertex3f(-10.0f, -10.0f, 10.0f);
glTexCoord2f(1.0f, 0.0f);
glVertex3f( 10.0f, -10.0f, 10.0f);
glTexCoord2f(1.0f, 1.0f);
glVertex3f( 10.0f, 10.0f, 10.0f);
glTexCoord2f(0.0f, 1.0f);
glVertex3f(-10.0f, 10.0f, 10.0f);
// now we disable texturing as we only have the front face's texture so far
glDisable(GL_TEXTURE_2D);

// rest of code the same
glEnd();



The building now looks like this:
A picture of a cube with the front face textured

As you can see, all this takes a long time, and this is just for one building! If you have a lot of buildings to do, especially if they're not rectangular in shape as well, then it's going to take you a very long time indeed. Also, if you want lights in your scene then you will need to specify normals for each point as well.

I hope this helps to clarify what I was talking about.

Share this post


Link to post
Share on other sites
nightangel    122
[wow] this is what i want to do for my project, u did really helps me a lot, to build up my ideas and conceptual of the development of building blocks, hehe sure rate for u!!

From my friend of engineering student, they have drawing the map of my campus, so i can get from them, that will be more time saving for me... Thanks Darren

Share this post


Link to post
Share on other sites
Stinkbeard888    122
As an alternative, you could cast your string to a LPCWSTR.

Let's say you've got c_str myString.

The function

open(myString);

gives you a compile error. Instead use

open((LPCWSTR)myString);

A superfluous post? Perhaps. But this will work if you don't want to or can't change your settings.

Share this post


Link to post
Share on other sites
nefthy    184
A little advise from me too. If you are confident with plain C, use C instead of C++. It will save you some time. Unless you _have_ to use C++, that is.

Also about using Models from an external program, I don't think that this would be a problem, since displaying models is a bit more complicated, from a software engineering point of view, compared to drawing some textured quads. But check with your teachers to be sure.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this