|
don't copy the buffer, render straight to texture so that you can warp it to your heart's content.
http://www.paulsprojects.net/opengl/rtotex/rtotex.html[^]
_________________________
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'm not sure if you know what i mean. Did you download my files? Look at the effect in my Visualization, that is the kind of effect i want.
Here is a pic: http://img519.imageshack.us/my.php?image=viz1kx4.png
Do you mean for me to render directly to a texture, then display that? How exactly would i do that?
btw, your link is broken
Customer in computer shop: "Can you copy the Internet onto this disk for me?"
|
|
|
|
|
VizCoder wrote: Do you mean for me to render directly to a texture, then display that? How exactly would i do that?
Yes, that is exactly what I mean. Using pbuffers and render to texture you no longer have to render to a screen (double buffered or not) and then copy back the image. You can render directly to a pbuffer which allows you to copy the image directly to memory on your computer, or you can render directly to texture memory which can then be used for rendering as a texture on another object, all in the same scene.
Also you can achieve the same process by manually controlling bufferswap so that you never see it. This is how it was done before pbuffers and render to texture calls:
render(sceneA);
glFlush();
glCopyPixels();
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
createyourtexture();
render(sceneB);
swapbuffers();
the problem with this style is that it broke the rendering cycle several times 1) with the glFlush() 2) with the read-back cycle of glCopyPixels() and 3) with the texture binding procedures.
VizCoder wrote: btw, your link is broken
It still works for me.... so just google "render to texture"
VizCoder wrote: Did you download my files?
Advice is free, debugging your code takes a lot more time. Sorry, maybe someone else will.
_________________________
Asu no koto o ieba, tenjo de nezumi ga warau.
Talk about things of tomorrow and the mice in the ceiling laugh. (Japanese Proverb)
|
|
|
|
|
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)
|
|
|
|