473,416 Members | 1,774 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,416 software developers and data experts.

Graphics in C++ using Borland

Pmb
At the moment I'm using Borland's C++
(http://www.borland.com/products/down...cbuilder.html#)

I want to be able to take an array of points and plot them on the screen. Is
there a way to do this? E.g. I want to be able to graph a function. At this
point I'm not up to a level in C++ where I want to start learning Visual C++
so I don't want to go that route.

Thanks

Pmb
Jul 22 '05 #1
14 3065
Pmb <so*****@somewhere.com> spoke thus:
I want to be able to take an array of points and plot them on the screen. Is
there a way to do this? E.g. I want to be able to graph a function. At this
point I'm not up to a level in C++ where I want to start learning Visual C++
so I don't want to go that route.


(newsgroups.borland.com would be glad to help.)

Your post is off-topic for comp.lang.c++. Please visit

http://www.slack.net/~shiva/welcome.txt
http://www.parashift.com/c++-faq-lite/

for posting guidelines and frequently asked questions. Thank you.

--
Christopher Benson-Manica | I *should* know what I'm talking about - if I
ataru(at)cyberspace.org | don't, I need to know. Flames welcome.
Jul 22 '05 #2
Hi Pmb ( Pete ),

You mentioned,
" I want to be able to take an array of points
and plot them on the screen. "

You need to create a window and then get
the device constant, HDC, of that window.
You also need a pen, HPEN.

Note, this is a Win32 project, not a console project.

Below are a few code snippets that might help you.

long __stdcall
WinProc ( HWND Wnd, uint WM, uint wp, long lp ) {
return DefWindowProc( Wnd, WM, wp,lp ); }

int __stdcall WinMain ( HINSTANCE inst,
HINSTANCE PID, LPSTR CmdLn, int x1 ) {

HPEN Pen = CreatePen( PS_SOLID, 0, RGB( 255, 0, 0 ) );
HBRUSH Black = CreateSolidBrush ( RGB( 0, 0, 0 ) );
{ WNDCLASS Class = {
0, WinProc, 0, 0, PID, 0, 0, Black, 0, "WinProc" };
RegisterClass( & Class ); }

int Left_Scr, Top_Scr, W_Me, H_Me, Right_Scr, Bot_Scr ;
{ long R[ 4 ];
SystemParametersInfo(
SPI_GETWORKAREA, 0, ( RECT * ) R, 0 );
Right_Scr = R [ 2 ]; Bot_Scr = R [ 3 ];
R [ 2 ] -= R [ 0 ]; R[ 3 ] -= R [ 1 ];
Left_Scr = R [ 0 ]; Top_Scr = R [ 1 ];
W_Me = R [ 2 ]; H_Me = R [ 3 ]; }

HWND Win = CreateWindow "WinProc", "Some Title",
WS_VISIBLE, Left_Scr, Top_Scr,
W_Me, H_Me, 0, 0, PID, 0 );

HDC DC = GetDC( Win );

int x, y ;
MoveToEx ( DC , x = 100, y = 200, 0 );
LineTo ( DC, x = 200, y = 300 );
ReleaseDC( Win, DC);

MSG Msg;
while ( GetMessage( & Msg, 0,0,0) {
TranslateMessage( & Msg ); DispatchMessage( & Msg );

unsigned int M = Msg.message, C = Msg.wParam ;
if ( M == WM_KEYDOWN && C == 27) return 1;
}

}
Jul 22 '05 #3
Pmb

"Christopher Benson-Manica" <at***@nospam.cyberspace.org> wrote in message
news:c9**********@chessie.cirr.com...
Pmb <so*****@somewhere.com> spoke thus:
I want to be able to take an array of points and plot them on the screen. Is there a way to do this? E.g. I want to be able to graph a function. At this point I'm not up to a level in C++ where I want to start learning Visual C++ so I don't want to go that route.


(newsgroups.borland.com would be glad to help.)

Your post is off-topic for comp.lang.c++.


It's not off topic since I want to learn how to do this in C++.

<snip unhelpful comments>

Pmb
Jul 22 '05 #4
Pmb wrote:

"Christopher Benson-Manica" <at***@nospam.cyberspace.org> wrote in message
news:c9**********@chessie.cirr.com...
Pmb <so*****@somewhere.com> spoke thus:
I want to be able to take an array of points and plot them on the screen. Is there a way to do this? E.g. I want to be able to graph a function. At this point I'm not up to a level in C++ where I want to start learning Visual C++ so I don't want to go that route.


(newsgroups.borland.com would be glad to help.)

Your post is off-topic for comp.lang.c++.


It's not off topic since I want to learn how to do this in C++.


Hmm. I checked the C++ standard and there is nothing mentioned
about graphics.

The fact that you used C++ is completely unimportant in your case.
Your problem is not about C++ but about doing graphics. C++ in
this case is just the tool to do something. Using the same
logic I could argue that Einsteins theory of relativity is on
topic, since I use C++ to implement some equations from that
theory.

Not everything with C++ in it is on topic in this group.

Please check:
http://ma.rtij.nl/acllc-c++.FAQ.html#q1.6
comp.lang.c++ follows the same rules as alt.comp.lang.learn.c-c++
with respect to this.

--
Karl Heinz Buchegger
kb******@gascad.at
Jul 22 '05 #5
Pmb

"Karl Heinz Buchegger" <kb******@gascad.at> wrote in message
news:40***************@gascad.at...
Pmb wrote:

"Christopher Benson-Manica" <at***@nospam.cyberspace.org> wrote in message news:c9**********@chessie.cirr.com...
Pmb <so*****@somewhere.com> spoke thus:

> I want to be able to take an array of points and plot them on the screen. Is
> there a way to do this? E.g. I want to be able to graph a function.
At this
> point I'm not up to a level in C++ where I want to start learning
Visual C++
> so I don't want to go that route.

(newsgroups.borland.com would be glad to help.)

Your post is off-topic for comp.lang.c++.


It's not off topic since I want to learn how to do this in C++.


Hmm. I checked the C++ standard and there is nothing mentioned
about graphics.

The fact that you used C++ is completely unimportant in your case.


I disagree.
Your problem is not about C++ but about doing graphics.


That is incorrect. A topic on doing graphics is a topic on the algorithms
and techniques of graphics. I don't want to know that. I want to know the
nuts and bolts of function calls and how to use C++ to get the system to do
graphics

<snip incorrect analogy>

I have a text called "Numerical Methods in C" which shows how to do this. I
can't follow the code. I want to find a place/material in which something
similar is done and explained in term of C++.

And I understand what is and is not on topic. Sometimes people disagree
about what is or is not on topic. I do not post messages which I consider to
be off topic.

If you consider this off topic then please do not respond. I do not consider
this off topic.

Pmb
Jul 22 '05 #6

"Pmb" <so*****@somewhere.com> wrote in message
news:cb********************@comcast.com...

"Christopher Benson-Manica" <at***@nospam.cyberspace.org> wrote in message
news:c9**********@chessie.cirr.com...
Pmb <so*****@somewhere.com> spoke thus:
I want to be able to take an array of points and plot them on the screen. Is there a way to do this? E.g. I want to be able to graph a function.
At
this point I'm not up to a level in C++ where I want to start learning
Visual
C++ so I don't want to go that route.


(newsgroups.borland.com would be glad to help.)

Your post is off-topic for comp.lang.c++.


It's not off topic since I want to learn how to do this in C++.


If you'd just click on those links and read the welcome message and faq,
then you'd know that your question *is* off-topic here. This group
discusses the C++ language as defined by the standard, not how to use C++ to
accomplish platform-specific tasks.

Using just functions and classes available in standard C++, there is no way
to accomplish what you've asked. There simply are no graphics functions in
C++. There *are* such functions in various implementations (such as VC++),
as add-ons and third-party API's, but those are specific to the
implementation, and to the platform.

You need to ask in a newsgroup devoted to the compiler (e.g., on the
newsgroups.borland.com server) or the platform (e.g., on the
news.microsoft.com server) to find out how to do things specific to their
software.

-Howard
Jul 22 '05 #7
Pmb wrote:

The fact that you used C++ is completely unimportant in your case.
I disagree.


It is.
Your problem is not about C++ but about doing graphics.
That is incorrect. A topic on doing graphics is a topic on the algorithms
and techniques of graphics. I don't want to know that. I want to know the
nuts and bolts of function calls and how to use C++ to get the system to do
graphics


Then the answer is: there is no such thing. At least not in the context
of this group.

<snip incorrect analogy>

I have a text called "Numerical Methods in C" which shows how to do this. I
can't follow the code. I want to find a place/material in which something
similar is done and explained in term of C++.

And I understand what is and is not on topic.
Obviously not.
Sometimes people disagree
about what is or is not on topic. I do not post messages which I consider to
be off topic.

If you consider this off topic then please do not respond. I do not consider
this off topic.


Talking about topicality is always on topic per definition.
--
Karl Heinz Buchegger
kb******@gascad.at
Jul 22 '05 #8
Hi Pmb ( Pete ),

Because Direct Draw 7 can do VRAM to VRAM blts,
I always use it when I need to do graphics.

DD 7 is a C++ API ( Framework ).

But unlike OpenGL, it comes preloaded on almost all PC's.
( Google: define:OpenGL . Also: "Direct Draw 7" )

However, the API doesn't really teach a lot of C++ stuff,
it doesn't seem all that different from plain C.

The following will give you
a small taste of what it looks like:

#define _SurT LPDIRECTDRAWSURFACE7

LPDIRECTDRAW7 Direct_Draw;
LPDIRECTDRAW _Direct_Draw;
DDSURFACEDESC2 Z;
_SurT Sur_Scr, Sur_Draw, Sur_Cur, Sur_Font;
BITMAP BMH; DDBLTFX ErBlack, ErSel, ErOdd;
DDCOLORKEY BlueKey;

DirectDrawCreate( 0, & _Direct_Draw, 0 );
_Direct_Draw->QueryInterface(
IID_IDirectDraw7, (VOID**) & Direct_Draw );
if ( ! _Direct_Draw ) Fatal( "No Direct Draw 7");
Direct_Draw->SetCooperativeLevel( Win, DDSCL_NORMAL );
memset( & Z, 0,sizeof( Z )); Z.dwSize = sizeof Z;
Z.dwFlags = DDSD_CAPS;
Z.ddsCaps.dwCaps= DDSCAPS_PRIMARYSURFACE;
Direct_Draw->CreateSurface( & Z, & Sur_Scr, 0 );
ErBlack.dwSize =
ErSel.dwSize = ErOdd.dwSize = sizeof ErBlack;
ErSel.dwFillColor = Get_Color( Sur_Scr, RGB( 0, 66, 0 ) );
ErOdd.dwFillColor =
Get_Color( Sur_Scr, RGB( 0, 128, 128 ) );
Z.dwFlags |= DDSD_HEIGHT | DDSD_WIDTH;
Z.ddsCaps.dwCaps = DDSCAPS_VIDEOMEMORY;
Z.dwWidth = W_Me; Z.dwHeight = H_Me;
Direct_Draw->CreateSurface( & Z, & Sur_Draw, 0 );
if ( ! Sur_Draw ) {
DDCAPS Caps; Caps.dwSize = sizeof Caps;
Direct_Draw->GetCaps( & Caps, 0 );
Fatal( "No VRAM for back buffer\n"
"Needed: %3.1f MegaBytes\nNot: %3.1f MegaBytes\n",
W_Me * H_Me * 4 / A_Meg,
Caps.dwVidMemFree / A_Meg ); }
Z.ddsCaps.dwCaps = DDSCAPS_TEXTURE;
Z.ddsCaps.dwCaps2= DDSCAPS2_TEXTUREMANAGE;
int K = Get_Color(Sur_Scr,_Blue); DDCOLORKEY KK = { K, K }; BlueKey = KK;

And on and on ...
Jul 22 '05 #9
Pmb wrote:
"Karl Heinz Buchegger" <kb******@gascad.at> wrote in message
news:40***************@gascad.at...
Pmb wrote:
"Christopher Benson-Manica" <at***@nospam.cyberspace.org> wrote in
message
news:c9**********@chessie.cirr.com...

Pmb <so*****@somewhere.com> spoke thus:
>I want to be able to take an array of points and plot them on the

screen. Is

>there a way to do this? E.g. I want to be able to graph a function.
At
this

>point I'm not up to a level in C++ where I want to start learning
Visual
C++

>so I don't want to go that route.

(newsgroups.borland.com would be glad to help.)

Your post is off-topic for comp.lang.c++.

It's not off topic since I want to learn how to do this in C++.


Hmm. I checked the C++ standard and there is nothing mentioned
about graphics.

The fact that you used C++ is completely unimportant in your case.

I disagree.

Your problem is not about C++ but about doing graphics.

That is incorrect. A topic on doing graphics is a topic on the algorithms
and techniques of graphics. I don't want to know that. I want to know the
nuts and bolts of function calls and how to use C++ to get the system to do
graphics

<snip incorrect analogy>

I have a text called "Numerical Methods in C" which shows how to do this. I
can't follow the code. I want to find a place/material in which something
similar is done and explained in term of C++.

And I understand what is and is not on topic. Sometimes people disagree
about what is or is not on topic. I do not post messages which I consider to
be off topic.

If you consider this off topic then please do not respond. I do not consider
this off topic.

Pmb


The usage of the language, such as which containers to use for graphics
is topical. How to actually draw the pixels isn't.

Perhaps it is time for another one of my graphics rants. You can search
this newsgroup and news:comp.lang.c for my rants on why graphics, color
and displays are not topic. I'll be brief this time.

First off, C++ does not assume nor demand any platform to support
graphics. One can use C++ to program a vending machine, which has
no display. One can also use C++ to program video games or image
processing. However, anything beyond the actual language is off-topic
for this newsgroup. There are newsgroups that love to discuss graphic
algorithms and platform specific groups that discuss how to draw a
a pixel.

Back to the rant. Secondly, there is no standard for graphics. There
was a Graphics Kernel System, but that is more along theory than
implementation. Let us take a small sample, say the Microsoft Windows
PCs. There is no standard as to pixel organization. The operating
system has many different file formats to support this. Here are some
issues:
1. Colors per pixel (assuming a platform can support colors).
Some systems support one (Black / white), others have 3 or more.
2. Values per color. How many values per color? 24 bit? 8 bit?
3. Color mapping / scheme, which one:
RGB, CMYK, HSB?
4. Vector graphics?
5. Layers or planes. There is no standard for multiple planes,
nonetheless, drawing operations on planes (i.e. translucent,
opaque, blend, etc.).

Let's say that Microsoft has a standard. Can I take a simple program
that draws a toroid in purple and run that on Windows 95, 98, 2000,
ME, XP, and CE and have it display the same?
Can I take the same program, compile and run it on a Linux system?
Can I take the same program, compile and run it on a VAX system?
Can I take the same program, compile and run it on a Ninetendo Game
Cube?

However, I can take a conforming C++ program, compile it on a
supporting (hosted) platform and have it produce the same results.
This is what standardization provides.
--
Thomas Matthews

C++ newsgroup welcome message:
http://www.slack.net/~shiva/welcome.txt
C++ Faq: http://www.parashift.com/c++-faq-lite
C Faq: http://www.eskimo.com/~scs/c-faq/top.html
alt.comp.lang.learn.c-c++ faq:
http://www.raos.demon.uk/acllc-c++/faq.html
Other sites:
http://www.josuttis.com -- C++ STL Library book

Jul 22 '05 #10
This group is about Standard C++. Both the language and the standard
library have no concept of "graphics". Therefore, it is off-topic.

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
To iterate is human, to recurse divine.
-L. Peter Deutsch
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Jul 22 '05 #11
> Hi Pmb ( Pete ),

You mentioned,
" I want to be able to take an array of points
and plot them on the screen. "

You need to create a window and then get
the device constant, HDC, of that window.
You also need a pen, HPEN.

Note, this is a Win32 project, not a console project.

Below are a few code snippets that might help you.

<code snippets snipped>

In the code snippets, you have used a lot of names that you haven't
declared and aren't part of the Standard Library. BTW, : "Names
beginning with an underscore and a capital letter or two underscores
are reserved for use by the implementation and shall not be used
otherwise." (This isn't an exact quote from the standard, but it says
something along those lines). So, you should avoid using names like
__stdcall beginning with 2 underscores. Anyway, the declaration:

long __stdcall
WinProc ( HWND Wnd, uint WM, uint wp, long lp ) {
return DefWindowProc( Wnd, WM, wp,lp ); }

(apart from the undeclared identifiers), certainly seems like a syntax
error, unless some clever macros are invloved.

BTW, this group is about Standard C++ and there are no graphics in
Stdandard C++.
Jul 22 '05 #12
Hi Prateek R Karandikar,

I showed:
long __stdcall
WinProc ( HWND Wnd, uint WM, uint wp, long lp ) {
return DefWindowProc( Wnd, WM, wp,lp ); }

And you commented,
" ( apart from the undeclared identifiers ),
[ that ] certainly seems like a syntax error,
unless some clever macros are involved. "

What undeclared identifiers ?

uint is an unsigned int ... is that what you meant ?

Wnd, WM, wp,lp are all declared in the parameter list.

__stdcall and DefWindowProc() are from Windows.H.
Jul 22 '05 #13
Jeff Relf wrote:
__stdcall and DefWindowProc() are from Windows.H.


When I #include <windows.h>, I get an error indicating that that include
file wasn't found.

Perhaps you might discuss this on a VC newsgroup instead of a group
dedicated to Standard C++?
Jul 22 '05 #14
> Hi Prateek R Karandikar,

I showed:
long __stdcall
WinProc ( HWND Wnd, uint WM, uint wp, long lp ) {
return DefWindowProc( Wnd, WM, wp,lp ); }

And you commented,
" ( apart from the undeclared identifiers ),
[ that ] certainly seems like a syntax error,
unless some clever macros are involved. "

What undeclared identifiers ?

uint is an unsigned int ... is that what you meant ?

Wnd, WM, wp,lp are all declared in the parameter list.

__stdcall and DefWindowProc() are from Windows.H.


There is no standard typedef uint for unsigned int. There is no
standard header Windows.H
Jul 22 '05 #15

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Deepak Gupta | last post by:
Dear sir , I have a problem with my cpp compiler. I have terbo(borland) 3.0 & 4.5 both compiler compiler but compling a graphics.h header file it shows an error that BGI graphics not supported in...
2
by: daytripper | last post by:
im doing a physics/math model on borland Command LIne Compiler 5.5. i want to test the data arrays graphically. ie plot a few simple line graphs of the data in the arrays. this compile doesnt...
1
by: wildchild | last post by:
Hi, I am new to grpahics progamming in/under Borland C. I have included the "graphics.h" header file but i am unable to take input on the screen. if i try to move my cursor to a specified...
5
by: SJ | last post by:
Hi, I'd like to pu text fixed fith graphics and equations onto some control. And I don't know which one. I tried to use TRichEdit but its doesn't show graphics and eqation. How can I show these...
4
by: Chris | last post by:
It's becoming clear I am using Bloodshed Dev-C++ and have tried to use WinBGIm, but I can't find any documentation for it, let alone the proper libraries. Can anyone give me a link? or ...
2
by: mweitz | last post by:
"BGI Graphics are not supported under Windows" - I`ve got this message working in Borland C++ 5.01. File (house.cpp) should include graphics. Project contents: home.cpp; ...
0
by: sumitnxt | last post by:
Please tell me where can i find graphics.h header file for borland C++ Compiler
6
by: jt | last post by:
i think i was not clear in my quesiton. my question actually was how to store a graphics image generated in C. Eg. #include<graphics.h> void main() { int gm,gd=DETECT; initgraph(&gd,&gm,"");...
0
by: madex | last post by:
hi, im trying to change font in graphics mode under borland compiler, im using settextstyle(); but it doesnt work, idk why it always prints the default font, the reason i need to change font is...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.