Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Simple Drawings
Index -> Programming, C++ -> C++ Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Drakonius




PostPosted: Tue Mar 29, 2005 4:38 pm   Post subject: Simple Drawings

Embarassed i feel dumb for asking this but my course on C++ does not cover simple drawing functions....is the way how C++ drawings work very much different from java? if not can somebody post some of those functions for me.... like draw dots, draw lines, and draw rectangles....i tried reading through the topic headings but i couldn't find it, might be just me tho... Embarassed
Sponsor
Sponsor
Sponsor
sponsor
rizzix




PostPosted: Tue Mar 29, 2005 4:42 pm   Post subject: (No subject)

there;s no standard way. you'd need some sort of library.
The_$hit




PostPosted: Tue Apr 05, 2005 4:23 pm   Post subject: (No subject)

What is an appropriate library? Where can you get it? and what are some functions?
If any one could answer these questions it would help alot thank you.
Martin




PostPosted: Wed Apr 06, 2005 6:17 am   Post subject: (No subject)

Well, probably the best thing that you could do is learn about DirectX or OpenGL. Both are equally powerful, are used (Half-Life 2 was created in DirectX, Doom 3 was created in OpenGL), and fairly straightforward. Also, the SDK's for both are available for 6 easy payments of $0.00.

Now, these aren't as simple as Turing's built in drawing functions, but once you get comfortable with using one of them, you will find that they are much more powerful. Both have extensive documentation to be found online, and a lack of tutorials won't ever be a problem to you. I found that the DirectX SDK documentation included was much better than OpenGL's, but OpenGL has a lot more resources online. If you want to buy books, all of the good ones are simply about concepts, and don't focus on one of the two libraries.

So what to use? Well, which code segment looks nicer to you? Both draw a triangle.
OpenGL
code:
glBegin(GL_TRIANGLES);
        glVertex3f( 0.0f, 1.0f, 0.0f);
        glVertex3f(-1.0f,-1.0f, 0.0f);
        glVertex3f( 1.0f,-1.0f, 0.0f);
glEnd();


Below, with a predefined vertex buffer structure CUSTOMVERTEX. Okay, not quite the equivalent to above...but still. I'm not sure how to use a vertex buffer in OpenGL, and I have no idea how to do it without one in DirectX.
DirectX
code:
g_pd3dDevice->SetStreamSource( 0, g_pVB, 0, sizeof(CUSTOMVERTEX) );
g_pd3dDevice->SetFVF( D3DFVF_CUSTOMVERTEX );
g_pd3dDevice->DrawPrimitive( D3DPT_TRIANGLELIST, 0, 1 );


In the end, it's a matter of preference. If you really get into it, you'll almost invetiably end up learning both.
wtd




PostPosted: Wed Apr 06, 2005 1:14 pm   Post subject: (No subject)

Or, for fun. Smile

code:
import Graphics.UI.GLUT
import Graphics.Rendering.OpenGL

main = do
   (progName,_) <- getArgsAndInitialize
   createAWindow progName
   mainLoop

createAWindow windowName = do
   createWindow windowName
   displayCallback $= displayPoints

displayPoints = do
  clear [ColorBuffer]
  renderPrimitive Polygon
    $ mapM_ (\(x, y, z) -> vertex $ Vertex3 x y z) myPoints

myPoints :: [(GLfloat,GLfloat,GLfloat)]
myPoints =
  [(0.0, 1.0, 0.0)
  ,(-1.0, -1.0, 0.0)
  ,(1.0, -1.0, 0.0)]
Martin




PostPosted: Wed Apr 06, 2005 1:23 pm   Post subject: (No subject)

Does Ruby have support for non-glut openGL?
wtd




PostPosted: Wed Apr 06, 2005 2:14 pm   Post subject: (No subject)

Yes. Hit Google to look for documentation.

It's available on Ubuntu via apt, and at http://raa.ruby-lang.org/. Probably also as a Ruby gem.
OMouse




PostPosted: Wed Apr 06, 2005 6:19 pm   Post subject: (No subject)

The Fast Light ToolKit (FLTK) has support for OpenGL graphics in a GUI. So you can have a window with buttons controlling the OpenGL engine.

I would recommend OpenGL because of its cross-platform capabilities.

-OMouse
Sponsor
Sponsor
Sponsor
sponsor
rizzix




PostPosted: Thu Apr 07, 2005 12:12 am   Post subject: (No subject)

yes i recommed FLTK for beginners.
Display posts from previous:   
   Index -> Programming, C++ -> C++ Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 9 Posts ]
Jump to:   


Style:  
Search: