Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


zacaj

Member Since 18 Sep 2008
Offline Last Active Sep 28 2013 03:05 PM

#4933548 Can I use native code in developing for android?

Posted by zacaj on 21 April 2012 - 10:54 AM

You can (especially if you're using openGL) basically write almost your whole app in C(or C++, but beware of no STL) fairly easily. Once you get it set up, it basically boils down to naming your C functions a certain way and also declaring them a certain way in your Java code so it can call them. (C calling Java is a bit more complicated though). You have Java get input and then just call a C function with the input, and let your C code handle all the game and drawing. The main thing to be aware of is that (unless they've changed it) you have to compile the C code on the command line, then go to Eclipse and refresh it so it sees the new dynamic library and then run your Java compile to test the C code, and debugging native code is also very complex. The only Android app I've made wasn't very processor intensive, so I can't speak as to the overhead involved, but I doubt it's that much.


#4919602 Multiple light sources

Posted by zacaj on 05 March 2012 - 04:24 PM

Ok, feel free to PM me or something if this topic gets buried :)


#4916071 how to return different types?

Posted by zacaj on 23 February 2012 - 08:24 PM

struct typea
int type
String something

Struct typeb
int type
float somenumber

Struct basetype
int type

basetype* function
if something
typea *ret=malloc(typea) ;
ret.type=1
return ret


basetype *xml=function ()
if xml.type=1
typea *a=(typea*) xml


#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




PARTNERS