6 Replies - 8949 Views - Last Post: 09 February 2005 - 03:03 PM Rate Topic: -----

#1 Ti22  Icon User is offline

  • New D.I.C Head

Reputation: -1
  • View blog
  • Posts: 10
  • Joined: 11-January 05

Opengl In Oop With C++

Posted 11 January 2005 - 03:00 PM

HI,

for the past days I've been trying to draw a cube with object oriented openGL with C++

I am about to smack my head against the wall..

I've tried to do everything I can, and I am so confused,

see the attachment to see what i've come up with

What I want to get working is the ability to create the cube with this command

(in the main.cpp)
under the

int draw_scene(GLvoid)

room cube;
cube.set_rgb(set my color property)
cube.set_rotate(my rotation properties)
cube.set_translate(set my translation (ie location of cube))
cube.set_scale(set the size of my cube)
cube.draw();

and then I want it to draw the cube, I think i've done the Set functions and Get Functions correctly with all the properties and etc..

now How do I get OpenGL to draw my cube.

Please help me, I am very new to C++ (in fact I just leanred OO Programming about 2-3 days ago).

I have done alot of OpenGL programming with C in structured form but I now I need to get OpenGL with OO working.

The code compiles but I didn't put in any openGL drawing code in there becasue I don't know where or how to.

Thank you

Attached File(s)


This post has been edited by Ti22: 11 January 2005 - 03:08 PM


Is This A Good Question/Topic? 0
  • +

Replies To: Opengl In Oop With C++

#2 Videege  Icon User is offline

  • rÍvant.toujours
  • member icon

Reputation: 6
  • View blog
  • Posts: 1,413
  • Joined: 25-March 03

Re: Opengl In Oop With C++

Posted 11 January 2005 - 05:48 PM

Your code is set up fine. Object Oriented with OGL really isn't that much different in technique than procedural programming (though OOP is much more organized, and, imo, much more powerful). You want to call your draw code under your draw_scene function in main. Something like this:

int draw_scene(GLvoid) 	 //This function is where all the drawing is done!
{
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 	 //Clear sceen and depth buffer.
	glLoadIdentity(); 	 //Reset current model view matrix.

	//draw code here, like, square.Drawsquare(2.0f, 1.0f, 4.0f);
        //essentially you can put in straight OGL calls or use your classes and functions (much more organized).

	return true;    //If everything went ok it will return true :D     	 
}


Was This Post Helpful? 0
  • +
  • -

#3 Ti22  Icon User is offline

  • New D.I.C Head

Reputation: -1
  • View blog
  • Posts: 10
  • Joined: 11-January 05

Re: Opengl In Oop With C++

Posted 12 January 2005 - 08:04 AM

OK I got it to work, I had to change alot of the code in the room.h and room.cpp

it works now :D like i want it to

thx for the help :D
Was This Post Helpful? 0
  • +
  • -

#4 mad  Icon User is offline

  • New D.I.C Head
  • member icon

Reputation: 1
  • View blog
  • Posts: 41
  • Joined: 09-February 05

Re: Opengl In Oop With C++

Posted 09 February 2005 - 01:38 PM

i really need help about set_rotation. i'm from Turkey i think cause of that i can't download the livingroom.zip . please write the full code of set_rotation here i can't rotate my cube. thanx
-MaD-
Was This Post Helpful? 0
  • +
  • -

#5 skyhawk133  Icon User is offline

  • Head DIC Head
  • member icon

Reputation: 1877
  • View blog
  • Posts: 20,284
  • Joined: 17-March 01

Re: Opengl In Oop With C++

Posted 09 February 2005 - 02:33 PM

Make sure you save the .zip file to your computer first then open it, opening it directly won't work.
Was This Post Helpful? 0
  • +
  • -

#6 mad  Icon User is offline

  • New D.I.C Head
  • member icon

Reputation: 1
  • View blog
  • Posts: 41
  • Joined: 09-February 05

Re: Opengl In Oop With C++

Posted 09 February 2005 - 03:01 PM

no the problem is it downloads a 0 "zero" kb file. i am gonna mad i searched a whole day for it and i found it but i can't reach it. Man that feels suck on me.
Was This Post Helpful? 0
  • +
  • -

#7 skyhawk133  Icon User is offline

  • Head DIC Head
  • member icon

Reputation: 1877
  • View blog
  • Posts: 20,284
  • Joined: 17-March 01

Re: Opengl In Oop With C++

Posted 09 February 2005 - 03:03 PM

Hmmm, I'm not sure what to tell you, I just downloaded it and was able to open it.... there are atleast 10 files in the zip so there is really no way to just post all the code. Maybe the original poster can dig out what you need.

Sorry :(
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1