Jump to content

  • Log In with Google      Sign In   
  • Create Account

Banner advertising on our site currently available from just $5!

1. Learn about the promo. 2. Sign up for GDNet+. 3. Set up your advert!

dave j

Member Since 11 Oct 2002
Offline Last Active Feb 10 2015 06:11 AM

#5195141 Trying to optimize a mesh in python, but it's WAY too slow :P

Posted by dave j on 28 November 2014 - 05:06 AM

Ah, ok. Well I finally got it working with the help of an octree. I will try using your methon with the hash maps. I was originally using separate lists inside of each octree node, but I might try to use a map instead. I did use a hash map for changing the indices, but I didn't think of adding up the position values X3. I was too afraid that that would result in a collision, which CAN happen if you have a cube shaped mesh with the same values in different coordinate axis (Example: Vertex1(0, 0, 1), Vertex2(1, 0, 0).

Don't worry about calculating a hash - putting it into the map will do that anyway. Just concatenate everything into a string e.g.:

key = pack("ffffffff", x, y, z, nx, ny, nz, u, v)

Your code can then become something like:
vertexCache = {}

// Get a dictionary of unique vertices.
maxIndex = 0
for v in oldVertexList:
   key = pack("ffffffff", v.x, v.y, v.z, v.nx, v.ny, v.nz, v.u, v.v)
   if not key in VertexCache:
      vertexCache[key] = maxIndex
      maxIndex += 1

// Convert it into a list in index order for unpacking and writing out later.
newVertexList = list(repeat(-1,maxIndex))
for (k,v) in iter(vertexCache.items()):
   newVertexList[v] = k

// Create a new index list referring to items in newVertexList
newIndexList = []
for index in oldIndexList:
   v = oldVertexList[index]
   key = pack("ffffffff", v.x, v.y, v.z, v.nx, v.ny, v.nz, v.u, v.v)

#5171246 Status of GL extension libraries

Posted by dave j on 03 August 2014 - 05:28 AM

The OpenGL APIs are defined in XML specification files these days to allow people to automate the generation of header files. You can find the details here. As well as the XML specs, there's enough documentation and example code that developing something to produce your own core profile version specific header files should be relatively easy.

#5166377 hyphotetical raw gpu programming

Posted by dave j on 12 July 2014 - 04:29 AM

For the gory details of a relatively simple[1] GPU, Broadcom have released documentation for the Raspberry Pi's GPU.

[1] Simpler than the AMD GCN described by phantom at least.

#5135429 Large textures are really slow...

Posted by dave j on 28 February 2014 - 12:45 PM

The tile-based architectures of most mobile GPUs have a different set of optimal use cases compared to more traditional GPUs. Check the advice in Performance Tuning for Tile-Based Architectures from the OpenGL Insights book to make sure you're not doing anything that triggers poor performance.

#5128133 how to prevent save cheating? (for games where saving is NOT allowed)

Posted by dave j on 02 February 2014 - 05:16 AM

I don't think it's a case of making it less easy for them to do as less desirable. If you allow the player to save whenever and wherever they like they'll always be tempted to save just before a difficult bit and reload if they fail. Instead you could have a limited number of save locations that are sufficiently far apart that going back to a saved game would lose a significant amount of progress. This would at least discourage them from going back to a saved game even if it didn't prevent it.

#5106643 Looking for procedural 3D mesh generation resources

Posted by dave j on 03 November 2013 - 05:13 AM

The Virtual Terrain Project is a good place to start. It has a page listing papers on procedural building and city generation. It also contains information about procedurally generating other things such as terrain and plants.

#5095166 BASIC

Posted by dave j on 19 September 2013 - 07:18 AM

Many many years ago I was asked to alter a program written in BASIC by someone who had been learning to program as they went along. It was obvious that they only discovered subroutines part way through when I found the equivalent of the following in several places throughout the code:

10 REM early bit of code
20 GOSUB 40
30 GOTO 60
40 REM stuff they later decided they wanted to use in several places
60 REM some more program
70 GOSUB 40
80 REM rest of program
90 END

#5092965 Best method to learn Java?

Posted by dave j on 10 September 2013 - 04:27 AM

As others have said, forget 3D games for the moment. There are a number of projects that are designed to help teach Java programming by getting you to customise a game. Robocode is one example - you write code to control a robot tank that battles against others. This will not only help you learn programming in Java but also introduce you to some of the concepts of game programming. It doesn't cover that much of Java though so you'll still need to look at other tutorials.

#5089459 How Useful is SVG?

Posted by dave j on 27 August 2013 - 04:48 AM

I think the problem you might have with using SVG directly is rendering speed for use in games. Many mobile GPUs support OpenVG in hardware and Nvidia have an OpenGL extension that can render it which will both help but I don't know how quick they are. For other GPUs there are some libraries that attempt to render SVG or OpenVG using OpenGL (See Sugar and ShivaVG).

The big problem you might face is different rendering speeds for more complex objects. With rasters, everything is just a rectangle so rendering speed is based on size. With vector shapes, more detail, particularly if your shapes have many complex curved paths, clip paths, etc. will take longer to render. You might want artists to avoid using particularly slow to render features.

#5081164 "New" to OOP

Posted by dave j on 28 July 2013 - 04:50 AM

it also helps to use a language that forces you to stay in OOP land such as Java and C#.

I found this. When I first started learning OOP I was trying to do it in C++ having been a very competent C programmer for years. I could never stop automatically thinking of solutions in C. I switched to Smalltalk and all soon became clear. You're probably better off with something like Java today - it wasn't around when I first tried OOP.

#5070804 I Want To Write Embedded Software etc

Posted by dave j on 18 June 2013 - 04:30 AM

The best way would be to get an Arduino or a Raspberry Pi and have a go.

There are other boards that are suitable but both the above have large communities and many resources aimed at those learning.

Embedded implies connecting to hardware, which is the fun bit, so you'll need to know the basics of digital electronics. There are lots of tutorials for both the above boards that explain how to use them to interact with particular sensors/controllers/etc. and will explain the relevant bits of electronics.

#5068242 The documentation says those bits are reserved...

Posted by dave j on 08 June 2013 - 10:08 AM

That won't solve the problem if the library is dynamically linked, though, as soon as you'll roll out a version of the library which actually uses those reserved bits the crappy application will still be using the bits incorrectly and you're back to square one.

Surely the crappy application would never have worked when they tried to use the reserved bits with an earlier version of the dynamic library so they'd have changed it to use another method for their flags.

#5067990 The documentation says those bits are reserved...

Posted by dave j on 07 June 2013 - 06:22 AM

...that must mean we can use them.

Many APIs have flags words to contain a various options. Frequently not all the bits are used. Despite the fact that the documentation mentioned that all unused bits in flag words were reserved and should be set to zero, a GUI project that sat on top of OS/2's Presentation Manager (think Windows GUI - they are almost identical) used the reserved bits for it's own purposes. A few years later IBM changed OS/2 to use some of those bits. Not only did the framework need changing to not use those bits, 600 screens needed updating as well (think changing 600 Windows .RC files).

Top tip:

If you are documenting an API that has flag words, define every single unused bit in every flag word as "must be zero". If you define a standard for unused bits once at the begining of your documentation some idiot will not notice/ignore it.

#5058871 String

Posted by dave j on 03 May 2013 - 04:33 AM

We cannot do your homework for you. However, if you provide what you have so far, and explain where you are having trouble, we would be happy to help.

Yes we can - we can give them wrong answers. :) Maybe then they'll attempt to do their homework for themselves.

#5057687 crashes at glGenBuffers, run time error says "Unhandled exception at 0x53...

Posted by dave j on 29 April 2013 - 02:12 AM

The first parameter to glGenBuffers should be the number of buffers you want to generate not GL_ARRAY_BUFFER.