|
El Corazon wrote: Advice is free, debugging your code takes a lot more time. Sorry, maybe someone else will.
that's ok, i can't expect everyone to go searching through my code finding bugs. I just wanted you to see my viz to get an idea of what i want to do.
As for your solution, i don't really know much about OpenGL so i might read a few tutorials before attempting anything like that
Customer in computer shop: "Can you copy the Internet onto this disk for me?"
|
|
|
|
|
Well, i have taken the leap to using pbuffers. I really have no idea about OpenGL let alone pbuffers so i am just picking things up as i go along. I got some code of the internet which uses pbuffers but i can't get it to work. There were 3 ways of doing it, i did the second one since my hardware doesn't support the 3rd way (see here[^], "Off-screen Rendering Using Pixel Buffers" Version #2).
I was wondering if i need a certain version(?) of wglext.h since they included one in the download and i didn't have one before so i just copied that.
I keep getting errors when trying to switch contexts between rendering to the pbuffer and rendering to the screen, i,e wglMakeCurrent() fails.
Any ideas, just of the top of your head since i can't post my whole code. Could it be the way i'm doing it or is it my hardware? (The example exe from the site worked but i didn't compile)
Customer in computer shop: "Can you copy the Internet onto this disk for me?"
|
|
|
|
|
Hi,
I agree with previous posts. I will take a lot of time to download your files, compile them, run them... even if the resulting images are quite cool. I come here once in a while to give some advice if I think they can be usefull, but I have my own project and many other things to ocupy my time.
So I would like to invite you to state what your problem is. In other words, what it is that is happening that is not as you expected? I think this is a good starting point for me to try to help.
Anyway, I suspect that SwapBuffers() 2 times results in not swapping at all. At least with double buffering. So I don't know why you would want that.
I have the feeling you would want something like:
1. WaitEvent()
2. TakePrimaryBufferAndCopyItToTexture()
3. WarpItAsNecessary()
4. DrawToSecondaryBuffer()
5. SwapBuffersOnceToMakeSecondaryBecomePrimary()
6. goto 1.
Is this not what you want?
I hope this helps,
Rilhas
|
|
|
|
|
hello guys..my program is about drawing some shapes like (lines ,polygons..etc)my nightmare is after drawing the shapes i wanna to save them as atext file which contains the (start point , end point , color ,..etc)
iam using V.S 2003...i will apprecaite any help .
Regards ;
|
|
|
|
|
hi,
i would recommend that you create a separate class to hold all the fields that you need such as points and colors etc. and every time you draw any shape, you would need to save the things you need in memory. then when you click save(or whatever) you can write the contents of the array to the file.
you can use an arraylist to store the objects that you create, or any array structure that you are comfortable with.
hope this helps.
regards
|
|
|
|
|
yah thats cool my bro..i have already used an arraylist and thats was my best :
// save the file
string str_Line;
System.IO.FileStream fs = new System.IO.FileStream("c:\\graphics.txt", System.IO.FileMode.OpenOrCreate, System.IO.FileAccess.Write, System.IO.FileShare.ReadWrite);
StreamWriter streamWriter=new StreamWriter(fs);
if(drawwhat==1)
{
for(int j=0;j
|
|
|
|
|
hi,
from the code above i see that you are storing the points in the array list, but this is not a good way to store data because you don't know that kind of shape it is i.e. is it a line, a circle, a rectangle... what?
therefore, i recommmend you to store objects of the shape class that you can create for each shape you draw and store that object in the arraylist.
if you do this, you can set the type of shape that it represents just by setting a simple flag - some enum value. so, when you save the data, you will be saving the class objects and not points. when you retrieve the data, you will retrieve the class objects.
this will enable you to distinguish what type of shape it is and enable you to draw accordingly.
hope this helps.
regards
|
|
|
|
|
You have been asking the same questions for some time now. Realistically, the best way to do this is to create a class for each shape you want to draw, with a common base class, and make a list of that base class. Then you can make the class know how to build itself from the string you store in your file, and to generate a string which identifies the shape type and the details of that shape.
I'd go for something less verbose, you really only need to store numbers, just assign each shape type a number.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Hi,
where can I find algorithms for drawing different shapes, I found some to draw spiral and circle, but I need to have more shapes.
Can you please recommend any website(s) that helps?
thanks,
|
|
|
|
|
just more? nothing specific?
http://www.acm.org/tog/GraphicsGems/[^]
_________________________
Asu no koto o ieba, tenjo de nezumi ga warau.
Talk about things of tomorrow and the mice in the ceiling laugh. (Japanese Proverb)
|
|
|
|
|
thanks El Corazon,
I don't need any specific shape,
for example:
<br />
for( int i=0 ; i<200 ; ++i)<br />
{<br />
theta = 2+Math::PI*float(i)/10;<br />
r = Math::Sqrt(theta);<br />
x=r*Math::Cos(theta)+400;<br />
y=r*Math::Sin(theta)+400;<br />
}<br />
this algorithm will give me a very beautiful shape. I need more algorithms that would to the same.
|
|
|
|
|
sarah_malik wrote: I need more algorithms that would to the same.
there are many. It is called a polar graph, or polar equation. That particular one is one of the more simple ones.
x=r*cos(theta);
y=r*sin(theta);
is the translation from polar (radius=r, angle=theta) coordinates to Cartesian coordinates.
You can make your own and experiment with others from here:
http://www.analyzemath.com/polarcoordinates/polarcoordinates.html[^]
http://www.analyzemath.com/polarcoordinates/graphing_polar_equations.html[^]
I did many polar coordinates on my first computer, including a spider's web.
_________________________
Asu no koto o ieba, tenjo de nezumi ga warau.
Talk about things of tomorrow and the mice in the ceiling laugh. (Japanese Proverb)
|
|
|
|
|
|
The Grand Negus wrote: the number of things you can draw with formulas is seriously limited.
Actually, the number of things you can draw with formulas are infinite, but not all of them attractive. In many cases, one formula provides infinite variations, though subtle, and given multiple formulas and methods (like fractals?), the list goes on....
however... that was why I pointed to the graphics gems first, which covers algorithmic drawing in detail.
_________________________
Asu no koto o ieba, tenjo de nezumi ga warau.
Talk about things of tomorrow and the mice in the ceiling laugh. (Japanese Proverb)
|
|
|
|
|
|
sarah_malik wrote: but I just need algorithms that would draw such things.
check out the formulas behind fractals. There are many self-similar iterative design systems. http://en.wikipedia.org/wiki/Fractal[^] also L-Systems: http://en.wikipedia.org/wiki/L-system[^]
_________________________
Asu no koto o ieba, tenjo de nezumi ga warau.
Talk about things of tomorrow and the mice in the ceiling laugh. (Japanese Proverb)
|
|
|
|
|
THANK YOU.
|
|
|
|
|
You are welcome. The hardest part is trying to figure out what you are looking for. There are as many shapes as the imagination, and as many methods of getting them.
_________________________
Asu no koto o ieba, tenjo de nezumi ga warau.
Talk about things of tomorrow and the mice in the ceiling laugh. (Japanese Proverb)
|
|
|
|
|
The Grand Negus wrote: do you want to (1) write a program to produce art of a particular kind, or do you want to (2) use someone else's program to produce these works?
I'm trying to write a program that produces art
The Grand Negus wrote: I need to know what language(s) you know, your level of expertise, and how much time you're willing to spend on the thing.
I know C, C++, managed C++ and VB. I'm a beginner in the graphics field, actually this is my firt graphics program and I would spend maybe 1 to 2 weeks.
thanks,
|
|
|
|
|
sarah_malik wrote: I'm trying to write a program that produces art
Take a look at FractInt in the link that GN gave you. I haven't used fractint in years, but the idea was you could zoom in and out of fractals getting the core numbers to reproduce it. So you can find the art within the math, and get the numbers back out to reproduce it. I used to play around with it a lot. Fractals make for interesting art as you saw in the mosaic images. Fractals are a good tool, mathematically and visually interesting.
_________________________
Asu no koto o ieba, tenjo de nezumi ga warau.
Talk about things of tomorrow and the mice in the ceiling laugh. (Japanese Proverb)
|
|
|
|
|
The Grand Negus wrote: The source code (in Plain English) is also on the site.
You should try Ultimate C++, you could reduce the verbiage of that source by a factor of 3 or 4.
_________________________
Asu no koto o ieba, tenjo de nezumi ga warau.
Talk about things of tomorrow and the mice in the ceiling laugh. (Japanese Proverb)
|
|
|
|
|
The Grand Negus wrote: How 'bout them Mandelbrots?
Alive and well, and producing images through infinity.
http://users.erols.com/ziring/mandel.html[^]
http://www.codeproject.com/cpp/mandelbrot_obfuscation.asp[^]
or
void mandel(int xpt, int ypt)<br />
{<br />
long double x=0;<br />
long double y=0;
long double xnew=0;<br />
long double ynew=0;<br />
<br />
for(int k=0;k<=initer;k++)
{<br />
<br />
xnew=x*x-y*y + xpt*pixcorx+Minx;<br />
ynew=2*x*y + Maxy-ypt*pixcory;<br />
x=xnew;<br />
y=ynew;<br />
if ( (x*x+y*y)>4 ) break;
}
<br />
int color = k;<br />
if (color>15) color=color%15;<br />
if (k>=initer)<br />
putpixel(xpt,ypt,0);<br />
else<br />
putpixel(xpt,ypt,color);<br />
<br />
newcolor=color;<br />
}
_________________________
Asu no koto o ieba, tenjo de nezumi ga warau.
Talk about things of tomorrow and the mice in the ceiling laugh. (Japanese Proverb)
|
|
|
|
|
I can't thank you enough guys. I really appreciate your help.
thanks for everything.
|
|
|
|
|
Hello frens, help me about how to code for flipping an image horizontally or vertically myself, as a general guide?
I need to do it without using the library functions.
madhav
|
|
|
|
|
The basic idea is to move the data for each pixel from it's original place to its flipped place.
How you code it depends on the layout of your image pixel data.
Typically it's in a packed form (like an array), where pixel data for a row is consecutive and
each row of pixel data follows the previous. To flip the pixels in-place (without needing a
second image buffer) you could use a pointer to the first row/column pixel data and a pointer to
the last row/column pixel data (whether you use row or column depends on if you are flipping
horizontally or vertically)...
Pseudocode for vertical flip:
Set FirstRowPtr to first row pixel data
Set LastRowPointer to last row pixel data
loop (imageheight / 2) times
{
swap FirstRowPtr pixel data with LastRowPointer pixel data
Set FirstRowPtr to next row pixel data
Set LastRowPointer to previous row pixel data
} For interlaced image data it's similar, but the row/col calculations are more complex.
Hope that helps a bit,
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|