It's all depending on what he wants exactly. Maybe elaborate, Kialtia?
[QUOTE=Meatpuppet;38331501]I put 'x' and 'y' in, and it just makes a bigger and bigger square for bigger values. This is what they mean, right?
[/QUOTE]
Drawing numerous squares of one color looks like one larger square.
[QUOTE=ahdge;38339158]Drawing numerous squares of one color looks like one larger square.[/QUOTE]
I know.
What are the best online Lua resources for learning it? I am attempting to mod NS2 and the documentation for it is less than fantastic (actually it pretty much does not exist).
[QUOTE=hogofwar;38339472]What are the best online LUA resources for learning it? I am attempting to mod NS2 and the documentation for it is less than fantastic (actually it pretty much does not exist).[/QUOTE]
[b]Lua[/b] has a pretty decent [url=http://www.lua.org/manual/]reference manual[/url].
[QUOTE=MakeR;38339510][b]Lua[/b] has a pretty decent [url=http://www.lua.org/manual/]reference manual[/url].[/QUOTE]
Not sure why I capitilised it, I knew it meant moon before and wasn't an acronym/initialism.
I am having a problem with some basic opengl texturing. I am using opentk and winforms.
I will shorten the code a but but basicly this is where my glControl load and draw functions :
[code]
private void glControl_Load(object sender, EventArgs e)
{
m_Loaded = true;
Application.Idle += new EventHandler(Application_Idle);
SetupViewport();
//Init
GL.ClearColor(Color.Black);
GL.Disable(EnableCap.CullFace);
GL.Enable(EnableCap.Texture2D);
//ImageScanner
m_ImageScanner = new ImageScanner(glControl.Width, glControl.Height);
}
void Application_Idle(object sender, EventArgs e)
{
glControl_Paint(null, null);
}
private void glControl_Paint(object sender, PaintEventArgs e)
{
if (!m_Loaded)
return;
GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);
GL.MatrixMode(MatrixMode.Modelview);
m_ImageScanner.Draw();
glControl.SwapBuffers();
}
[/code]
(
I set up a basic orthographic viewport for 2d drawing. Image scanner loads and draws a image and is going to do some basic proccessing. To draw the image I made a image class :
[code]
public Image(string a_FilePath)
{
m_PosX = 0;
m_PosY = 0;
LoadImage(a_FilePath);
}
public void LoadImage(string a_Filepath)
{
m_Image = new Bitmap(a_Filepath);
BitmapData bmp_data = m_Image.LockBits(new Rectangle(0, 0, m_Image.Width, m_Image.Height), ImageLockMode.ReadOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
m_GLTextureID = GL.GenTexture();
GL.BindTexture(TextureTarget.Texture2D, m_GLTextureID);
GL.TexImage2D(TextureTarget.Texture2D, 0, PixelInternalFormat.Rgba, bmp_data.Width, bmp_data.Height, 0,
OpenTK.Graphics.OpenGL.PixelFormat.Bgra, PixelType.UnsignedByte, bmp_data.Scan0);
m_Image.UnlockBits(bmp_data);
}
public void Draw()
{
GL.LoadIdentity();
GL.BindTexture(TextureTarget.Texture2D, m_GLTextureID);
GL.Begin(BeginMode.Quads);
{
GL.TexCoord2(0.0f, 0.0f);
GL.Vertex2(0.0f, 0.0f);
GL.TexCoord2(1.0f, 0.0f);
GL.Vertex2(m_Image.Width, 0.0f);
GL.TexCoord2(1.0f, 1.0f);
GL.Vertex2(m_Image.Width, m_Image.Height);
GL.TexCoord2(0.0f, 1.0f);
GL.Vertex2(0.0, m_Image.Height);
}
GL.End();
}
[/code]
It is drawing but its pure white and not textured with the texture that is loaded. it draws the correct size so I know the image is being loaded.
[QUOTE=holocene;38339153][code]SELECT orders.id, orders.comments, orders.date, orders.status, orders.customerid, customers.firstname, customers.surname
FROM orders
INNER JOIN customers
ON orders.customerid=customers.id [b]OR orders.customerid = -1[/b][/code]
...?[/QUOTE]
I tried that, then I get the following result :
[img]https://dl.dropbox.com/u/3655572/sql_error.PNG[/img]
Which is basicly returning the order multiple times, I am trying some basic SQL but I seem to be horrible at it, sorry if i am missing obvious answers.
I'm writing a little experiment in Love2D (which is awesome). The problem is, I want to use the stencil buffer to make dynamic 2d shadows. It works as expected, except that in order to draw to the stencil buffer, I need to actually draw the polygons every draw call, which is expensive. I'd rather like to draw all the polygons once to a texture (Canvas), update this canvas when the light moves, and draw the canvas to the stencil buffer instead. But when I do that, it just draws a rectangle the size of the canvas to the stencil buffer instead, obscuring everything.
So, I got a bit frustrated and thought okay, I can do this with a pixel shader. I pass in the "stencil" canvas, and then check if the alpha of the pixel in the stencil buffer at the current position in the pixel shader is zero, if so then just return the correct color, if not then return 0,0,0,0 (basically, AND the stencil with everything else.) The problem is I have no idea how pixel shaders work. Here's my code:
[code]
extern Image mask;
vec4 effect(vec4 color, Image texture, vec2 texture_coords, vec2 pixel_coords)
{
vec4 maskcol = Texel(mask,texture_coords);
if(maskcol.a == 0.0)
{
vec4 temp = Texel(texture,texture_coords);
return temp;
} else
{
return vec4(0,0,0,0);
}
}
[/code]
What am I doing wrong? I'd rather not do this and just draw a canvas to the stencil buffer in the first place. Anyone know how I can do this? Thanks.
Shouldn't the number of vertices match the number of vertex coordinates in a .obj file?
The model I'm loading has 33496 vertices and 34000 texture coordinates.
[editline]value[/editline]
Oh wait, I'm guessing some of the vertex coordinates are shared.
Not really programming related, but this is probably the smartest subforum that I could ask...
How does this work?
[IMG]http://img803.imageshack.us/img803/3625/integrate.png[/IMG]
I don't even know where to start Googling for this one.
Please take pity on me, oh great mathmagicians.
[QUOTE=Kialtia;38347312]I tried that, then I get the following result :
[img]https://dl.dropbox.com/u/3655572/sql_error.PNG[/img]
Which is basicly returning the order multiple times, I am trying some basic SQL but I seem to be horrible at it, sorry if i am missing obvious answers.[/QUOTE]
Try
[code]SELECT orders.id, orders.comments, orders.date, orders.status, orders.customerid, customers.firstname, customers.surname
FROM orders
INNER JOIN customers
ON orders.customerid=customers.id OR orders.customerid = -1
DISTINCT orders.id[/code]
This will only show each order seperately, although there is a reason the same order is being showed multiple times. It's because the status is different per record.
I was just playing around in the IDE, trying to learn new skills. Here's what I came up with.
Anything that needs improving?
[cpp]
//{ Includes and namespace usage.
#include <iostream>
using namespace std; //}
//{ Declarations and privatization.
class Date {
private:
unsigned char *month, *day; short *year;
public:
bool check_month(unsigned char); bool check_day(unsigned char, unsigned char, short);
void shift_date(long);
bool set_month(unsigned char); bool set_day(unsigned char); bool set_year(short); bool set_date(unsigned char, unsigned char, short);
short get_month(); short get_day(); short get_year();
Date(); Date(unsigned char, unsigned char, short); ~Date(); }; //}
//{ Checks.
bool Date::check_month(unsigned char month) {
if ((month < 1) || (month > 12)) return 0;
return 1; }
bool Date::check_day(unsigned char month, unsigned char day, short year) {
if ((day < 1) || (day > 31)) return 0;
if ((month == 2) && (year % 4 != 0))
if (day > 28) return 0;
else if (day > 29) return 0;
if ((month == 4) || (month == 6) || (month == 9) || (month == 11))
if (day > 30) return 0;
return 1; } //}
//{ Add or subtract days. Contains algorithms swiped from the Internet.
void Date::shift_date(long days) {
//{ Calculate day number from date.
long temp_year = *year - 1900;
*month = (*month + 9) % 12;
temp_year = temp_year - (*month / 10);
long new_date_num = days +
(365 * temp_year) + (temp_year / 4) - (temp_year / 100) + (temp_year / 400) + (((*month * 306) + 5) / 10) + (*day - 1); //}
//{ Calculate date from day number.
temp_year = ((10000 * new_date_num) + 14780) / 3652425;
long ddd = new_date_num - ((365 * temp_year) + (temp_year / 4) - (temp_year / 100) + (temp_year / 400));
if (ddd < 0) {
--temp_year;
ddd = new_date_num - ((365 * temp_year) + (temp_year / 4) - (temp_year / 100) + (temp_year / 400)); }
long mi = ((100 * ddd) + 52) / 3060;
*month = ((mi + 2) % 12) + 1;
*year = temp_year + ((mi + 2) / 12) + 1900;
*day = ddd - (((mi * 306) + 5) / 10) + 1; //}
} //}
//{ Set values.
bool Date::set_month(unsigned char pending_month) {
if (check_month(pending_month)) {
*month = pending_month;
return 1; }
return 0; }
bool Date::set_day(unsigned char pending_day) {
if (check_day(*month, pending_day, *year)) {
*day = pending_day;
return 1; }
return 0; }
bool Date::set_year(short pending_year) {
if (check_day(*month, *day, pending_year)) {
*year = pending_year;
return 1; }
return 0; }
bool Date::set_date(unsigned char pending_month, unsigned char pending_day, short pending_year) {
if (check_month(pending_month) && check_day(pending_month, pending_day, pending_year)) {
*month = pending_month; *day = pending_day; *year = pending_year;
return 1; }
return 0; } //}
//{ Get values.
short Date::get_month() { return *month; }
short Date::get_day() { return *day; }
short Date::get_year() { return *year; }; //}
//{ Constructor and destructor.
Date::Date() {
*month = 0; *day = 0; *year = 0; }
Date::Date(unsigned char pending_month, unsigned char pending_day, short pending_year) {
month = new unsigned char; day = new unsigned char; year = new short;
*month = pending_month; *day = pending_day; *year = pending_year;
if (!(check_month(pending_month) && check_day(pending_month, pending_day, pending_year))) {
*month = 0; *day = 0; *year = 0; } }
Date::~Date() {
delete month, day, year; } //}
//{ Main body. Used for testing.
int main() {
Date date(2, 28, 1997); //Construction test.
date.shift_date(30); //Date shift test.
cout << "Set day to 32? " << (date.set_day(32) ? "true" : "false") << '\n'; //Set and check test.
cout << "Shifted date: " << date.get_month() << '/' << date.get_day() << '/' << date.get_year() << '\n'; //Get test.
return 0; } //}
[/cpp]
[QUOTE=Kialtia;38347312]I tried that, then I get the following result :
[img]https://dl.dropbox.com/u/3655572/sql_error.PNG[/img]
Which is basicly returning the order multiple times, I am trying some basic SQL but I seem to be horrible at it, sorry if i am missing obvious answers.[/QUOTE]
[url=http://www.codeproject.com/Articles/33052/Visual-Representation-of-SQL-Joins]LEFT JOIN[/url]? That will return everything from the left, but joins stuff on the right when there's a match. Also, a better practice would be using NULL to represent a non-existent customer rather than -1.
So I'm having a bit of trouble with a piece of Java. I've been looking at it for quite a while now and I just can't see where the problem is coming from. I am trying to iterate over an array of Hand objects containing a List of Card objects. Which as far as I know works going by earlier methods that do the exact same thing.
This method is meant to remove a Card from one hand and move it to another based on the Suit (an enumerated value). But for some reason throws a ConcurrentModificationException. This is the problem method;
[cpp]
public void q8() {
System.out.println("8. Give each Hand one Suit of Cards.");
for (Hand h : hands) {
// Get an Iterator for the current Hand.
Iterator<Card> it = h.iterator();
while (it.hasNext()) {
Card c = it.next();
it.remove();
// Check which Suit we are currently looking at.
switch (c.suit()) {
case CLUBS:
hands[0].add(c);
break;
case DIAMONDS:
hands[1].add(c);
break;
case HEARTS:
hands[2].add(c);
break;
case SPADES:
hands[3].add(c);
break;
}
}
System.out.println(h);
}
}
[/cpp]
I'm calling it through Reflection so I can call the other methods and ask the user to continue. And I have no idea how to get a more detailed Stack Trace out of the InvocationTargetException other than the exception thrown is a ConcurrentModificationException. I'm not using threads anywhere in the program, and all the help I found seems to relate to threads.
Any ideas?
[editline]Edited:[/editline]
Fixed it! I just removed the for...each loop in favour of a for loop, allowing me to check if I am currently iterating over the hand I want to modify, meaning I shouldn't need to modify it anyway, and stopping the error!
[cpp]
public void q8() {
System.out.println("8. Give each Hand one Suit of Cards.");
for (int i = 0; i < hands.length; i++) {
// Get an Iterator for the current Hand.
Iterator<Card> it = hands[i].iterator();
while (it.hasNext()) {
Card c = it.next();
// Check which Suit we are currently looking at.
switch (c.suit()) {
case CLUBS:
if (i != 0) {
hands[0].add(c);
it.remove():
}
break;
....
}
}
}
[/cpp]
This only converts the first value in the array from hex to decimal correctly then it sets the others to the save value as the first, must be missing something obvious but cant figure out what :/
[code]
void ConvertToDecimal(const vector<string> &in, vector<int> &out)
{
stringstream sstrm;
int o;
for(int i = 0; i < in.size(); i++)
{
sstrm << hex << in[i];
sstrm >> o;
out.push_back(o);
}
}
[/code]
[QUOTE=eternalflamez;38354824]Try
[code]SELECT orders.id, orders.comments, orders.date, orders.status, orders.customerid, customers.firstname, customers.surname
FROM orders
INNER JOIN customers
ON orders.customerid=customers.id OR orders.customerid = -1
DISTINCT orders.id[/code]
This will only show each order seperately, although there is a reason the same order is being showed multiple times. It's because the status is different per record.[/QUOTE]
[QUOTE=SteveUK;38354910][URL="http://www.codeproject.com/Articles/33052/Visual-Representation-of-SQL-Joins"]LEFT JOIN[/URL]? That will return everything from the left, but joins stuff on the right when there's a match. Also, a better practice would be using NULL to represent a non-existent customer rather than -1.[/QUOTE]
Thanks, both of you, I've finally fixed it, I've also altered the database to use NULL instead of -1.
[QUOTE=elevate;38354890]I was just playing around in the IDE, trying to learn new skills. Here's what I came up with.
Anything that needs improving?
snip[/QUOTE]
It seems fine, I can't actually read your shift_day code, but this is bugged:
[cpp] if ((month == 2) && (year % 4 != 0))
if (day > 28) return 0;
else if (day > 29) return 0;[/cpp]
This may not perform as indented. Use brackets around nested if statements like this, and your indention is off. Assuming you meant to write this:
[cpp] if ((month == 2) && (year % 4 != 0))
{
if (day > 28)
return 0;
}
else if (day > 29)
{
return 0;
}[/cpp]
Either way your code is still broken on this line:
[cpp]if ((month == 2) && (year % 4 != 0))[/cpp]
As of the switch to the Gregorian calender, the rule goes as follows:
[quote]Every year that is exactly divisible by four is a leap year, [B]except for years that are exactly divisible by 100; the centurial years that are exactly divisible by 400 are still leap years[/B]. For example, the year 1900 is not a leap year; the year 2000 is a leap year.[/quote]
- [url=https://en.wikipedia.org/wiki/Gregorian_calendar]Wikipedia[/url]
Could anyone look at my problem that I posted a couple of posts before. Still can't get it to draw :(
Also:
[QUOTE=elevate;38354890][cpp]
long new_date_num = days +
(365 * temp_year) + (temp_year / 4) - (temp_year / 100) + (temp_year / 400) + (((*month * 306) + 5) / 10) + (*day - 1); //}
//{ Calculate date from day number.
temp_year = ((10000 * new_date_num) + 14780) / 3652425;
long ddd = new_date_num - ((365 * temp_year) + (temp_year / 4) - (temp_year / 100) + (temp_year / 400));
if (ddd < 0) {
--temp_year;
ddd = new_date_num - ((365 * temp_year) + (temp_year / 4) - (temp_year / 100) + (temp_year / 400)); }[/cpp][/QUOTE]
This assumes a year is 365 days (which it is not always).
[QUOTE=elevate;38354890][cpp]//{ Constructor and destructor.
Date::Date() {
*month = 0; *day = 0; *year = 0; }[/cpp][/QUOTE]
You didn't create month, day or year so you're writing to random memory.
[QUOTE=elevate;38354890][cpp]Date::~Date() {
delete month, day, year; } //}[/cpp][/QUOTE]
Delete doesn't do multiple deletes. This will only delete month.
[QUOTE=Jookia;38367392]Delete doesn't do multiple deletes. This will only delete month.[/QUOTE]
Yeah, this is a prime example of not knowing what the comma actually does. In this case (and in any case besides variable declaration), it will evaluate each expression and return the last one.
So this code (delete month, day, year;) literally says:
Evaluate "delete month"
Evaluate "day" but don't do anything with the value
Evaluate "year" and assign its value to the L-value (which doesn't exist in this statement)
[QUOTE=ShaunOfTheLive;38373816]Yeah, this is a prime example of not knowing what the comma actually does. In this case (and in any case besides variable declaration), it will evaluate each expression and return the last one.
So this code (delete month, day, year;) literally says:
Evaluate "delete month"
Evaluate "day" but don't do anything with the value
Evaluate "year" and assign its value to the L-value (which doesn't exist in this statement)[/QUOTE]
the real crime here is that delete is an expression rather than a statement
I am trying to recreate .net terrarium: [url]http://terrarium2.codeplex.com/[/url]
In java.
Could somebody point me to where I could learn more about changing the viewport in lwjgl so I can have a HUD/GUI around it. I can create a window and draw stuff, but I just want to change the viewport size/location. What should I do?
[cpp]// HEADER.hpp
template <class T>
class Fgsd
{
public:
Fgsd();
};[/cpp]
[cpp]// SOURCE.cpp
#include "HEADER.hpp"
template<class T>
Fgsd<T>::Fgsd() { };[/cpp]
Using the constructor results in a linker error.
Presumably this is caused by some odd combination of compilation/template resolution order, because it's fixed either by getting rid of templates or placing the constructor in the header file.
However it's stupid. Is it an universal quirk with all compilers, or is VC just being VC? And are there good ways to fix it while retaining separation of header and source code?
templates go in header files
[editline]9th November 2012[/editline]
<3 c++
[QUOTE=ThePuska;38381736]However it's stupid. Is it an universal quirk with all compilers, or is VC just being VC? And are there good ways to fix it while retaining separation of header and source code?[/QUOTE]
Yes, no, no.
This isn't some quirk to MSVC, this is how it works in all compilers, and is pretty much the only sane way to actually implement templates.
Does anyone have resources on how to generate perlin noise? I think I get the idea of how it works, but it would be nice to have it more clearly laid out.
[editline]9th November 2012[/editline]
Simplex noise works, too, but I think that Perlin is easier as far as I know.
[editline]9th November 2012[/editline]
Also, I use python but I should be able to understand just about any language as long as it's well commented or clear.
Yeah, I could give you a good implementation of it in c++. I'll have access to my laptop tonight, I'll pm you then.
Sorry, you need to Log In to post a reply to this thread.