Jump to content

  • Log In with Google      Sign In   
  • Create Account

14 years ago on June 15th Gamedev.net was first launched! We want to thank all of you for being part of our community and hope the best years are ahead of us. Happy birthday Gamedev.net!

zacaj

Member Since 18 Sep 2008
Offline Last Active Today, 12:19 AM
*****

#4915044 Help with for loops and strings when loading files.

Posted by zacaj on 20 February 2012 - 08:40 PM

You could always cast it. In my opinion that'd still look a lot better than instantiating a whole new class just to concatenate a string


#4905942 Multidimensional Arrays for a Rogue-Like Map?

Posted by zacaj on 24 January 2012 - 06:03 PM

First of all, if you use 2D arrays youre going to have to set your size in advance (when you compile) which might be limiting. Its better to dynamically allocate a single dimensional array of size w*h and then access it with x+y*w. As to printing it, cant you just use two nested for loops? Im not sure how youd clear the screen though


#4905206 OpenGL tutorials that aren't deprecated?

Posted by zacaj on 22 January 2012 - 03:03 PM

arcsynthesis.org/gltut/


#4875506 An efficient way to find a string in a file!

Posted by zacaj on 22 October 2011 - 08:26 PM

There's no specific functions for that, the f* functions don't deal with what's in the files, just read the data in. There is a str* function that searches for one string in another, you could read in the whole file and then use that, but tge file couldn't be very big for that to be practical


#4868716 Putting Models on Terrain Surface

Posted by zacaj on 03 October 2011 - 03:44 PM

As long as you can choose just one point on your model to be its 'bottom,' using the ray casting technique is actually really simple to write. Just look up 'point in triangle test' and test your triangles top down, interpolating the heights of the three corners of the triangle you find


#4850365 Best library for doing text in OpenGL

Posted by zacaj on 17 August 2011 - 09:41 AM

In that case, youre going to have trouble finding any libraries. I had this problem a few months ago, and if I remember, I only even found one library that supported 3.0+ (3/4 should be compatable) Im trying to find that one, but Im not having much luck. Your best bet is to just write something yourself, its only like 300 lines of code for a complete text class

EDIT: http://www.lighthouse3d.com/very-simple-libs/vsfl/


#4849999 Best library for doing text in OpenGL

Posted by zacaj on 16 August 2011 - 01:36 PM

Its surprisingly easy to write your own using Freetype. If youre looking for a regular library, well also need to know what version of openGL youre targetting. Most dont work with 1,2,3, and 4


#4849673 Nub question about srand/rand

Posted by zacaj on 15 August 2011 - 08:36 PM

Basically, rand doesnt actually generate a random number. Basically, rand() generates a new number based on the last number generated, so each time you call rand() you get a new number, but the first time you call rand(), it always uses the same number, so you always get the same set of numbers. srand changes that last number to whatever you give it as an argument. WHen you call srand(time), it takes the current time(which is obviously unique), and uses it for the next rand() call, so you wont ever get the same sequence of numbers. You only ever need to call srand() once per program execution.


#4845866 What are array indices? What's their advantage over vertex array data?r

Posted by zacaj on 07 August 2011 - 01:19 PM

It depends on the GPU partially, because some might be more optimized for a certain type, but you cant easily control for that. Basically, just keep in mind: a vertex is 3/4 floats, and each float is 4 bytes, and unsigned int is 4 bytes(you could also use shorts or chars, if you have a simpler model). Just think when youre programming each thing: In general, which will take less space?


#4845847 What are array indices? What's their advantage over vertex array data?r

Posted by zacaj on 07 August 2011 - 11:52 AM

The last parameter of elements isnt anything from arrays, its an array of unsigned ints, the order of the vertices to draw
for instance:
With glDrawArrays:
vertices:
-1,-1
-1,1
1,1
1,1
1,-1
-1,-1
glDrawArrays(GL_TRIANGLES,0,6)
With glDrawElements
vertices:
-1,-1
-1,1
1,1
1,-1
indices:(unsigned int[6])
0,1,2 ,2,3,0
glDrawElements(GL_TRIANGLES,6,UNSIGNED_INT,indices);
The indices correspond to the numbers of the vertices


#4845835 What are array indices? What's their advantage over vertex array data?r

Posted by zacaj on 07 August 2011 - 11:19 AM

Indices are just numbers. (plural of index). And index of 0 would correspond to the first vertex, 5 would be the sixth, etc. That way, you only have to send unique vertices to the GPU, since most vertices are shared by more than one face


#4845550 To goto or not to goto?

Posted by zacaj on 06 August 2011 - 03:23 PM

I find them useful to do cleanup in functions that can fail, so I dont have to free all the resources everywhere, I can just goto the end, and put all the frees there


#4842741 Selecting OpenGL Version (Windows VC++ 2010)

Posted by zacaj on 30 July 2011 - 10:44 PM

Youll need to use a library like GLEW or GLee to add all the functions not in 1.1


#4842400 OpenGL Cubes

Posted by zacaj on 29 July 2011 - 08:18 PM

Check out this post, it talks about removing "buried cubes"
http://www.sea-of-memes.com/LetsCode1/LetsCode1.html

Much of the slowdown youre getting is probably coming from call overhead. Although the games draw alot more triangles than you are, they draw them in bigger batches, so theres not as much superfluous data going around. You might want to try to implement geometry instancing, it should help a lot with the frame rate. Are all your cubes textured the same? How many calls are you doing per cube?


#4839617 Loading different texture formats

Posted by zacaj on 24 July 2011 - 09:28 AM

What browser are you using? Have you tried others?




PARTNERS