![]() |
|
#1
|
|||
|
|||
Newbie OpenGL Programmer!Hi Guys!! This is my first post on the forum. I'm trying to learn how to program in open gl. I recently bought a book on open gl game programming and am having trouble with one of the exercises. I'm not sure if it is ok to post the source code on here, but here goes.
CPP / C++ / C Code:
This code creates a triangle and polygon. The exercise wants you to modify the triangle to be all red and the polygon to be all blue. This seems simple, I tried modifying the values in the glColor3f function. For the triangle I have CPP / C++ / C Code:
CPP / C++ / C Code:
When I modify these values in Visual C++, they don't have any effect on the triangle or polygon. I'm a struggling programmer that needs help!! Last edited by LuciWiz : 22-Aug-2005 at 23:53.
Reason: Please insert your C++ code between [c++] & [/c++] tags
|
|
#2
|
|||
|
|||
|
Hello, i love opengl.
I copied just your draw triangle and polygon (the bits that start, glBegin() and end glEnd()), parts into my prog and the two versions you got do have different effects. The first ones create gradual colors and your new ones do create a total color, though on the blue quad one of the glcolor3f is black (0 0 0). However if you want to color something all the same color just call glColor3f once at the start and opengl will subsequently draw everything in that color till it comes across another glColor function. Try CPP / C++ / C Code:
Changing the color values is having an effect in mine so you must be not compiling it right or summink? Last edited by LuciWiz : 31-Aug-2005 at 03:25.
Reason: Please insert your C++ code between [c++] & [/c++] tags
|
|
#3
|
|||
|
|||
|
Hi!! Thanks for the reply!!! I had no idea that if you call:
glColor3f(1.0, 0.0, 0.0); before the glbegin call that it would change the color to solid. I will definetly try that. I have another question. I got this code from cd from a book I just purchase. I just copied all the files from the cd and saved this into my VS C++ folder. Now when I change the values in my prog, I save it, it won't let me compile it. When you entered this code into your prog, did you create a new project and choose win32 project under templates? After this, did you just copy and paste my code into VS C++ and compile it? When I try to compile the whole big thing of code, i get build errors. If you wouldn't mind Pixienick, would it be too much of me to ask you to please go step by step on how you compiled this code would be great, Thanks!!! |
|
#4
|
|||
|
|||
|
I just copied yor drawing of poly and triangles into the draw function of one of my progs and they worked. If your having trouble creating new projects have you maybe not added the opengl libraries into the project settings (alt F7) link tab? I'm not going to rebuild all your code but if you send me your email to me, i'll send you a skeleton project of my own that will do the same job, can't say fairer than that!
|
|
#5
|
|||
|
|||
|
for some reason it wont let me shoot you a pm. maybe i need to have more posts? when i get enough i'll give you my email addy. Thanks again for the help!!
oh btw, do you have any recommendations on a great c++ book? I have a little programming experience, but I really feel like I need to learn a lot more. |
|
#6
|
|||
|
|||
|
There's loads of books about. I learnt a bit of c then started going through the tutorials at http://nehe.gamedev.net/, they got a real nice step by step guide taking you through all the opengl basics and some nice source code to play with. You'll be making games in no time!
|
|
#7
|
|||
|
|||
|
Quote:
i will definetly check that site out. im trying to get my posts up so i can pm you my email addy. |
|
#8
|
|||
|
|||
|
I pm'ed you my email address. Hope you got it. Thanks again!!
|
|
#9
|
|||
|
|||
use directX instead of OpenGLHi,
since u r at the begining level of OpenGL... my suggestion is why dont u go for the advanced version of OpenGL that is DirectX (Just clarify it with some other regrding this) Best Regards, Janakiraman |
|
#10
|
||||
|
||||
|
Quote:
DirectX is NOT a version of OpenGL, it is a competing standard. The difference is that while OpenGL is an open, cross-platform standard, DirectX is a locked in standard maintained by Microsoft. It only works on Windows as far as I know, but you can use certain emulators to fake it on various Operating Systems. D3D is very popular with the gaming crowd, but some cool games (like Quake) used OpenGL, and some others offered support for both of them. However OpenGL only deals with the graphics part involved in creating a game, while D3D offers support for sound too, and I guess that's why they (game developers) tend to use it... Anyway, don't use DirectX if you don't strictly program for the Windows platform. Also, if you aren't into games, maybe OpenGL would be a better way to go. If you are interested into further reading, I suggest you google "directx vs opengl" for some interesting articles. Best regards, Lucian __________________
Please read these Guidelines before posting on the forum "A person who never made a mistake never tried anything new." Einstein |
Recent GIDBlog
Toyota - 2008 July Promotion by Nihal
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| new programmer | wendy | C++ Forum | 4 | 13-Jan-2005 23:59 |
| hello all!! newbie to the GIDforums | usmsci | Sports Forum | 20 | 16-Dec-2004 07:40 |
| nVidia & OpenGL Problems in windows XP | marjasin | Computer Hardware Forum | 21 | 30-Aug-2004 00:57 |
| linked lists, newbie needs help | moltarim | C Programming Language | 4 | 06-May-2004 11:32 |
| C++ books for newbie | mak90thug | C++ Forum | 4 | 04-Feb-2004 14:58 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The