Title: .net based fractal rendering/ray tracing
Post by: JColyer on November 21, 2009, 02:23:12 AM
Anybody out there using .net to write their rendering software? I'm a C#/.Net programmer by trade, but only sever side and web based stuff. When it comes to windows GUI programming - well - I've got no clue. I read a lot about the coding behind ray tracers, but with my lack of windows GUI knowledge I'm totally hosed.
James
Title: Re: .net based fractal rendering/ray tracing
Post by: David Makin on November 21, 2009, 02:52:03 AM
Lack of Windows GUI programming knowledge is the main reason I use Ultra Fractal - plus the fact that I'm sick of all the issues relating to software development under Windows in C/C++ etc.
Title: Re: .net based fractal rendering/ray tracing
Post by: Snakehand on December 10, 2009, 03:05:34 PM
Lack of Windows GUI programming knowledge is the main reason I use Ultra Fractal - plus the fact that I'm sick of all the issues relating to software development under Windows in C/C++ etc.
One solution which I use, is SDL - it is originally inteded for games, but can be used as a simple cross platform UI. For illustration I have attached a "shell" that I use for my GPU fractal renderer. The following snippet is all the GUI code that is needed for simple key driven interaction. #include "SDL.h" #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include "Bulber.h"
void UpdateScreen( SDL_Surface *screen, Bulber* bulb) { unsigned char *raw_pixels; SDL_LockSurface(screen);
raw_pixels = (unsigned char*)screen->pixels;
bulb->Blit( raw_pixels, screen->pitch );
SDL_UnlockSurface(screen); SDL_UpdateRect(screen,0,0,0,0); }
int main() { SDL_Surface *screen;
/* Initialize SDL's video system and check for errors */ if (SDL_Init(SDL_INIT_VIDEO) != 0) { printf("Unable to initialize SDL: %s\n", SDL_GetError()); return 1; };
/* Make sure SDL_Quit gets called when the * program exits! */ atexit(SDL_Quit);
/* Attempt to set a 640x480 24bpp video mode */ screen = SDL_SetVideoMode(800,600,24,SDL_SWSURFACE );// | SDL_RESIZABLE); if (screen == NULL) { printf("Unable to set video mode: %s\n", SDL_GetError()); return 1; };
/* If we got this far, everything worked */ int x,y; Bulber bulb(800,600); float cx = 0.0f; float cy = 0.0f; float cz = -4.0f; float zoom = 1.0f;
bulb.Calc( cx, cy, cz, zoom ); UpdateScreen(screen, &bulb);
SDL_EnableKeyRepeat(300,100);
SDL_Event event; bool run = true; for(;run;) { SDL_WaitEvent(&event); switch (event.type) { case SDL_KEYDOWN: switch(event.key.keysym.sym){ case SDLK_a: cz -= 0.01 / zoom; bulb.Calc( cx, cy, cz, zoom ); UpdateScreen(screen, &bulb); break; case SDLK_z: cz += 0.01 / zoom; bulb.Calc( cx, cy, cz, zoom ); UpdateScreen(screen, &bulb); break; case SDLK_LEFT: cx -= 0.04f /zoom; bulb.Calc( cx, cy, cz, zoom ); UpdateScreen(screen, &bulb); break; case SDLK_RIGHT: cx += 0.04f /zoom; bulb.Calc( cx, cy, cz, zoom ); UpdateScreen(screen, &bulb); break; case SDLK_UP: cy -= 0.1f /zoom; bulb.Calc( cx, cy, cz, zoom ); UpdateScreen(screen, &bulb); break; case SDLK_DOWN: cy += 0.1f /zoom; bulb.Calc( cx, cy, cz, zoom ); UpdateScreen(screen, &bulb); break; case SDLK_PAGEUP: zoom = zoom / 1.1f; bulb.Calc( cx, cy, cz, zoom ); UpdateScreen(screen, &bulb); break; case SDLK_PAGEDOWN: zoom = zoom * 1.1f; bulb.Calc( cx, cy, cz, zoom ); UpdateScreen(screen, &bulb); break; default: break; } break;
case SDL_QUIT: run = false; break; } }
return 0; }
Title: Re: .net based fractal rendering/ray tracing
Post by: twinbee on December 10, 2009, 03:50:37 PM
I use SDL too - a great library, and it works fine under Visual C++ 2008. No GUI knowledge is really needed.
If anyone wants to know the best tutorial for setting up SDL with Visual C++, there's a good one if I can find it.....
|