Graphics mode

T

Teodor Carstea

Hi all! I'm a beginner.

I need to include graphics mode in my program, I dunno how. I can do it
in C++, but I can't in Ruby.
Example: a ball falls down. Da program calculates it's coordinates and
it works. But I wanna see it. For now I can see just an array of (x,y)
values. Help me to make a graphic view using theese coordinates. In C++
I know I need just to initialize graphics mode. But I'm really green how
to do it in Ruby.



Help!
 
P

Paul Smith

Hi all! I'm a beginner.

I need to include graphics mode in my program, I dunno how. I can do it
in C++, but I can't in Ruby.
Example: a ball falls down. Da program calculates it's coordinates and
it works. But I wanna see it. For now I can see just an array of (x,y)
values. Help me to make a graphic view using theese coordinates. In C++
I know I need just to initialize graphics mode. But I'm really green how
to do it in Ruby.

Initialize graphics mode?

C++ doesn't have a way to "initialize graphics mode", but some
library, provided by the system or a 3rd party will do so.

Unsurprisingly, you need a library to do the same in Ruby.

What library are you using when you do this in C++?

You could use a similar library in Ruby - Rubygame? Ruby/SDL?
 
M

Marnen Laibow-Koser

Teodor said:
Hi all! I'm a beginner.

I need to include graphics mode in my program, I dunno how. I can do it
in C++, but I can't in Ruby.
Example: a ball falls down. Da program calculates it's coordinates and
it works. But I wanna see it. For now I can see just an array of (x,y)
values. Help me to make a graphic view using theese coordinates. In C++
I know I need just to initialize graphics mode.

C++ has nothing like that -- there is no such thing as "graphics mode".
Perhaps you're using a particular graphics library?
But I'm really green how
to do it in Ruby.



Help!

Same way as in C++: find a graphics library you like, learn to use it.

Best,
-- 
Marnen Laibow-Koser
http://www.marnen.org
(e-mail address removed)
 
T

Teodor Carstea

C++ doesn't have a way to "initialize graphics mode"

Well, this is the way I do it in C++:

#include <graphics.h>
void main(){
//initializing graphics mode
int gdriver=DETECT, gmode, errorcode;
initgraph(&gdriver, &gmode, "C:\\Progra~1\\BORLANDC\\BGI");
errorcode = graphresult();
if(errorcode!=grOk) {
cout<<"Graphics error!!!\n"
<<"Press any key...";
getch();
exit(1);
}
//...
//AND HERE IS DA MAIN PROGRAM CODE.
//...
}

I'd like to make my ruby prog like this. Any Ideas?
P.S.: If you have an idea, please describe it in a way you would talk to
a noob, for I'm really green. Plus, I use Ubuntu, no comment.

Thanks!
 
M

Marnen Laibow-Koser

Teodor said:
Well, this is the way I do it in C++:

#include <graphics.h>

Where did you get this header? What does it contain? I don't think
this is standard in C++.

But we're getting off topic.
void main(){
//initializing graphics mode
int gdriver=DETECT, gmode, errorcode;
initgraph(&gdriver, &gmode, "C:\\Progra~1\\BORLANDC\\BGI");
errorcode = graphresult();
if(errorcode!=grOk) {
cout<<"Graphics error!!!\n"
<<"Press any key...";
getch();
exit(1);
}
//...
//AND HERE IS DA MAIN PROGRAM CODE.
//...
}

I'd like to make my ruby prog like this. Any Ideas?

Yes. Please read my earlier posts.
P.S.: If you have an idea, please describe it in a way you would talk to
a noob, for I'm really green. Plus, I use Ubuntu, no comment.

What is that supposed to mean?

Best,
-- 
Marnen Laibow-Koser
http://www.marnen.org
(e-mail address removed)
 
P

Paul Smith

Well, this is the way I do it in C++:

#include <graphics.h>
void main(){
=A0//initializing graphics mode
=A0 =A0 =A0 =A0int gdriver=3DDETECT, gmode, errorcode;
=A0initgraph(&gdriver, &gmode, "C:\\Progra~1\\BORLANDC\\BGI");
=A0errorcode =3D graphresult();
=A0if(errorcode!=3DgrOk) {
=A0 =A0 =A0 cout<<"Graphics error!!!\n"
=A0 =A0 =A0 =A0 =A0 <<"Press any key...";
=A0 =A0 =A0 getch();
=A0 =A0 =A0 exit(1);
=A0}
//...
//AND HERE IS DA MAIN PROGRAM CODE.
//...
}

I'd like to make my ruby prog like this. Any Ideas?
P.S.: If you have an idea, please describe it in a way you would talk to
a noob, for I'm really green. Plus, I use Ubuntu, no comment.

I'm really confused.

You use Ubuntu, but you have a C:\ drive?

You use ubuntu, and therefore have access to gcc, but use the Borland
compiler instead?

I think the best thing is for you to forget this 'graphics mode' and
instead look at a library like rubygame.
http://rubygame.org/wiki/Getting_started



--=20
Paul Smith
http://www.nomadicfun.co.uk

(e-mail address removed)
 
T

Teodor Carstea

Same way as in C++: find a graphics library you like, learn to use it.

ok, I'll try to find it. I use NetBeans, could you drive me step by
step?

Thanks!
 
T

Teodor Carstea

Your IDE is irrelevant. (But consider abandoning NetBeans and using
something like KomodoEdit.)
No. That's not what this list is for. If you need that kind of
handholding, buy a book.

well, well, it is truly offensive, but it makes me go stronger and
further.

and.... I'm not gonna buy ANY books.

"The best friend for you is yourself" (Louis Armstrong)

Thanks!
 
S

Seebs

Well, this is the way I do it in C++:
Uh.

#include <graphics.h>

This header is not part of standard C++. It's a library provided
by your compiler.
void main(){

This is wrong too. main() returns int. If your compiler isn't giving
you a warning for that, you should probably set it to be more
aggressive.
initgraph(&gdriver, &gmode, "C:\\Progra~1\\BORLANDC\\BGI");

You should be using forward slashes (they work fine on Windows in file
names) and full names, not the weird DOS-style names, in all probability.

This function exists only in a non-standard library you haven't referred
to, and shouldn't be getting used here anyway. If you need to make a program
wait for a user to hit a key before exiting, you have done something
else fundamentally wrong.
P.S.: If you have an idea, please describe it in a way you would talk to
a noob, for I'm really green. Plus, I use Ubuntu, no comment.

I would recommend that you look into one of the existing graphics libraries
provided by the environment. You'll note that the program described above
doesn't work on your Ubuntu system.

There's a bunch of graphics libraries out there. It matters a fair bit what
you want, but some people have suggested gosu:

http://code.google.com/p/gosu/

-s
 
M

Marnen Laibow-Koser

Seebs said:

Well, to be fair...I usually have a similar attitude. Between the rapid
change velocity of things like Rails and all the free info out there, I
don't usually need the books.

But with that choice come certain consequences, such as lack of
handholding. I have chosen to accept those consequences. People who
don't want to accept those consequences should not make that choice.
He'd be a better friend if he bought you some books to help you learn
faster.

-s

Best,
-- 
Marnen Laibow-Koser
http://www.marnen.org
(e-mail address removed)
 
K

Ken Bloom

Well, this is the way I do it in C++:

#include <graphics.h>
void main(){
//initializing graphics mode
int gdriver=DETECT, gmode, errorcode;
initgraph(&gdriver, &gmode, "C:\\Progra~1\\BORLANDC\\BGI"); errorcode
= graphresult();
if(errorcode!=grOk) {
cout<<"Graphics error!!!\n"
<<"Press any key...";
getch();
exit(1);
}
//...
//AND HERE IS DA MAIN PROGRAM CODE.
//...
}

I'd like to make my ruby prog like this. Any Ideas? P.S.: If you have an
idea, please describe it in a way you would talk to a noob, for I'm
really green. Plus, I use Ubuntu, no comment.

Thanks!

Wow! That's a blast from the past! I'm guessing it's either Borland C++
for DOS (where screens actually did have "graphics mode" versus "text
mode"[1]) or their library for Windows which simulated the old DOS
library by opening up a window and drawing in that window. (I programmed
for this emulation library 10 years ago as part of an AP computer science
assignment.)

I'm guessing that you're moving from your knowledge of old DOS/Windows
and C++, you're moving to Linux and now you want to learn a nice shiny
new language for programming in Linux, so you chose Ruby.

If you're planning on writing GUI applications, you should either look at
Ruby/GTK+ or QTRuby, both of which are good frameworks providing all of
the standard widgets that you find in word processors, web browsers, and
the like.
http://ruby-gnome2.sourceforge.jp/
http://techbase.kde.org/Development/Languages/Ruby

If you want full screen graphics (or full-screen graphics in a window),
which is often useful for game programming, you should look at Ruby/SDL.

http://www.kmc.gr.jp/~ohai/rubysdl.en.html

Ultimately you should take the time to learn a little of both.


[1] FWIW, Linux has this too, but you only think about it that way if
you're writing an X server or programming in svgalib. For the most part
that view of the world is obsolete by about 20 years.
 
K

Ken Bloom

Well, this is the way I do it in C++:

#include <graphics.h>
void main(){
//initializing graphics mode
int gdriver=DETECT, gmode, errorcode;
initgraph(&gdriver, &gmode, "C:\\Progra~1\\BORLANDC\\BGI"); errorcode
= graphresult();
if(errorcode!=grOk) {
cout<<"Graphics error!!!\n"
<<"Press any key...";
getch();
exit(1);
}
//...
//AND HERE IS DA MAIN PROGRAM CODE.
//...
}

I'd like to make my ruby prog like this. Any Ideas? P.S.: If you have an
idea, please describe it in a way you would talk to a noob, for I'm
really green. Plus, I use Ubuntu, no comment.

Thanks!

What a blast from the past!

It ain't Ruby, but you might be interested in the BOSS library
( http://www.codedread.com/code.php#BOSS )
which implements a bunch of the old Borland C++ libraries on top of the
modern SDL graphics library, if you plan to keep coding in C++.

--Ken
 
M

Marnen Laibow-Koser

Ken Bloom wrote:
[...]
If you're planning on writing GUI applications, you should either look
at
Ruby/GTK+ or QTRuby, both of which are good frameworks providing all of
the standard widgets that you find in word processors, web browsers, and
the like.
http://ruby-gnome2.sourceforge.jp/
http://techbase.kde.org/Development/Languages/Ruby
[...]

There have been several recent threads in this forum on GUI development
in Ruby, and I'd recommend reading them. I'm using JRuby and Monkeybars
for my one non-Rails project.

Best,
-- 
Marnen Laibow-Koser
http://www.marnen.org
(e-mail address removed)
 
W

Walton Hoops

-----Original Message-----
From: news [mailto:[email protected]] On Behalf Of Ken Bloom

Wow! That's a blast from the past! I'm guessing it's either Borland C++
for DOS (where screens actually did have "graphics mode" versus "text
mode"[1]) or their library for Windows which simulated the old DOS
library by opening up a window and drawing in that window. (I
programmed
for this emulation library 10 years ago as part of an AP computer
science
assignment.)

Heh same here actually... 10 years ago API Compsci ;-)
 
M

Martin DeMello

This function exists only in a non-standard library you haven't referred
to, and shouldn't be getting used here anyway. =A0If you need to make a p= rogram
wait for a user to hit a key before exiting, you have done something
else fundamentally wrong.

Ah, nostalgia :) I think it was from Borland's conio, a very
well-designed library indeed. I missed it when I first moved to linux.

martin
 
M

Matthew K. Williams

-----Original Message-----
From: news [mailto:[email protected]] On Behalf Of Ken Bloom

Wow! That's a blast from the past! I'm guessing it's either Borland C++
for DOS (where screens actually did have "graphics mode" versus "text
mode"[1]) or their library for Windows which simulated the old DOS
library by opening up a window and drawing in that window. (I
programmed
for this emulation library 10 years ago as part of an AP computer
science
assignment.)

Heh same here actually... 10 years ago API Compsci ;-)

Eeek! I feel old. I did AP CompSci back 21 years ago. It was in Pascal
then......

Matt
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,164
Messages
2,570,901
Members
47,439
Latest member
elif2sghost

Latest Threads

Top