[QUOTE=cartman300;45685567]For example i have vertex data and normal data for these vertices, and if i want to modify these vertices in a vertex shader, how would i get the correct normals after that in shaders? Obviously after modifying vertex position the normal won't stay the same. I'm using OpenGL 3+[/QUOTE]
[url]http://www.arcsynthesis.org/gltut/Illumination/Tut09%20Normal%20Transformation.html[/url]
The tl;dr is use the inverse transpose of the transformation.
How do I find all simple cycles in a graph? Reusing vertices and edges from previous cycles.
Whoops found an article right after posting on just that: [url]http://blog.reactoweb.com/2012/04/algorithm-101-finding-all-polygons-in-an-undirected-graph/[/url]
Hello programmers, I'm a long time lurker of this part of the forum and also a total rookie.
Can a function call another function by reference in c++ ?
It seems to me that it would be the easiest way to check the execution time of many functions, but I don't really know if it's fairy dust or doable.
I'm talking about something like this
[CODE]int timeCheck (otherfunction)
{
interval = time;
// .. calling otherfunction
interval = time - interval;
return interval;
}
execution_time = timeCheck(DrawTexture()); // token function
[/CODE]
I'm all ears !
Yes,
[code]
typedef void (*FuncSig)();
int TimeCheck(FuncSig F) {
<...>
F()
<...>
}
exec_time = TimeCheck(DrawTexture);
[/code]
You can either use function pointers (this) or [URL="http://stackoverflow.com/questions/9568150/what-is-a-c-delegate"]something else[/URL]
Thank you very much this is awesome !
I know this is probably extremely easy, but I'm just drawing a blank at the moment. Given two angles, how can I tell the clockwise difference between the two?
[QUOTE=WTF Nuke;45695648]I know this is probably extremely easy, but I'm just drawing a blank at the moment. Given two angles, how can I tell the clockwise difference between the two?[/QUOTE]
[cpp]// Wraps angles to [0 .. 2pi]
float WrapRadian0(float x)
{
return x - floorf(x / (2.0f * M_PI)) * 2.0f * M_PI;
}
// Compute the clockwise difference of two angles:
float angDiff = WrapRadian0(angTo - angFrom);
[/cpp]
[editline]15th August 2014[/editline]
Assuming you don't need the rotation number as well.
[editline]15th August 2014[/editline]
Because in that case it'd just be subtraction...
How to make windows not instantly closing after debuging them (in visual c++)
[editline]15th August 2014[/editline]
nvm i've learned that ctrl + f5 solves this problem.
Need some help with SQL. I need to convert a name in the format of "Smith, Mr. John Alexander 6356 (John)" to "John Smith". Any help would be great thanks!
I probably have a not so trivial problem... after my gpu in my laptop burned i switched the development of my engine to my new desktop machine... and then suddenly 2 render passes gave up ... i fixed the issue that they caused runtime errors and now the fragment shader just does not draw anything... or the vertex shader is too stupid to output 2 triangles...
(GLSL)
here's one of them:
//deferred ambient pass
//vertex shader
[CODE]
#version 400
void main () {
const vec4 verts[4] = vec4[4](vec4(-1.0, -1.0, 0.5, 1.0),
vec4( 1.0, -1.0, 0.5, 1.0),
vec4(-1.0, 1.0, 0.5, 1.0),
vec4( 1.0, 1.0, 0.5, 1.0));
gl_Position = verts[gl_VertexID];
}
[/CODE]
//fragment shader
[CODE]
#version 400
uniform sampler2D p_tex;
uniform sampler2D n_tex;
uniform sampler2D c_tex;
uniform vec3 ambient;
uniform vec2 win_size;
layout( location = 0 ) out vec4 frag_color;
void main () {
vec2 st;
st.s = gl_FragCoord.x / win_size.x;
st.t = gl_FragCoord.y / win_size.y;
vec4 p_texel = texture (p_tex, st);
// skip background
if (p_texel.z > -0.0001) {
discard;
}
vec4 n_texel = texture (n_tex, st);
vec4 c_texel = texture (c_tex, st);
frag_color.rgb = c_texel.rgb * ambient;
//frag_color.rgb = vec3(1.0,0.0,0.0);
frag_color.a = 1.0;
}
[/CODE]
//CPP code
[CODE]
glBindFramebuffer (GL_FRAMEBUFFER, 0);
glClearColor (0.012, 0.012, 0.012, 1.0f);
glClear (GL_COLOR_BUFFER_BIT);
glEnable (GL_BLEND); // --- could reject background frags!
glBlendEquation (GL_FUNC_ADD);
glBlendFunc (GL_ONE, GL_ONE); // addition each time
glDisable (GL_DEPTH_TEST);
glDepthMask (GL_FALSE);
glActiveTexture (GL_TEXTURE0);
glBindTexture (GL_TEXTURE_2D, fb_tex_p);
glActiveTexture (GL_TEXTURE1);
glBindTexture (GL_TEXTURE_2D, fb_tex_n);
glActiveTexture (GL_TEXTURE2);
glBindTexture (GL_TEXTURE_2D, fb_tex_c);
//deferred render pass... rendering lights, works flawless
[...]
//the color buffer should still be bound and the previously rendered frame wasn't cleared...
//disable stuff so the gl_VertexID var works in GLSL
glBindVertexArray(0);
//VBOs
glBindBuffer(GL_ARRAY_BUFFER, 0);
glDisableVertexAttribArray(0);
glBindBuffer(GL_ARRAY_BUFFER, 0);
glDisableVertexAttribArray(1);
glBindBuffer(GL_ARRAY_BUFFER, 0);
glDisableVertexAttribArray(2);
/////////////////////////////////////////////////////////////////////////////////
///
/// AMBIENT LIGHT PASS
///
///
glUseProgram (DR_AmbientPassProgramIdId);
glPolygonMode(GL_FRONT_AND_BACK, GL_POLYGON);
glUniform2f (win_size_loc_ambientpass, win->getWindowWidth(), win->getWindowHeight());
glUniform3f (color_loc_ambientpass, 0.510, 0.510, 0.508); // ambient color
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
[/CODE]
The uniforms for the programs are set after the shaders got compiled and linked to the program, thats why i don't set the sampler2D uniforms for p_tex (position) , n_tex(normal) and c_tex (color) every frame... and this actually works for the 2nd render pass with lights....
So the problem is... the ambient shader does not brighten up anything ... i tried even to color the complete fullscreenquad red... no success...
any ideas ?
here's an image of all buffers:
[url]http://3devs.bplaced.net/wp-content/uploads/2014/08/deferred-renderer.jpg[/url]
(the black parts in the final output should become visible ... but they do not)
Ok looks like somehow the shader was so stupid enough to optimize out the quad ....
i set up an vao with the correct vbos for triangles and stuff... and passed it to the fullscreen "quad" .. now more a 2 triangle shader
and voila that shit works again ...
[url]http://3devs.bplaced.net/wp-content/uploads/2014/08/ambient-pass.jpg[/url]
[QUOTE=JakeAM;45698009]Need some help with SQL. I need to convert a name in the format of "Smith, Mr. John Alexander 6356 (John)" to "John Smith". Any help would be great thanks![/QUOTE]
What exactly is the format?
Do you want the name in the parentheses, or after "Mr."?
You'll probably need to use regular expressions for it. I assume you use MySQL; it happens to [url=http://dev.mysql.com/doc/refman/5.5/en/regexp.html]have them built in[/url]
So I have a graph of some data, and I want to calibrate that data (multiply it by a gain, and add an offset). My program lets the user click two points on the graph, then write in a box what the value *should* be at those two points. So I have the actual current value at the those points, and also the value it should be. How can I go from that to working out the actual gain and the offset needed?
[QUOTE=proboardslol;45687234]So I posted this in WAYWO[/QUOTE]
Not sure if it's too late and you probably figured something out (which you probably did) but you could just do exactly what Nintendo did and turn it into Pikmin, so that each Mario helps the nearest Mario carry the block to his desired location, adding +.5 speed for each Mario. Obviously this would break your code, since they'd occasionally get to their location and teeter overtop of it, you only use ints, and so forth, so you'd need to fix that.
Help! How to solve this problem??
[IMG]http://i.imgur.com/59KEs65.png[/IMG]
I've replaced Pulse Rifle in HL2 with OICW and it works fine in player's hands, but NPCs don't fire it for some reason. They just play firing animation and that's it, no muzzle flash, no brass shells ejecting, despite the fact that all required animation events are specified in W_ar2's .qc file.
Here's .qc file, it looks fine to me: [url]http://pastebin.com/hfTAXyWx[/url]
Here's weapon_ar2.cpp: [url]http://pastebin.com/n1iHt84h[/url]
I really have no idea why NPC's don't fire.
[QUOTE=Mobon1;45725959]Not sure if it's too late and you probably figured something out (which you probably did) but you could just do exactly what Nintendo did and turn it into Pikmin, so that each Mario helps the nearest Mario carry the block to his desired location, adding +.5 speed for each Mario. Obviously this would break your code, since they'd occasionally get to their location and teeter overtop of it, you only use ints, and so forth, so you'd need to fix that.[/QUOTE]
that'd be cool to do in the long-run but I'd have to dramatically re-work the code. Currently the code is really simple actually. it goes like this
1. A text file is read which has an ASCII art of the words NVCC STEM CLUB
2. for the position of each "pixel" in the ASCII art a block and a mario are created in an array.
3. the block and mario are given random coordinates to start art, and are given the coordinates of where the block is SUPPOSED to go to.
4. mario goes to where the block IS and grabs it
5. once he grabs it, the MARIO_GRABBING Boolean is set to true and he now must find where the block is supposed to go
6. once he reaches where the block is SUPPOSED to go, he drops it and runs off screen
So each mario has a specific block that he must grab. I did this because the language I'm using is stupid (FreeBASIC) and I'm only really using it as a hobby. an Object-oriented language would make it infinitely easier to detect whether something can be picked up or not
Trying to start work on an Android app. Haven't done much on Android in a long while.
Was wondering, how would you go about getting started with material design. Want to incorporate it into the app but can't find much tutorials on it or anything? And can't find any of the material design stuff in Android studio
[QUOTE=Nik1895;45726091]I've replaced Pulse Rifle in HL2 with OICW and it works fine in player's hands, but NPCs don't fire it for some reason. They just play firing animation and that's it, no muzzle flash, no brass shells ejecting, despite the fact that all required animation events are specified in W_ar2's .qc file.
Here's .qc file, it looks fine to me: [url]http://pastebin.com/hfTAXyWx[/url]
Here's weapon_ar2.cpp: [url]http://pastebin.com/n1iHt84h[/url]
I really have no idea why NPC's don't fire.[/QUOTE]
Seems like it's a problem with a model as the weapon works fine if I use a different world model
[QUOTE=Fourier;45726028]Help! How to solve this problem??
[IMG]http://i.imgur.com/59KEs65.png[/IMG][/QUOTE]
Not using SVN would be a start :v:
(I realise this is probably some existing thing.)
Anyway, it seems like the problem isn't on your end so it's unlikely you can fix it.
For some reason I cannot instantiate a vector of unique_ptr of a class that I created. It says
[code]error C2280: 'std::unique_ptr<DCELHalfEdge,std::default_delete<_Ty>>::unique_ptr(const std::unique_ptr<_Ty,std::default_delete<_Ty>> &)' : attempting to reference a deleted function e:\microsoft visual studio 12.0\vc\include\xmemory0[/code]
I have no idea why, I have a default constructor and assignment constructor, as well as move constructors. I haven't explicitly deleted anything. I even tried not defining any constructors, to no avail. This is Visual Studio 2013 November CTP.
Oh ok I figured it out. I needed a move constructor of the class that contained the vector. One is supposed to be generated for you in this case, but VS2013 doesn't do that.
i've been trying to implement assimp for like 2 weeks now, but i'm having a problem that i just can't work out. i'm loading an .obj and it seems to work fine, but only a few of the vertices are actually loading.
this is what i'm getting from [URL="http://webgl-tests.crbs.ucsd.edu/obj-viewer/?model=sample"]sphere.obj[/URL]
[IMG]http://i.gyazo.com/10602a9baab85ccce721a6e07d8e0175.gif[/IMG]
and this is the c++ assimp code
[CODE]
// these structs are actually in a .h file, but i included them here for clarity
struct gl_vec3
{
float x;
float y;
float z;
gl_vec3(float _x, float _y, float _z) : x(_x), y(_y), z(_z) {}
};
struct gl_vec2
{
float x;
float y;
gl_vec2(float _x, float _y) : x(_x), y(_y) {}
};
struct gl_vertex
{
gl_vec3 pos;
gl_vec2 tex;
gl_vec3 norm;
gl_vertex(gl_vec3 p, gl_vec2 t, gl_vec3 n) : pos(p), tex(t), norm(n) {}
};
void StaticModel::load(const std::string& filename)
{
Assimp::Importer importer;
const aiScene* scene = importer.ReadFile(filename,
aiProcess_Triangulate |
aiProcess_GenSmoothNormals |
aiProcess_GenUVCoords);
if(!scene)
{
printf("Error parsing '%s': '%s'\n", filename, importer.GetErrorString());
return;
}
m_meshes.resize(scene->mNumMeshes);
m_textures.resize(scene->mNumMaterials);
for(unsigned int i = 0; i < scene->mNumMeshes; i++)
{
const aiMesh* pmesh = scene->mMeshes[i];
const aiMaterial* pmat = scene->mMaterials[i];
GLMesh mesh;
GLTexture texture;
std::vector<gl_vertex> vertices;
std::vector<GLuint> indices;
const aiVector3D vzero(0.0f, 0.0f, 0.0f);
// import vertices from the aiMesh
for(unsigned int n = 0; n < pmesh->mNumVertices; n++)
{
const aiVector3D* position = &(pmesh->mVertices[n]);
const aiVector3D* normal = &(pmesh->mNormals[n]);
const aiVector3D* texcoord = pmesh->HasTextureCoords(0) ? &(pmesh->mTextureCoords[0][n]) : &vzero;
vertices.push_back(gl_vertex(
gl_vec3(position->x, position->y, position->z),
gl_vec2(texcoord->x, texcoord->y),
gl_vec3(normal->x, normal->y, normal->z)
));
}
// import indices
for(unsigned int n = 0; n < pmesh->mNumFaces; n++)
{
const aiFace& face = pmesh->mFaces[n];
assert(face.mNumIndices == 3);
indices.push_back(face.mIndices[0]);
indices.push_back(face.mIndices[1]);
indices.push_back(face.mIndices[2]);
}
std::cout << pmesh->mNumVertices << " " << pmesh->mNumFaces << std::endl;
std::cout << vertices.size() << " " << indices.size() << std::endl;
mesh.buffer(vertices, indices);
m_meshes.push_back(mesh);
}
}
[/CODE]
i'm completely stuck. i've tried [URL="http://i.gyazo.com/5621f9ba5580ec165615d096dcec9256.png"]multiple[/URL] [URL="http://i.gyazo.com/2a4de497248c54dfc88317ffa2aa9e29.gif"].obj[/URL] [URL="http://i.gyazo.com/0cfd5dc6310739b3b7b812046f5789ee.png"]files[/URL], but it seems like they're all missing vertices. i've also tried rendering without using element buffers but that didn't change much either. any help would be appreciate, and i can post the source on github if it helps.
Hello guys,
As I'm an masochist Iv'e decided to play around with OpenGL (to the end of a little 2D game /demo) [i]without[/i] using any library (OpenTK and the like); the reason being i just want to learn about OpenGL and the rest, not produce anything worthwhile.
Iv'e got a problem, however, that I can only seem to squeeze ~60 fps while doing basically nothing (a textured square).
I'm using a call to PeekMessage to check for tings in the message pump, if not, run the 'tick' function in a while loop (seems to be a common approach).
Here's the 'tick' function:
[Code]
Stopwatch wall;
TimeSpan
currentTime = TimeSpan.Zero,
accumulator = TimeSpan.Zero,
timestep = new TimeSpan(0,0,0,0,8);
void Tick()
{
var newTime = wall.Elapsed;
accumulator += newTime - currentTime;
currentTime = newTime;
Update();
while (accumulator >= timestep)
{
UpdateGameState(timestep);
accumulator -= timestep;
}
Render();
}
[/code]
pretty simple stuff.
and 'Render'
[Code]
RenderingContext.Clear(GL.ClearBufferMask.GL_COLOR_BUFFER_BIT);
GL.Begin(GL.BeginMode.GL_QUADS);
GL.TexCoord(0, 0); GL.Vertex(transformedSquare[0].X, transformedSquare[0].Y);
GL.TexCoord(1 / 8d, 0); GL.Vertex(transformedSquare[1].X, transformedSquare[1].Y);
GL.TexCoord(1 / 8d, 1 / 8d); GL.Vertex(transformedSquare[2].X, transformedSquare[2].Y);
GL.TexCoord(0, 1 / 8d); GL.Vertex(transformedSquare[3].X, transformedSquare[3].Y);
GL.End();
Context.SwapBuffers();
[/Code]
The result:
[IMG]http://i.imgur.com/bHSiYUm.png[/IMG]
All of the OpenGL calls are just P/Invoked like so:
[code]
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport(GDI32_LIBRARY_NAME, EntryPoint = "SwapBuffers")]
public static extern bool SwapBuffers(HDC hDC);
[/code]
any ideas? (I can upload all the source if needs be), thanks
[editline]19th August 2014[/editline]
The rotation is also juttery, but I'm guessing that can be sorted with some lerping (using the remaining time in the accumulator)
[editline]19th August 2014[/editline]
Seems to be that removing the SwapBuffers call puts it back up to < 0.001 ms/frame.
Some VSync issue? any information is welcomed :)
Are you allowed to have std::list or std::vectors of incomplete types? It seems that the committee disallowed it for historical reasons as well as recursiveness, but it seems that these restrictions have been slackened in C++11. Am I right in this assumption? It compiles fine in VS2013 November CTP, but I'm afraid of causing undefined behaviour.
Hey, so I wanted to give game development a go after a few years experience in programming C#/Java and c++. I was wondering if there is like a modern guide to game development anyone recommends? It will be a game similar to like Baldur's Gate Dark Alliance and Diablo probably be done in unity.
Basically I want like a step by step guide to making a game.
Thanks guys.
[QUOTE=Two-Bit;45745022][...]
Basically I want like a step by step guide to making a game.
[...][/QUOTE]
I very much doubt something like that exists. If it did you could input that into the computer instead and programming the game would be unnecessary.
I just don't know where to begin, how to build the skeleton of the game so to speak, how to have a rough game then be able to add the features and all that in.
Sorry if this is the wrong place, but some time ago in waywo someone posted something about a markup fork that was made for use with consoles (you know unix shell, cmd and all that) it even included things like graphs and tables
Does anyone remember that?
[QUOTE=Lemmingz95;45737663]Hello guys,
As I'm an masochist Iv'e decided to play around with OpenGL (to the end of a little 2D game /demo) [i]without[/i] using any library (OpenTK and the like); the reason being i just want to learn about OpenGL and the rest, not produce anything worthwhile.
Iv'e got a problem, however, that I can only seem to squeeze ~60 fps while doing basically nothing (a textured square).
[...]
[/QUOTE]
if you have vsync on, you wont get a framerate beyond your sync rate :)
Edit:
only if you calculate your framerate wrong.
I have a question regarding Java.
I'm trying to make a sort of guessing game with a while loop and I would like some help on what I'm doing wrong.
[code]
import java.util.Scanner;
public class GuessingGameV1
{
public static void main(String[] args)
{
Scanner in = new Scanner(System.in);
int randomNumber = 0;
int guess = 0;
while(guess > randomNumber || guess < randomNumber)
{
System.out.println("Enter your guess: ");
guess = in.nextInt();
randomNumber = Math.random;
if(guess > randomNumber)
{
System.out.println("Your guess was too high :(");
}
else if (guess < randomNumber)
{
System.out.println("Your guess was too low :(");
}
else if (guess == randomNumber)
{
System.out.println("You guessed correctly! :)");
}
}
System.out.println("Congratulations!");
}
}
[/code]
it says it cannot find variable Math.random even though thats what is used to generate a random number... right?
Also, I want the randomly generated number to be between 1 and 100, how would I type that out?
And am I using the while loop correctly for this because I want it to be so you keep inputting numbers until you get it right and the program stops.
[QUOTE=joshuadim;45750107]I have a question regarding Java.
I'm trying to make a sort of guessing game with a while loop and I would like some help on what I'm doing wrong.
[code]
import java.util.Scanner;
public class GuessingGameV1
{
public static void main(String[] args)
{
Scanner in = new Scanner(System.in);
int randomNumber = 0;
int guess = 0;
while(guess > randomNumber || guess < randomNumber)
{
System.out.println("Enter your guess: ");
guess = in.nextInt();
randomNumber = Math.random;
if(guess > randomNumber)
{
System.out.println("Your guess was too high :(");
}
else if (guess < randomNumber)
{
System.out.println("Your guess was too low :(");
}
else if (guess == randomNumber)
{
System.out.println("You guessed correctly! :)");
}
}
System.out.println("Congratulations!");
}
}
[/code]
it says it cannot find variable Math.random even though thats what is used to generate a random number... right?
Also, I want the randomly generated number to be between 1 and 100, how would I type that out?
And am I using the while loop correctly for this because I want it to be so you keep inputting numbers until you get it right and the program stops.[/QUOTE]
First off, I think there is a special import in order to use that math class, but I could be wrong. It's been a while since I've touched it.
Secondly, you are using it wrong. This is what you should do:
[CODE]Random rand = new Random(); // create a new random.
int number = rand.nextInt(100) + 1; // get a random number between 1 and 100.[/CODE]
Third, your loop seems to be in need of a few modifications. You can simplify the loop itself by doing this:
[CODE]
while(guess != randomNumber)
[/CODE]
and you are getting a new random number every time the loop runs, which means that the player is just guessing at a different number each time. Once you fix your random number generation (shown above) you would place it outside and above the while loop so that at the start of the game, it would generate one random number for the entire game.
Lastly, in this if block:
[CODE]
else if (guess == randomNumber)
{
System.out.println("You guessed correctly! :)");
}
[/CODE]
You are checking if the place has won the game. In order to break out of the while loop and display congratulations, you would have to place a break; after the println. This should exit the while loop and display "Congratulations".
Sorry, you need to Log In to post a reply to this thread.