Logo by MandelBRO - Contribute your own Logo!

END OF AN ERA, FRACTALFORUMS.COM IS CONTINUED ON FRACTALFORUMS.ORG

it was a great time but no longer maintainable by c.Kleinhuis contact him for any data retrieval,
thanks and see you perhaps in 10 years again

this forum will stay online for reference
News: Did you know ? you can use LaTex inside Postings on fractalforums.com!
 
*
Welcome, Guest. Please login or register. June 13, 2021, 04:23:09 AM


Login with username, password and session length


The All New FractalForums is now in Public Beta Testing! Visit FractalForums.org and check it out!


Pages: [1]   Go Down
  Print  
Share this topic on DiggShare this topic on FacebookShare this topic on GoogleShare this topic on RedditShare this topic on StumbleUponShare this topic on Twitter
Author Topic: Any opensource renderer  (Read 2439 times)
0 Members and 1 Guest are viewing this topic.
Dratone
Guest
« on: November 17, 2009, 02:14:02 PM »

Hi,

I want to learn how to start about programming something like this. I've already got some experience in programming (PHP, C++, VB, C#), but have never so far started anything graphically.

As I want to start this, I'd like an example to study. Are there any opensource renderers? and/or could you guys give me a few pointers?
Logged
cKleinhuis
Administrator
Fractal Senior
*******
Posts: 7044


formerly known as 'Trifox'


WWW
« Reply #1 on: November 17, 2009, 03:22:05 PM »

you should perhaps start with plain opengl, 3d polygonal rendering
and then implement your renderer on a ray base  police
Logged

---

divide and conquer - iterate and rule - chaos is No random!
Duncan C
Fractal Fanatic
****
Posts: 348



WWW
« Reply #2 on: November 27, 2009, 05:06:55 AM »

Hi,

I want to learn how to start about programming something like this. I've already got some experience in programming (PHP, C++, VB, C#), but have never so far started anything graphically.

As I want to start this, I'd like an example to study. Are there any opensource renderers? and/or could you guys give me a few pointers?

XAOS is a cross platform open source fractal renderer. It's claim to fame is very fast live zooming. I took a look at the code a couple of years ago and found it hard to figure it out. It's a fairly big, complex application.

There are probably others. You might want to do a search on sourceforge.net for fractal renderers.

Are you looking for 2D or 3D rendering? What types of fractals? What platform? Since you mention C#, I would assume that you are developing for Windows?

Good luck, and let us know what you find.


Regards,

Duncan C
Logged

Regards,

Duncan C
Dratone
Guest
« Reply #3 on: December 29, 2009, 04:20:23 PM »

XAOS is a cross platform open source fractal renderer. It's claim to fame is very fast live zooming. I took a look at the code a couple of years ago and found it hard to figure it out. It's a fairly big, complex application.
Thanks, I'll take a look at that.
There are probably others. You might want to do a search on sourceforge.net for fractal renderers.

Are you looking for 2D or 3D rendering? What types of fractals? What platform? Since you mention C#, I would assume that you are developing for Windows?
I really prefer linux - however since I've had to do some development work in VB and C#, windows is a 'can do' for me, but deffinitly a 'prefer not to' smiley
Good luck, and let us know what you find.


Regards,

Duncan C

Logged
Buddhi
Fractal Iambus
***
Posts: 895



WWW
« Reply #4 on: December 29, 2009, 08:51:10 PM »

Hello Dratone,

I had the same problem when I started with fractals (about 15 years ago). I didn't know how to draw something on screen or how to calculate fractal iteration. But during this time I wrote fractal renderers in Atari Basic, Amos Basic (Amiga), Matlab, Delphi, TurboPascal, C++ on Amiga (for Motorola 68040 and PowerPC), Microsoft Visual Basic, Borland C++, on Windows and latest in C++ on Linux. I know that some basic example is very helpful at the beginning. I prepared sample code for you in C / C++ for Linux GTK environment (I'm using Ubuntu Linux 9.10 x64). This program is for rendering simple 2D Mandelbrot sets

Code:
#include <gtk/gtk.h>
#include <math.h>
#include <jpeglib.h>
#include <setjmp.h>
#include <stdio.h>

#define IMAGE_WIDTH 800
#define IMAGE_HEIGHT 800

guchar *rgbbuf;

gboolean on_darea_expose(GtkWidget *widget, GdkEventExpose *event, gpointer user_data);

struct sFractal
{
double amin;
double amax;
double bmin;
double bmax;
int N;
double da;
double db;
};

struct sParam
{
int start;
int index;
sFractal fractal;
};

int CalculateIterations(double &a, double &b, int &N)
{
double x = a;
double y = b;

int i;

for (i = 0; i < N; i++)
{
double tempx = x * x - y * y + a;
y = 2.0 * x * y + b;
x = tempx;
double r = x * x + y * y;
if (r > 4) break;
}

return i;
}

//function for saving JPG file using jpeglib
void SaveJPEG(char *filename, int quality, int width, int height, JSAMPLE *image)
{
struct jpeg_compress_struct cinfo;
struct jpeg_error_mgr jerr;
FILE * outfile;
JSAMPROW row_pointer[1];
int row_stride;

cinfo.err = jpeg_std_error(&jerr);
jpeg_create_compress(&cinfo);

if ((outfile = fopen(filename, "wb")) == NULL)
{
fprintf(stderr, "can't open %s\n", filename);
return;
}
jpeg_stdio_dest(&cinfo, outfile);

cinfo.image_width = width;
cinfo.image_height = height;
cinfo.input_components = 3; /* # of color components per pixel */
cinfo.in_color_space = JCS_RGB; /* colorspace of input image */

jpeg_set_defaults(&cinfo);
jpeg_set_quality(&cinfo, quality, TRUE);

jpeg_start_compress(&cinfo, TRUE);

row_stride = width * 3; /* JSAMPLEs per row in image_buffer */

while (cinfo.next_scanline < cinfo.image_height)
{
row_pointer[0] = &image[cinfo.next_scanline * row_stride];
(void) jpeg_write_scanlines(&cinfo, row_pointer, 1);
}

jpeg_finish_compress(&cinfo);
fclose(outfile);
jpeg_destroy_compress(&cinfo);
}

//********************************** MAIN *******************************
int main(int argc, char *argv[])
{
//gtk widgets
GtkWidget *window, *darea, *box;

//allocation memory for graphics
rgbbuf = new guchar[IMAGE_WIDTH * IMAGE_HEIGHT * 3];

//main window
gtk_init(&argc, &argv);
window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
g_signal_connect(G_OBJECT(window), "destroy", G_CALLBACK(gtk_main_quit), NULL);
g_signal_connect(G_OBJECT(window), "delete_event", G_CALLBACK(gtk_main_quit), NULL);

//,ain box in window
box = gtk_vbox_new(FALSE, 0);
gtk_container_set_border_width(GTK_CONTAINER(box), 5);

//drawing area
darea = gtk_drawing_area_new();
gtk_widget_set_size_request(darea, IMAGE_WIDTH, IMAGE_HEIGHT);
gtk_signal_connect(GTK_OBJECT(darea), "expose-event", GTK_SIGNAL_FUNC(on_darea_expose), NULL);

//putting darea to box
gtk_box_pack_start(GTK_BOX(box), darea, FALSE, FALSE, 0);

//putting box to window
gtk_container_add(GTK_CONTAINER(window), box);

gtk_widget_show_all(window);

//main parameters of fractal
sFractal fractal;

fractal.amin = -2.2;
fractal.amax = 0.8;
fractal.bmin = -1.5;
fractal.bmax = 1.5;
fractal.N = 32;

fractal.da = (fractal.amax - fractal.amin) / IMAGE_WIDTH;
fractal.db = (fractal.bmax - fractal.bmin) / IMAGE_HEIGHT;

//rendering

for (int x = 0; x < IMAGE_WIDTH; x++)
{
for (int y = 0; y < IMAGE_HEIGHT; y++)
{
double a = fractal.amin + x * fractal.da;
double b = fractal.bmin + y * fractal.db;

int L = CalculateIterations(a, b, fractal.N);

int brightness = 255.0 * ((double) L / fractal.N);

int address = (x + y * IMAGE_WIDTH) * 3;
rgbbuf[address] = brightness * 1.0; // red
rgbbuf[address + 1] = brightness * 0.9; //green
rgbbuf[address + 2] = brightness * 0.5; //blue
}
}

//end of rendering

//draw offscreen image in window
gdk_draw_rgb_image(darea->window, darea->style->fg_gc[GTK_STATE_NORMAL], 0, 0, IMAGE_WIDTH, IMAGE_HEIGHT, GDK_RGB_DITHER_NONE, rgbbuf, IMAGE_WIDTH * 3);

//saving image in JPG file
SaveJPEG("/media/Dane/Roboczy2/test.jpg", 90, IMAGE_WIDTH, IMAGE_HEIGHT, (JSAMPLE*) rgbbuf);

//wait for refreshing interface (it is necessary when fractal is rendering in animation loop)
while (gtk_events_pending())
gtk_main_iteration();

printf("End of rendering");
gtk_main();
return 0;
}

//This function refreshes graphinc when window is exposured
gboolean on_darea_expose(GtkWidget *widget, GdkEventExpose *event, gpointer user_data)
{
gdk_draw_rgb_image(widget->window, widget->style->fg_gc[GTK_STATE_NORMAL], 0, 0, IMAGE_WIDTH, IMAGE_HEIGHT, GDK_RGB_DITHER_MAX, rgbbuf, IMAGE_WIDTH * 3);
return TRUE;
}


For compile this I'm using gcc or g++ with following parameters (this is example for Eclipse SDK C++):
g++ -O2 -march=native -mfpmath=387,sse -ffast-math -Wall -c -fmessage-length=0 `pkg-config --cflags gtk+-2.0;` -MMD -MP -MF"Fractal2D.d" -MT"Fractal2D.d" -o"Fractal2D.o" "../Fractal2D.cpp"
and for linker: g++ `pkg-config --libs gtk+-2.0` -o"Fractal2D"  ./Fractal2D.o   -ljpeg

If you have some additional questions please don't hesitate to ask.
« Last Edit: December 29, 2009, 10:33:46 PM by Buddhi » Logged

Pages: [1]   Go Down
  Print  
 
Jump to:  

Related Topics
Subject Started by Replies Views Last post
another volume renderer 3D Fractal Generation lycium 1 1363 Last post August 01, 2007, 10:20:43 PM
by Nahee_Enterprises
Multithreaded Buddhabrot Renderer Programming « 1 2 3 » johandebock 34 7396 Last post September 25, 2015, 05:16:24 PM
by johandebock
box counting software - opensource project Let's collaborate on something! cKleinhuis 2 1281 Last post October 22, 2012, 08:13:36 PM
by cKleinhuis
MC Renderer feature request « 1 2 » lxh 24 2080 Last post March 29, 2013, 10:34:40 AM
by lxh
OpenCL Mandelbrot renderer (Linux/Windows/Mac, opensource) General Discussion trenmost 0 2581 Last post April 29, 2015, 08:44:39 PM
by trenmost

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines

Valid XHTML 1.0! Valid CSS! Dilber MC Theme by HarzeM
Page created in 0.134 seconds with 24 queries. (Pretty URLs adds 0.006s, 2q)