|
heloo my friend..okie my for loop like that :
for (int j=0; j < arraylist_points.Count; j++){...}
so lets say i draw squar then line ..it will be saved in text file as..:
Line
{X=83,Y=58}{X=257,Y=172}
Line
{X=165,Y=55}{X=71,Y=251}
its should write squar then line..not line twice..!!
|
|
|
|
|
Cool but the code you posted doesn't show anything except looping through an existing array.
If DrawWhat==1 it writes a bunch of lines (in a loop)
If DrawWhat==2 it writes a bunch of squares (in a loop)
If you want them written in a different order than that you'll need to code it that way
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
mr jets wrote: for(int j=0;j {
Check 'Ignore HTML tags in this message' to make your code render properly.
Have you stepped through the code ? Have you made sure the last item isn't actually in the list twice ?
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 )
|
|
|
|
|
mr jets wrote: BUTT the problem is its writting the last thing i draw
As I tell my team. When faced with a bug/issue you cannot explain, start verifying your assumptions. Step through the code with a debugger, generate a smaller sample to easily step through. If the bug is consistant, then you can reduce it to 2 or 3 shapes and still get the extra item, so single step through inspecting values. Debugging isn't magic, its just research into how the computer is dealing with your code, and finding where what you told it is inconsistant with what it is doing.
If you don't have a debugger, message boxes, print displays and other items have been an age-old custom to watching computer activity as it happens.
_________________________
Asu no koto o ieba, tenjo de nezumi ga warau.
Talk about things of tomorrow and the mice in the ceiling laugh. (Japanese Proverb)
|
|
|
|
|
Hi, i am writing a small app which renders OpenGL to a frame inside a window. I want it to be rendered every time an event occurs such as creating a new file (which would reset the view). However, i also want to render in frames per second when it is enabled. In this case, a timer causes an event every, say, 100ms. Now, that event causes a render function to be called which copies the OpenGL screen to a texture, warps it, and renders it back. Every time any other event occurs, all that needs to be done is to draw the warped image.
So, how do i use SwapBuffers(HDC) twice, once in each render function, but so that the image does not flicker.
Download here[^] and get my WMP visualization here[^]. Run the program before you try to compile, because if Dev-Cpp can't compile it will delete the exe.
Customer in computer shop: "Can you copy the Internet onto this disk for me?"
|
|
|
|
|
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.
|
|
|
|
|