What graphics library should I use for line rendering for a raycasting renderer?

Davidv
  • What graphics library should I use for line rendering for a raycasting renderer? Davidv

    I want to develop simple RPG with ray casting rendering. I chose SDL for graphics and input. The problem is there is no native line drawing in it, which I need to start prototyping a ray casting engine.

    I know about SDL_gfx, which can do this, but I am asking if there is any alternative to SDL with primitives drawing functions for C++, which is easy to learn, and is also used by indie game developers?

  • Rasterisation is not a requirement for raycasting. Since generally you are casting a ray per pixel, pixel-plotting is all you need:

    void SurfaceUtils::putPixel32( SDL_Surface *surface, int x, int y, Uint32 pixel )
    {
        //Convert the pixels to 32 bit
        Uint32 *pixels = (Uint32 *)surface->pixels;
    
        //Set the pixel
        pixels[ ( y * surface->w ) + x ] = pixel;
    }
    

    (...from the SDL docs.)

    Since I'm assuming you want a raycaster in the Doom/Wolfenstein style, all you need to do is plot pixels up or down each vertical scanline till you reach the end of the screen. If you're aiming for a per-pixel raycaster instead, warning: this is slow.

    PS. I've a working per-pixel voxel raycaster and heightmap voxel raycaster, both written using SDL. No extra graphics libs were needed.

  • You basically have three options. You can use OpenGL in addition to SDL (OpenGL has support for drawing lines, and is a fairly commonly used API for graphics. You can install and use SDL_gfx or some other library for SDL that includes line drawing. Or you can try SFML, which has support for drawing lines, and is designed for C++, as opposed to SDL, which is designed for C.

Tags
c++ sdl raycasting
Related questions and answers
  • I am quite new to OpenGL, I have managed after long trial and error to integrate Nehe's Cel-Shading rendering with my Model loaders, and have them drawn using the Toon shade and outline... on screen... Since the result was kind of hacked together, I am thinking that maybe I am performing some extra steps or extra rendering tasks that maybe are not needed, and are slowing down the game..., In); // Get The Current Line ( NEW ) shaderData[i][0] = shaderData[i][1] = shaderData[i][2] = float(atof (Line)); // Copy Over The Value ( NEW ) } fclose

  • I am making a game using OpenGL, with SDL_Image employed to load the textures. When drawn on screen, there's no alpha -- in an exact square around the opaque contents of the texture, black is drawn; outside that space, white is drawn. Here is my OpenGL init code... SDL_SetVideoMode(windowWidth, windowHeight, 16, SDL_HWSURFACE|SDL_GL_DOUBLEBUFFER|SDL_OPENGL); glClearColor(0, 0, 0, 0... = SDL_DisplayFormat(zoomedImage); SDL_FreeSurface(zoomedImage); } return optimizedImage; } ...here is the code I actually use to create the GL texture... GLuint thisIsMyTexture

  • I'm writing a platform game which uses SDL for the main graphics code. There is a chance that I may be using OpenGL for the rendering at a later stage, so answers could relate to either. I'm needing a good method to include vector animations (such as a starting video) within the game. Being a platform game, I would prefer to limit the dependents and size of the data. This rules out using Theora... engine) in SDL, or rendered to an OpenGL surface in SDL. Quite simply - is this feasable? Are there any other examples as to how I should embed it? Is there a better (read: smaller and simpler) solution?

  • I'm looking into building a cross-platform opensource 2D RPG style game engine for ChaiScript. I want to be able to do all of the graphics with SVG and need joystick input. I also need the libraries I use to be opensource and compatible with the BSD license. I'm familiar with allegro, ClanLib, and SDL. As far as I can tell, none of these libraries have built in or obvious integration for SVG... not seem to have joystick input support, which would require that SDL or some other library also be used. So my question can be summed up as this: What is the best way to get SVG and joystick

  • I'm using SDL & openGL to render a tile-map. The issue is that the tile-map rendering is extremely messed up, and I'm just a bit unsure what I'm doing wrong exactly. It should just be the first tile being rendered, but I'm getting a blurred mess :S. My rendering code: glBindTexture(GL_TEXTURE_2D, texture); float texscale = 1.0f / (float)tileWidth; sourceX = sourceX / (float)tileSheetWidth..., bmask, amask); SDL_BlitSurface(LoadedImage, NULL, image, NULL); glGenTextures(1, &texture); glBindTexture(GL_TEXTURE_2D, texture); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL

  • I have a MD2 model loader, I am trying to substitute its immediate drawing function with a Vertex Buffer Object one.... I am getting a really annoying access violation reading error and I can't... glEnableClientState(GL_TEXTURE_COORD_ARRAY); glDisableClientState(GL_NORMAL_ARRAY); First of all, does it look right? Second, I get access violation error "Unhandled exception at 0x01455626 in Graphics... the exception due to unknown size of vertices).... after all this work I was expecting an improvement in performance but my frame rate is almost half what it was when rendering twice with immediate mode

  • I have a class which "collects" line mesh transformations throughout the update and then draws them in one place by drawing one line over and over again. I'll post the code below. I'm just wondering...); // in the line loop too? // combine the matrices and render D3DXMATRIX matFinal = permanentLines[i].scale * permanentLines[i].rotation...++) { pColour->SetFloatVector(temporaryLines[i].colour); // in the line loop too? // combine the matrices and render D3DXMATRIX matFinal = temporaryLines[i].scale

  • I'm new to Game programmming and SDL, and I have been following Lazyfoo's SDL tutorials. My question is related to time based motion and frame rate based motion, basically which is better or appropriate depending on situations?. Could you give me an example where each of these methods are used?. Another question I have is that, in lazyfoo's two Motion tutorials (FPS based and time based... position when you compare the two programs. As beginner which method should I stick to?(all I want is smooth animations).

  • I've been using SDL 1.2.14 for awhile without using many of the features from newer OpenGL versions. I'm now interested working only with the 3.3 API (not using the deprecated functions, etc... that's the latest my graphics card supports), but I'm having trouble getting set up. Here's some information about my development environment: Windows 7 64 bit Eclipse Helios CDT Mingw Toolchain C++ I've tried building SDL 1.3 and following this tutorial. This ended up being a pretty big pain and I gave up amid a stream of compile errors - I'd prefer to not go this route if possible. I know also

Data information