Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 ... 251 252 [253] 254 255 ... 796

Author Topic: if self.isCoder(): post() #Programming Thread  (Read 830894 times)

GlyphGryph

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #3780 on: January 29, 2013, 02:37:33 pm »

And Perl is compiled, but most people seem to think that's a scripting language.

Personally, I think the division is pretty damn arbitrary. I'd be fine with going with the use-case definition Morley defined - so very few languages are "scripting languages", as in being limited to that, but many if not most languages can be USED as a scripting language. You CAN run C++ without compiling it after all, if not as easily as Java, so even C++ could be a scripting language if you really wanted it to be. And Javascript can be used to write full-featured applications that certainly go well beyond the definition of what most people would describe as scripting.

Some languages just make scripting /easier/. It just bugs me when people use the term to basically put down a language that people don't like and thus is somehow less than a "real" programming language. I guess I read MadocComadrin as saying that a scripting language is fine for beginners but once they get some experience they should switch to a "programming" language because they'd be better off.
« Last Edit: January 29, 2013, 02:45:26 pm by GlyphGryph »
Logged

eerr

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #3781 on: January 29, 2013, 03:16:29 pm »

As long as you ignore the fact that it is a terrible scripting language, Java is a great scripting language.

I think you lost me.

Scripting is code for good linking.

Not simply linking, which must exclusively be done in c or c++.
Or through a wrapper written in c, c++ or assembly.

Scripting language is lingua fracais for good boiler plating and good organization.
Logged

GlyphGryph

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #3782 on: January 29, 2013, 03:30:57 pm »

... what?
Logged

MadocComadrin

  • Bay Watcher
  • A mysterious laboratory goblin!
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #3783 on: January 29, 2013, 07:29:35 pm »

Quote
Err... Java IS a scripting language, isn't it? Like Ruby or Lisp, a LOT of higher level languages are scripting languages, i.e. they can be/are run through an interpreter.
Other people have hit the nail on the head. Just interpretation (or JiTC) doesn't make something a scripting language. The term isn't well defined, but I tend to think of scripting languages having two qualities:

Very high level--a person only needs to really be concerned with what they want done, instead of what's going on under the hood.
And more importantly, they are more likely to have their interpreter used by an application to define content or non-core behavior, and is less likely to be used to develop large applications.

Ruby, Lua and Python fit this definition pretty well, and while Java may skirt into this territory (usually in regards to web design), it has too much functionality outside of it to really call it a scripting language.
Logged

Valid_Dark

  • Bay Watcher
  • If you wont let me Dream, I wont let you sleep.
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #3784 on: January 30, 2013, 03:05:08 am »

since I can't find a good tutorial on using OpenGL with SDL, i'm picking apart an open source tetris clone I found.
Reverse engineering is going well, and I'm learning some things, but there are some things that I don't understand why he/she did.

Like for all of the class constructors he has void in the parenthesis, why would you do this?

Quote
class Visuals
{
public:

   Visuals(void);
   virtual ~Visuals(void);

also, from that same example, he has the deconstructor as a virtual function,
I've yet to learn about virtual functions, can anyone tell me why he did this  this way?

if I run into anything else I don't understand while picking apart this code I'll ask, but for now this is it.


Also, glOrtho,  the values for it describe the window resolution, not the window size, right?

prefer answer from someone with OpenGL 2D experience.
« Last Edit: January 30, 2013, 03:23:05 am by Valid_Dark »
Logged
There are 10 types of people in this world. Those that understand binary and those that don't


Quote
My milkshake brings all the criminals to justice.

Siquo

  • Bay Watcher
  • Procedurally generated
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #3785 on: January 30, 2013, 03:38:50 am »

Like for all of the class constructors he has void in the parenthesis, why would you do this?
Quote from: Stackoverflow
In C, the declaration int f(void) means a function returning int that takes no parameters. The declaration int f() means a function returning int that takes any number of parameters. Thus, if you have a function that takes no parameters in C, the former is the correct prototype.

In C++, I believe int f(void) is deprecated, and int f() is preferred, as it specifically means a function that takes no parameters.

also, from that same example, he has the deconstructor as a virtual function,
Otherwise you can't use a destructor in derived classes. Stupid, because why wouldn't you want that, but the short version is: if you're a base class, virtual your destructor.
Logged

This one thread is mine. MIIIIINE!!! And it will remain a happy, friendly, encouraging place, whether you lot like it or not. 
will rena,eme sique to sique sxds-- siquo if sucessufil
(cant spel siqou a. every speling looks wroing (hate this))

Valid_Dark

  • Bay Watcher
  • If you wont let me Dream, I wont let you sleep.
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #3786 on: January 30, 2013, 03:51:13 am »

Thank you Mr.Siquo for the fast response.

now I just need an OpenGL guru to stop by / take me as an apprentice.  I'm having a few OpenGL questions, and google isn't helping very much in answering them.
Logged
There are 10 types of people in this world. Those that understand binary and those that don't


Quote
My milkshake brings all the criminals to justice.

RulerOfNothing

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #3787 on: January 30, 2013, 04:16:01 am »

Actually, glOrtho specifies the window's size (although I don't think window resolution becomes a factor until after the vertices are transformed). I might be able to help with other OpenGL questions, but I don't have as much experience with OpenGL as I would have liked.
Logged

Valid_Dark

  • Bay Watcher
  • If you wont let me Dream, I wont let you sleep.
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #3788 on: January 30, 2013, 05:00:46 am »

Actually, glOrtho specifies the window's size (although I don't think window resolution becomes a factor until after the vertices are transformed). I might be able to help with other OpenGL questions, but I don't have as much experience with OpenGL as I would have liked.

more research on the topic shows that it's not the really the windows size, as that is set through a SDL command,
Quote
now we setup the viewport for opengl using glOrtho. This, in essence, is the window area OpenGL will use. If you set it smaller to the SDL window size you'll have black borders, and if you set it larger then the SDL window, you'll have your view clipped. Usually, this will always be the same as the regular window size, but there are certain cases you would want it smaller (you can actually create multiple viewports, and have them all display different camera angles of a single scene). Arguments are X, Y, Width, Heigh

looks like I found a decent tutorial,  but if I have any further questions I'll pm them to you I guess.
Logged
There are 10 types of people in this world. Those that understand binary and those that don't


Quote
My milkshake brings all the criminals to justice.

Mego

  • Bay Watcher
  • [PREFSTRING:MADNESS]
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #3789 on: January 30, 2013, 05:16:34 am »

Like for all of the class constructors he has void in the parenthesis, why would you do this?
Quote from: Stackoverflow
In C, the declaration int f(void) means a function returning int that takes no parameters. The declaration int f() means a function returning int that takes any number of parameters. Thus, if you have a function that takes no parameters in C, the former is the correct prototype.

In C++, I believe int f(void) is deprecated, and int f() is preferred, as it specifically means a function that takes no parameters.

It was clarified in the comments to that post, so I'll clarify it here, too: int f(void) is not deprecated in C++. It means literally the same thing to the compiler as int f() does. So, it's a relic of C, but not a bad relic.

Valid_Dark

  • Bay Watcher
  • If you wont let me Dream, I wont let you sleep.
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #3790 on: January 30, 2013, 05:25:37 am »

some tutorials suggest using
glEnable(GL_TEXTURE_2D);

after setting glMatrixMode(GL_MODELVIEW);
 
but before
 
glLoadIdentity();


and some tutorials say to use

glDisable(GL_DEPTH_TEST);
after setting matrixmode to modelview and doing glLoadIdentity.

what exactly do these 2 things do, and why are there 2 methods, pros/cons of each?  anyone have any input?
Logged
There are 10 types of people in this world. Those that understand binary and those that don't


Quote
My milkshake brings all the criminals to justice.

RulerOfNothing

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #3791 on: January 30, 2013, 05:43:16 am »

glEnable(GL_TEXTURE_2D) causes OpenGL to do 2D texturing (OpenGL is also capable of drawing simple shaded polygons)
glMatrixMode sets the matrix that future matrix operations act on. GL_MODELVIEW represents the matrix that affects how objects are transformed in 3D space (as opposed to the projection matrix, which affects how points in 3D space are transformed into points on the screen)
glLoadIdentity sets the current matrix to the identity matrix (which in the context of OpenGL is a matrix that does not affect input values)
glDisable(GL_DEPTH_TEST) causes OpenGL to not perform depth testing, which is used in 3D graphics to determine whether or not 3D objects are in front of already drawn objects or not. Evidently in a 2D program depth testing is of reduced utility.
Does this help?
Logged

Valid_Dark

  • Bay Watcher
  • If you wont let me Dream, I wont let you sleep.
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #3792 on: January 30, 2013, 02:38:07 pm »

Yeah, so in a 2D project, I should do GL_TEXTURE_2D instead of DEPTH_TEST, right?

and (I'm not sure how to word this)
it's like the modelview matrix and the projection matrix are always there, not enabled by setting the MatrixMode, matrixmode just changes which matrix you're editing,
thats why you change the matrixmode to projection, then do the GlOrtho, then you LoadIdentity then switch the matrixmode to modelview, right?
I'm still not exactly sure what LoadIdentity does, or what the Identity matrix is.  Maybe you could explain that in further detail?
Logged
There are 10 types of people in this world. Those that understand binary and those that don't


Quote
My milkshake brings all the criminals to justice.

RulerOfNothing

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #3793 on: January 30, 2013, 04:59:00 pm »

In computer graphics, transforms of objects (such as rotation and translation) are performed by multiplying the position vector of the vertices of the object by the modelview matrix. The identity matrix is simply a matrix that leaves the vector unchanged when it is multiplied by the matrix (so it is a matrix analogous to the number 1).
Logged

Virex

  • Bay Watcher
  • Subjects interest attracted. Annalyses pending...
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #3794 on: January 30, 2013, 05:41:36 pm »

As RulerOfNothing said, in graphics, you're generally dealing with vectors and matrices. Vectors represent for example the actual position of vertices w.r.t. a reference point, or the placement of a texture on a model. Nearly all operations you'll ever want to do on your objects can be represented as matrices. Multiplying a vector with said matrix then results in a vector with the operation associated with said matrix applied to it. Matrices have several very convenient properties, which is why they're used so ubiquitously. For example, multiplying two matrices (that can be multiplies, which does not apply to all matrices) results in a new matrix that corresponds to the two operations associated with the original matrix applied one after the other, allowing you to build reusable, compound operations. Another advantage is that the matrices used for graphics programming are usually invertible, meaning you can create matrices that undo each other. In this framework, the identity matrix is just the 'do nothing' matrix.
Logged
Pages: 1 ... 251 252 [253] 254 255 ... 796