Jump to content
  • Advertisement
Sign in to follow this  
ChristianFrantz

opengl to xna

This topic is 2123 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Ive found this great tutorial for building a voxel engine that fits what I'm trying to accomplish, but the problem is that its using c++ and opengl. Im familiar with xna framework so i was wondering how easy it would be to take the opengl code and convert it to xna, either by using opengl documentation or guessing what certain functions do.

The tutorial is here https://sites.google.com/site/letsmakeavoxelengine/home/chunk-management

Share this post


Link to post
Share on other sites
Advertisement

There doesn't appear to be anything in that code that you could not translate to XNA. My advice would be to not just "guess" what the functions do but to actually look at documentation and/or source code so that you can code a port to XNA successfully. The logic should be roughly the same, but some of the details will obviously be different.

 

From what I remember XNA has a very nice math library.

 

I glanced at the articles and it seems like the easiest path is to start by making your block class and getting the blocks to render using XNA in a similar style to what is going on in the first article. Don't worry about all of the enhancements right away, and keep in mind that the way you implement some of that may need to be done differently in XNA vs OpenGL, however these are topics that you should be able to research.

 

One thing I will throw out there is that the article shows rendering in the block class. This is alright, but it may provide some difficulties in the future. You can improve rendering speeds by drawing less polygons per frame and by batching similar polygons together. Drawing less polygons means doing things like culling back faces and faces that are invisible. The articles do talk about this. Other things are not to draw polygons that are not in the same area as the player which the article also talks about. The enemy of speed for a video card is any time the render state has to change. If you can minimize the state transitions (changing textures, colors, ect) and send large batches of like polygons together then your rendering will work better.  This may involve some sort of secondary class that handles those sorts of groups and merging polygon faces from the cubes together to send off at once. You could almost then think of the block class as holding the data for a block, and another class would need to be in charge of rendering the polygons out to the video card. I am no expert, but that is what I would consider when making such a system.

 

Good luck!

Edited by shadowisadog

Share this post


Link to post
Share on other sites
I've tried creating a voxel engine before and had a lot of trouble with it. I was able to store cubes in a chunk and draw each chunk separately, but my issue was with culling the faces of the cubes and not drawing cubes the camera can't see. I saw this article and thought I'd try making the engine again. All faces of the cube have the same texture so that won't be a problem.

In my previous attempt, my block class held all the code for creating chunks. I want to avoid doing that so when i inevitably screw up i won't have to go through lines of code to fix it.

I was thinking about two separate classes, one that draws a single block and another that takes those blocks, checks for face culling, and puts the chunks into separate vertex buffers. I like how the author of the article made his class which is why i want to use his ideas

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!