• Hey, guest user. Hope you're enjoying NeoGAF! Have you considered registering for an account? Come join us and add your take to the daily discourse.

Programming |OT| C is better than C++! No, C++ is better than C

Haly

One day I realized that sadness is just another word for not enough coffee.
Java -> C# is pretty easy, so if you're aiming for Unity development, Java isn't a bad place to start.
 

Bsigg12

Member
Hey guys I'm getting ready to start my computer science classes next fall for a bachelors degree. I have 2 years of school to work through. Haven't decided what I want to specifically do after I finish but any advice on what language(s) I should focus on as a beginner and then build on to hopefully secure a job?
 

Kalnos

Banned
Hey guys I'm getting ready to start my computer science classes next fall for a bachelors degree. I have 2 years of school to work through. Haven't decided what I want to specifically do after I finish but any advice on what language(s) I should focus on as a beginner and then build on to hopefully secure a job?

Don't worry about the language too much. Just find out what it is you want to make and try to do it in any language.
 

Granadier

Is currently on Stage 1: Denial regarding the service game future
once you get to a competent level in any language it should be easy to pick up another language fairly quickly.

This is one of the reasons why I think it's important to focus more on the underlying concepts in the introductory courses instead of focusing on the particular syntax.

But that discussion has been had before.

Don't worry about the language too much. Just find out what it is you want to make and try to do it in any language.

I don't really agree with this. I think you should provide some advice for where he can start. The vast amount of information out there for beginners can become overwhelming very quickly. At least it did for me.

I would suggest starting with Python, but make sure to study what you are doing with the language in depth instead of just writing out code. Take the time to analyze each section you write to know exactly what it's doing. Try and get a program written and running over the summer and know what it's doing under the hood. That will put you at a major advantage when you start school.

That way, once you are comfortable you can easily move on to different languages and feel comfortable.
 

Bsigg12

Member
Don't worry about the language too much. Just find out what it is you want to make and try to do it in any language.

OK, I figure I will learn the basis for coding through my classes so I was just wondering if I should put a focus on a language but figuring out what it is what I want to do first makes more sense. Thanks.
 

Granadier

Is currently on Stage 1: Denial regarding the service game future
OK, I figure I will learn the basis for coding through my classes so I was just wondering if I should put a focus on a language but figuring out what it is what I want to do first makes more sense. Thanks.

Send an email to your professor or the head of the CS department and ask them what language they will be using.
 

Kalnos

Banned
That way, once you are comfortable you can easily move on to different languages and feel comfortable.

I see where you're coming from and agree that Python can be a great language to start with but I guess my point was it depends on what he wants to do since the language is just a means to an end. If he's interested in building websites / web apps then he may want to learn HTML/JavaScript instead, etc.

EDIT: There's a good chance you can also figure out what languages your school will use by going to the course listings and looking at CS 101.
 

Grakl

Member
are any of the lynda courses for basic programming in Python or any other language generally alright? or maybe just fundamental logics -- I'm a math major who's done some javascript and python before, but I haven't had any formal instruction with any programming languages outside of high school, so I'm likely beginning at the fundamentals
 

Water

Member
are any of the lynda courses for basic programming in Python or any other language generally alright? or maybe just fundamental logics -- I'm a math major who's done some javascript and python before, but I haven't had any formal instruction with any programming languages outside of high school, so I'm likely beginning at the fundamentals
While I'm not familiar with Lynda courses, I suspect these are better sources, and also free.

https://www.udacity.com/course/cs101
http://learnpythonthehardway.org/
 

squidyj

Member
It doesn't matter what you call the file you put them in. The only thing that matters is that file is #include'd wherever something wants to use a node<T>. I just call those files *.h, but some people like to call them *.hpp.

All compilers require the template definition to be visible where it's used. That's fundamentally part of the language. However, the biggest thing that putting them in separate files gets you is faster compilation speed and less frequent recompilation. It does not really affect the program itself.



Hmm... All I can say is to double-check that the library is in your library path, and that you're specifying it to be linked into your application. Carefully reviewing the actual build commands being given to msvc / link or gcc / ld can help.

On Ubuntu or Fedora Linux, it's enough just to install glew and add '-lGLEW' to the gcc invocation. That might be all mingw needs, though it might not be (due to differences in where things get installed under Windows vs Linux).


This is what my qmake file looks like, note the include path, depend path and library path, my libraries are where you might expect from this.
Code:
QT       += core gui
QT       += opengl

TARGET = untitled
TEMPLATE = app

SOURCES += main.cpp\
        mainwindow.cpp \
    glwidget.cpp

HEADERS  += mainwindow.h \
    glwidget.h

FORMS    += mainwindow.ui

LIBS += -LD:/glew/lib -lglew32s

INCLUDEPATH += D:/glew/include
DEPENDPATH += D:/glew/include
PRE_TARGETDEPS += D:/glew/lib/glew32s.lib
Code:




Since I'm beginning to run out of time I switche dover to developing this on linux in a vm in which I managed to get glew and qt to work together but now I've got new problems
Code:
mvpLoc = glGetUniformLocation(program, "MVP");
normLoc = glGetUniformLocation(program, "MatNorm");

both uniforms are ready and waiting in my vertex shader but the second get uniform call returns -1 every time. This is what my vertex shader looks like right now.

Code:
in vec3 pos;
in vec3 norm;
in vec2 tex;

uniform mat4 MVP;
uniform mat3 MatNorm;

void main(void)
{
    gl_Position = MVP * vec4(pos, 1);
}
 

Grakl

Member
While I'm not familiar with Lynda courses, I suspect these are better sources, and also free.

https://www.udacity.com/course/cs101
http://learnpythonthehardway.org/
money wise Lynda is free for me -- my school provides it. I'm not a fan of udacity or edx courses, and I've used the HTML book on the second site a bit. I'll do that some more, but I'm still wondering if anyone has used Lynda for anything programming I wise.

Either way I'll be trying Lynda out, hah. Gonna see a few things. Thanks for the resources, though
 

Slavik81

Member
This is what my qmake file looks like, note the include path, depend path and library path, my libraries are where you might expect from this.
Code:
QT       += core gui
QT       += opengl

TARGET = untitled
TEMPLATE = app

SOURCES += main.cpp
        mainwindow.cpp 
    glwidget.cpp

HEADERS  += mainwindow.h 
    glwidget.h

FORMS    += mainwindow.ui

LIBS += -LD:/glew/lib -lglew32s

INCLUDEPATH += D:/glew/include
DEPENDPATH += D:/glew/include
PRE_TARGETDEPS += D:/glew/lib/glew32s.lib
Code:




Since I'm beginning to run out of time I switche dover to developing this on linux in a vm in which I managed to get glew and qt to work together but now I've got new problems
Code:
mvpLoc = glGetUniformLocation(program, "MVP");
normLoc = glGetUniformLocation(program, "MatNorm");

both uniforms are ready and waiting in my vertex shader but the second get uniform call returns -1 every time. This is what my vertex shader looks like right now.

Code:
in vec3 pos;
in vec3 norm;
in vec2 tex;

uniform mat4 MVP;
uniform mat3 MatNorm;

void main(void)
{
    gl_Position = MVP * vec4(pos, 1);
}
I can't recommend ApiTrace enough.
https://github.com/apitrace/apitrace

Unfortunately, it requires building from source. Fortunately, it's not too hard.

Also note that there are functions to read back errors. See the function "compile_shader" here: https://github.com/slavik81/menger/blob/newgl/main.c
 

Granadier

Is currently on Stage 1: Denial regarding the service game future
money wise Lynda is free for me -- my school provides it. I'm not a fan of udacity or edx courses, and I've used the HTML book on the second site a bit. I'll do that some more, but I'm still wondering if anyone has used Lynda for anything programming I wise.

Either way I'll be trying Lynda out, hah. Gonna see a few things. Thanks for the resources, though

I have used Lynda's courses for Android development. I thought they were alright.
 

Rapstah

Member
anyone have any experience with the java ide intellij?

friend was talking about it, seems alright.

I know guys who swear by it. I used it for a short while and the refactoring tools seem really powerful. There's all kinds of shit like automatically creating getters and setters for members but I question how valuable a lot of that is.
 
I know guys who swear by it. I used it for a short while and the refactoring tools seem really powerful. There's all kinds of shit like automatically creating getters and setters for members but I question how valuable a lot of that is.

It's valuable in building up all that base code and tracing down usage when refactoring. It saves a lot of time. For professional development though, it's Jira and source control integration are far more valuable time savers. That Intellij ultimate supports pretty much any major web language is also useful.
 

Granadier

Is currently on Stage 1: Denial regarding the service game future
cool, any specific comments?

Not really. I didn't spend too much time with the courses. They seemed to be pretty similar to just going through the developer site on Google, but in video form.

anyone have any experience with the java ide intellij?

friend was talking about it, seems alright.

I've been using IntelliJ since I first found it a year ago. I wouldn't write Java using anything else.
 
alas i don't think what i do classify as open source :(

think i might mess with it for home use stuff though. their homepage is quite modern design looking which is already a + over most shit lol
 

Onemic

Member
Which philosophy of learning c++ do you guys agree with more and why? the learn C, then slowly transition to C++ style, or the learn c++ straight up style? Thinking of getting C++ Primer to replace my C++ primer plus book which is based on the former style and use that to read up and self teach myself more C++ over the summer.
 

diaspora

Member
I have a somewhat rudimentary problem right now with HTML and JS. While I know how to disable a button, I'm not sure on how to make it conditional.

Right now I've got a form.

Code:
<FORM>
    <input type="text" id="realtxt"/>
    <SELECT id="realitems">
        <OPTION value="1">
        <OPTION value="max">Enter the highest number
        <OPTION value="min">Enter the lowest number
        <OPTION value="guess">Guess a number
    </SELECT>
    <button accesskey="v" id="btnVerify" onclick="result()"> Result </button>
</FORM>

Disabling the button in JS:

Code:
function disable()
	{
		if(document.getElementById("realitems").value === "1")
			document.getElementById("btnVerify").disabled = true;

		else
			document.getElementById("btnVerify").disabled = false;
	};

What I'm assuming is that the value of select is determined by the OPTION value of whatever is chosen in the dropdown menu. If that's true then what I need to make happen those is to execute the JS function in <SELECT> but I'm not sure on how to add the function to it.
 

Kalnos

Banned
Changing your code:

Code:
<FORM>
    <input type="text" id="realtxt"/>
    <SELECT id="realitems" onchange='disable()'>
        <OPTION value="1"></OPTION>
        <OPTION value="max">Enter the highest number</OPTION>
        <OPTION value="min">Enter the lowest number</OPTION>
        <OPTION value="guess">Guess a number</OPTION>
    </SELECT>
    <button accesskey="v" id="btnVerify" onclick="result()"> Result </button>
</FORM>


Code:
function disable()
{
    var mySelect = document.getElementById('realitems');
    if(mySelect.options[mySelect.selectedIndex].value == 1)
    {
        document.getElementById("btnVerify").disabled = true;
    }
    else
    {
        document.getElementById("btnVerify").disabled = false;
    }
}


The 'onchange' attribute that I added to the select will call the disable() method whenever it's changed.

Some of the other additions are just so I could test it in jsfiddle. Which you can see here. I didn't deactivate the button on the initial page load, too lazy. :p
 

xero273

Member
Hi,

Need some help with windows file server and Java. We have a file we are writing to a share drive in windows. There is one letter in the file that is coming out weird. The letter is this:
ö. It is suppose to be an accented o. So i tested this on my local drive. I ftped the file in my code to my local and the accented o displays correctly. When i ftp to the share drive, I get this Ã&#402;³n. I tried encoding the filename in utf8, but I still get the same result. Is there something I am missing here? it looks fine when I ftp to local drive but once I ftp to share drive, it blows up.

Thanks.
 

diaspora

Member
Changing your code:

Code:
<FORM>
    <input type="text" id="realtxt"/>
    <SELECT id="realitems" onchange='disable()'>
        <OPTION value="1"></OPTION>
        <OPTION value="max">Enter the highest number</OPTION>
        <OPTION value="min">Enter the lowest number</OPTION>
        <OPTION value="guess">Guess a number</OPTION>
    </SELECT>
    <button accesskey="v" id="btnVerify" onclick="result()"> Result </button>
</FORM>


Code:
function disable()
{
    var mySelect = document.getElementById('realitems');
    if(mySelect.options[mySelect.selectedIndex].value == 1)
    {
        document.getElementById("btnVerify").disabled = true;
    }
    else
    {
        document.getElementById("btnVerify").disabled = false;
    }
}


The 'onchange' attribute that I added to the select will call the disable() method whenever it's changed.

Some of the other additions are just so I could test it in jsfiddle. Which you can see here. I didn't deactivate it on the initial page load, too lazy. :p

Ahh, so it is like an array. In that case, if I want the blank option to disable the button would I then change ==1 to ==0?
 

Kalnos

Banned
Ahh, so it is like an array. In that case, if I want the blank option to disable the button would I then change ==1 to ==0?

that ==1 is the actual value of the option that you set as 'value = 1'.

You could also change the code I wrote to:
Code:
if (mySelect.selectedIndex == 0)
or yours to:
Code:
if(document.getElementById("realitems").selectedIndex == 0)

in order to do what you just suggested.
 

diaspora

Member
that ==1 is the actual value of the option that you set as 'value = 1'.

You could also change the code I wrote to:
Code:
if (mySelect.selectedIndex == 0)
or yours to:
Code:
if(document.getElementById("realitems").selectedIndex == 0)

in order to do what you just suggested.

Declaring

var mySelect = document.getElementById('realitems');

Outside of any functions but within <script></script> should act as a global variable too yes?
 

sdijoseph

Member
Code:
#include <iostream>
#include <iomanip>
#include "Node1.h"
using namespace std;
using namespace dijoseph;

template<class Item>
void displayPoly(node<Item>* poly);
template<class Item>
Item solve(node<Item>* poly, Item x);
void description(); // Function prototype
void instructions();
template<class Item>
void setPoly(node<Item>*& poly);
int main()
{
	// Declaring variables
	char menu = 'A';
	node<float>* cursor = NULL, *poly2 = NULL, *poly1 = NULL;
	float x;

	cout << fixed << setprecision(1); // IO Manipulation

	description(); // Function call

	while (menu != 'X') // Menu loop
	{

		cout << "\nPlease enter a menu option: ";
		cin >> menu;

		switch (toupper(menu))
		{
		case '1': // 1 for displaying the polynomial
			if (poly1 != NULL)
			{
				listClear(poly1);
			}
			setPoly(poly1);
			break;
		case '2': // 2 for setting the coefficients of the polynomial
			displayPoly(poly1);
			break;
		case '3': // 3 for erasing the coefficients of the polynomial
			if (poly1 != NULL)
			{
				listClear(poly1);
			}
			setPoly(poly1);
			if (poly2 != NULL)
			{
				listClear(poly2);
			}
			setPoly(poly2);
			displayPoly(multiplyPoly(poly1, poly2));
			break;
		case '4': // 4 for adding two polynomials
			if (poly1 != NULL)
			{
				listClear(poly1);
			}
			cout << "Poly has been erased" << endl;
			break;
		case '5': // 5 for solving the polynomial for a value of x
			cout << "Enter a value for x: ";
			cin >> x;

			cout << "The poly resolves to " << solve(poly1, x) << endl;
			break;
		case 'H': // H for instructions on how to properly enter the coefficients of polynomials
			instructions();
			break;
		case 'X':
			exit(1); // Exits program
		default:
			cout << "Invalid entry" << endl; // Error handling
		}
	}

	return 0;
}

Is there a way to change node<float> to something generic, and then request the data type from the user?
 

Slavik81

Member
Instead of a float, use a struct to store a member for each type you want to allow. Then add an enum on the struct to keep track of what type was used.

If you want, you can then optimize its memory usage by using a union.
 

Water

Member
Which philosophy of learning c++ do you guys agree with more and why? the learn C, then slowly transition to C++ style, or the learn c++ straight up style? Thinking of getting C++ Primer to replace my C++ primer plus book which is based on the former style and use that to read up and self teach myself more C++ over the summer.
A large portion of things you have to use to get things done in C is bad style in C++ code. If C++ is what you want to write, learning C first is a total waste of time. If you keep going with C++ you'll learn all the same things eventually but from a better context.
 

tokkun

Member
Is there a way to change node<float> to something generic, and then request the data type from the user?

Templates work well for types that can be determined statically (that is, before you run your program).

On their own, templates are not suited for determining types dynamically (that is, while your program is running - what you want to do by requesting the type from the user). You need to either supplement or replace the use of templates with something else that supports dynamic type checking.

Slavik81 described a method for doing manual type checking using an enum and a union. The other popular alternative is to use automatic type checking via Polymorphism.
 

Onemic

Member
A large portion of things you have to use to get things done in C is bad style in C++ code. If C++ is what you want to write, learning C first is a total waste of time. If you keep going with C++ you'll learn all the same things eventually but from a better context.

Ah, the program I'm taking at my college uses the philosophy of learning C and then learn c++, but slowly transition to using c++ OO tools. We're still using c style null terminated strings exclusively in my C++ class.
 

squidyj

Member
I've managed to solve all of the previous issues I've had with my openGL project but now all of my objects have a gl_FragColor.z value of 1, aka their depth is 1.0f, aka maximum depth which means they are not working correctly.

My initialization of depth testing and matrices wherein nothing is displayed
Code:
	projection = perspective(fov, aspect, 0.01f, 10.0f);
	view = lookAt(eye, vec3(0.0f,0.0f,0.0f), up);
	glEnable(GL_DEPTH_TEST);
	glDepthFunc(GL_LESS);
	glClearDepth(1.0f);

changing the depth function from less to less than or equal to causes everything to be displayed, without the benefit of depth testing of course. Likewise an examination of gl_FragColor.z in the fragment shader confirms every fragment has 1.0f

of course I also call glClear in my rendering function to clear the depth back to 1.0
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

Im using glm for my matrix generation and as far as I can tell i'm using it correctly. My trackball rotation works correctly and all the perspective transformations are correct.

vertex shader
Code:
//input position
in vec3 pos;
//input vertex normal
in vec3 norm;
//TODO texCoord, bitangent, tangent

//output to fragment shader
varying vec3 normal;
varying vec3 lpos;
varying vec3 fpos;


//modelview matrix
uniform mat4 MV;
//projection matrix
uniform mat4 P;
//normal transform matrix
uniform mat3 NML;
//TODO height, normal, albedo, gloss textures
//TODO define and control light on c++ side


void main(void)
{
    //eye space transformation
    fpos = (MV * vec4(pos,1.0f)).xyz;
    //hard-coded light position for now
    lpos = (MV * vec4(2.0f,2.0f,0.0f,1.0f)).xyz;
    normal = NML * norm;
    //project eye space vertex
    gl_Position = P * vec4(fpos,1.0f);
}

Is it possible it's not doing perspective division on its own?
 

CrankyJay

Banned
I've managed to solve all of the previous issues I've had with my openGL project but now all of my objects have a gl_FragColor.z value of 1, aka their depth is 1.0f, aka maximum depth which means they are not working correctly.

My initialization of depth testing and matrices wherein nothing is displayed
Code:
	projection = perspective(fov, aspect, 0.01f, 10.0f);
	view = lookAt(eye, vec3(0.0f,0.0f,0.0f), up);
	glEnable(GL_DEPTH_TEST);
	glDepthFunc(GL_LESS);
	glClearDepth(1.0f);

changing the depth function from less to less than or equal to causes everything to be displayed, without the benefit of depth testing of course. Likewise an examination of gl_FragColor.z in the fragment shader confirms every fragment has 1.0f

of course I also call glClear in my rendering function to clear the depth back to 1.0
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

Im using glm for my matrix generation and as far as I can tell i'm using it correctly. My trackball rotation works correctly and all the perspective transformations are correct.

vertex shader
Code:
//input position
in vec3 pos;
//input vertex normal
in vec3 norm;
//TODO texCoord, bitangent, tangent

//output to fragment shader
varying vec3 normal;
varying vec3 lpos;
varying vec3 fpos;


//modelview matrix
uniform mat4 MV;
//projection matrix
uniform mat4 P;
//normal transform matrix
uniform mat3 NML;
//TODO height, normal, albedo, gloss textures
//TODO define and control light on c++ side


void main(void)
{
    //eye space transformation
    fpos = (MV * vec4(pos,1.0f)).xyz;
    //hard-coded light position for now
    lpos = (MV * vec4(2.0f,2.0f,0.0f,1.0f)).xyz;
    normal = NML * norm;
    //project eye space vertex
    gl_Position = P * vec4(fpos,1.0f);
}

Is it possible it's not doing perspective division on its own?

Man, I do NOT miss this shit. Used to do OpenGL and OpenSceneGraph programming for a defense company.
 

CrankyJay

Banned
I have a somewhat rudimentary problem right now with HTML and JS. While I know how to disable a button, I'm not sure on how to make it conditional.

Right now I've got a form.

Code:
<FORM>
    <input type="text" id="realtxt"/>
    <SELECT id="realitems">
        <OPTION value="1">
        <OPTION value="max">Enter the highest number
        <OPTION value="min">Enter the lowest number
        <OPTION value="guess">Guess a number
    </SELECT>
    <button accesskey="v" id="btnVerify" onclick="result()"> Result </button>
</FORM>

Disabling the button in JS:

Code:
function disable()
	{
		if(document.getElementById("realitems").value === "1")
			document.getElementById("btnVerify").disabled = true;

		else
			document.getElementById("btnVerify").disabled = false;
	};

What I'm assuming is that the value of select is determined by the OPTION value of whatever is chosen in the dropdown menu. If that's true then what I need to make happen those is to execute the JS function in <SELECT> but I'm not sure on how to add the function to it.

Have you tried using jQuery instead of JS?
 

delirium

Member
All these Bitcoin exchanges using MongoDB or some other non ACID complaint DBs.

You would think these programmers would know better.
 

squidyj

Member
Hahaaaaaaaaaaaaaaaa I've lost the plot, my vertex shader is apparently spitting out random crap to my fragment shader dependent on... order of instructions?

So, this code produces a cube with no texturing but normals are correct and the lighting is good.
Code:
in vec3 pos;
in vec3 normal;
in vec2 texCoord;
in vec3 tangent;

//modelview matrix
uniform mat4 MV;
//projection matrix
uniform mat4 P;
//normal transform matrix
uniform mat3 NML;

//output to fragment shader
out vec3 fNormal;
out vec3 light_pos;
out vec3 fPos;
out vec2 fTexCoord;

void main(void)
{
[B]    gl_Position = P * MV * vec4(pos,1);
    fNormal = NML * normal;
    vec3 ohMyGodIBrokeIt = cross(normal, tangent);
    light_pos = (MV * vec4(2, 2, 0, 1)).xyz;
    fPos = (MV * vec4(pos,1.0f)).xyz;
    fTexCoord = texCoord;
[/B]	//project eye space vertex
}

THIS
Code:
    gl_Position = P * MV * vec4(pos,1);
    fNormal = NML * normal;
    light_pos = (MV * vec4(2, 2, 0, 1)).xyz;
    fPos = (MV * vec4(pos,1.0f)).xyz;
    fTexCoord = texCoord;
[B]    vec3 ohMyGodIBrokeIt = cross(normal, tangent);
[/B]
gives a properly textured and lit cube.

THIS
Code:
[B]    fNormal = NML * normal;
[/B]    gl_Position = P * MV * vec4(pos,1);
    light_pos = (MV * vec4(2, 2, 0, 1)).xyz;
    fPos = (MV * vec4(pos,1.0f)).xyz;
    fTexCoord = texCoord;
    vec3 ohMyGodIBrokeIt = cross(normal, tangent);

Causes no vertices to be drawn.
 
All these Bitcoin exchanges using MongoDB or some other non ACID complaint DBs.

You would think these programmers would know better.

Sometimes you make sacrifices for scalability. Granted, there are a few nosql databases such as FoundationDB that are ACID compliant so I'm not really sure if it's a good excuse.
 

Big Chungus

Member
Just finished one of my last programming assignments for this semester and i'm pretty damn happy.

The assignment might seem easy to some of you expert programmers but i'm just glad I got through it.
 

oxrock

Gravity is a myth, the Earth SUCKS!
Just finished one of my last programming assignments for this semester and i'm pretty damn happy.

The assignment might seem easy to some of you expert programmers but i'm just glad I got through it.

I'm no expert, share your epic moment.
 

Water

Member
Ah, the program I'm taking at my college uses the philosophy of learning C and then learn c++, but slowly transition to using c++ OO tools. We're still using c style null terminated strings exclusively in my C++ class.

As you probably guessed from my earlier comment, I think that's a highly unfortunate philosophy for a C++ class to choose - it's the classic mistake of teaching the wrong way first and the right way after, and has other problems as well. Worst case, the class cuts off at a point where they actually haven't yet taught you the right ways of doing things, and feeds the scourge of "C/C++" programmers loose in the wild.
 
I am currently in for a hard-reset of a lot of my "knowledge" when it comes to programming because I have a lot with Verilog to do. Where proper "timing" is essential since most of the work happens at the same time.
 
Hahaaaaaaaaaaaaaaaa I've lost the plot, my vertex shader is apparently spitting out random crap to my fragment shader dependent on... order of instructions

.../snip...

THIS
Code:
    gl_Position = P * MV * vec4(pos,1);
    fNormal = NML * normal;
    light_pos = (MV * vec4(2, 2, 0, 1)).xyz;
    fPos = (MV * vec4(pos,1.0f)).xyz;
    fTexCoord = texCoord;
[B]    vec3 ohMyGodIBrokeIt = cross(normal, tangent);
[/B]
gives a properly textured and lit cube.

THIS
Code:
[B]    fNormal = NML * normal;
[/B]    gl_Position = P * MV * vec4(pos,1);
    light_pos = (MV * vec4(2, 2, 0, 1)).xyz;
    fPos = (MV * vec4(pos,1.0f)).xyz;
    fTexCoord = texCoord;
    vec3 ohMyGodIBrokeIt = cross(normal, tangent);

Causes no vertices to be drawn.

welcome to the awesome world of openGL :) it's hard to help you debug without the rest of the program, it could also be a factor of running on a VM, what kind of GPU access it has or if it's using MESA. have you done the obvious of starting with 'clean' shaders and adding the features in in order? ie. get the fragments on, add lighting, add textures instead of trying to get it all to work at once. also do you have shader compile errors output?
 
Top Bottom