In the [b]first[/b] snippet you have an array of u8 ([b]not u8 pointers[/b]), in the [b]second[/b] you have an array of [b]u8 pointers[/b].
[QUOTE=ZeekyHBomb;21650109]I meant instead of all the other stuff.
Also get rid of identification[0] = 1; and so on.[/QUOTE]
I did. also, identification[0] = 1; is setting the first element equal to one.
It's not working for initialization though. For initialization of arrays you have to do like
int identification[] = {1, 2, 4, 7, 42};
If it still errors, just do it in the constructor.
[QUOTE=ZeekyHBomb;21713566]In the [b]first[/b] snippet you have an array of u8 ([b]not u8 pointers[/b]), in the [b]second[/b] you have an array of [b]u8 pointers[/b].[/QUOTE]
Okay, thank you for getting me somewhere.
So essentially, is what I'm wanting an array of pointers to arrays?
Anyway, my current array is now:
[code]u8 (*pl)[] = {
&foo,
&bar
};[/code]
I get "error : scalar object 'pl' requires one element in initializer" when compiling.
The code in your second snippet was correct. The first snippet is the wrong one.
@raccoon12: Make sure the compiled dlls copy alright. VS seems to have a habit in Source not to copy them after a build for some people.
[QUOTE=ZeekyHBomb;21729983]The code in your second snippet was correct. The first snippet is the wrong one.[/QUOTE]
Oh, looks like there's been a misunderstanding.
The first snippet I gave when asking had variables (which I now realised are arrays) I wanted to have pointers to in another array, the second snippet was my attempt at the array
Is there anything similar to View from SFML in OpenGL? Currently I'm using this code to move the "camera":
[cpp] Gl.glMatrixMode(Gl.GL_PROJECTION);
Gl.glLoadIdentity();
Gl.glOrtho(CameraX, CameraX + 800, 600, 0, 0, 1);
CameraX--;
Gl.glMatrixMode(Gl.GL_MODELVIEW);[/cpp]
But it's very slow (I expected it to be, it doesn't look like the correct way to do it)
What do you mean by "it's very slow"?
I mean, I was stupid enough to leave VSync on...
Now it moves at 2500FPS (while moving the camera every frame). Is that good or am I doing something wrong?
[QUOTE=a2h;21730000]Oh, looks like there's been a misunderstanding.
The first snippet I gave when asking had variables (which I now realised are arrays) I wanted to have pointers to in another array, the second snippet was my attempt at the array[/QUOTE]
Well, then there's no real harm in copying them, because C-style arrays are simply just a pointer. So simply have an array of pointers, like
[cpp]u8 foo[] = { ... };
u8 bar[] = { ... };
const u8 *pl[] = { foo, bar };[/cpp]
[media]http://www.youtube.com/watch?v=lu-Pv-AlSa0[/media]
give it time, just uploaded it, needs time for more quality
I'm making a little test program, and I have 4 radiobuttons. I want to make button1 disabled until one of the radiobuttons is clicked, but I don't want any of the buttons to start off checked.
So to start, I made a timer that checks every 100 milliseconds if any of the buttons are checked, and it any of them are then the button is enabled:
[cpp]
private void timer1_Tick(object sender, EventArgs e)
{
if(radioButton1.Checked)
{
button1.Enabled = true;
}
if (radioButton2.Checked)
{
button1.Enabled = true;
}
if (radioButton3.Checked)
{
button1.Enabled = true;
}
if (radioButton4.Checked)
{
button1.Enabled = true;
}
}
[/cpp]
And I set the button to disabled in the form designer. I also made sure none of the radiobuttons are checked in the form designer, but the first one always starts out checked. Can someone help?
Radiobuttons always have one selected.
Is there a way to stop that though?
[QUOTE=Chad Mobile;21744885]Is there a way to stop that though?[/QUOTE]
Like I said, one will always be checked.
[editline]08:19PM[/editline]
[Unless you figure out how to override it.]
Fuck. We were doing testing on the computers at school, and the program we were using had multiple choice using radiobuttons, and none were checked in the beginning. And the button was un-clickable until one was selected, so I wanted to try this.
You could always use check boxes instead of radio boxes. :P
But I'm trying to make a multiple choice question test. :P
That's what check boxes [i]are[/i].
But you can check more than one at a time. :P I'll just make it so only one can be selected a time. :razz:
[B]Edit:[/B] I did it :v:
[cpp]
private void timer1_Tick(object sender, EventArgs e)
{
if (checkBox3.Checked == false && checkBox2.Checked == false && checkBox1.Checked == false && checkBox4.Checked == false)
{
button1.Enabled = false;
}
}
[/cpp]
[cpp]
private void checkBox1_Click(object sender, EventArgs e)
{
checkBox2.Checked = false;
checkBox3.Checked = false;
checkBox4.Checked = false;
button1.Enabled = true;
}
private void checkBox2_Click(object sender, EventArgs e)
{
checkBox1.Checked = false;
checkBox3.Checked = false;
checkBox4.Checked = false;
button1.Enabled = true;
}
private void checkBox3_Click(object sender, EventArgs e)
{
checkBox1.Checked = false;
checkBox2.Checked = false;
checkBox4.Checked = false;
button1.Enabled = true;
}
private void checkBox4_Click(object sender, EventArgs e)
{
checkBox1.Checked = false;
checkBox2.Checked = false;
checkBox3.Checked = false;
button1.Enabled = true;
}
[/cpp]
[QUOTE=Chad Mobile;21745277]But I'm trying to make a multiple choice question test. :P[/QUOTE]
[QUOTE=Chad Mobile;21745694]But you can check more than one at a time. :P I'll just make it so only one can be selected a time.[/QUOTE]
?
I think he meant multiple choice as in, you have multiple answers to choose from but his program was allowing more than one check at a time, so he's making it only one at a time ?
I think that is what he was trying to get across.
He's basically made a set of checkboxes into radiobuttons, but meaning they don't start with anything checked
Multiple choice means A, B, C, D, pick one.
I don't know what multiple choice means where you guys come from.
[QUOTE=Chad Mobile;21745694]But you can check more than one at a time. :P I'll just make it so only one can be selected a time. :razz:
[B]Edit:[/B] I did it :v:
-code snip-
-ugly code snip-[/QUOTE]
Don't use a Tick event. Start out disabled, enable on box check and disable again on uncheck.
You should really also just use a collection of checkboxes and hook their events to the same method, that would scale a lot better. (The checkbox in question would be contained in the 'sender' argument, which you can downcast.)
Too late, I did it with check boxes and it works great. :v:
How can I rotate the camera around a point in OpenGL while centering on that same point.
I currently have this and it's failing miserably.
[cpp] public static void Update() {
if (Position != lastPoint) MoveCamera();
if (Rotation != lastRotation) RotateCamera();
}
static void MoveCamera() {
Gl.glMatrixMode(Gl.GL_MODELVIEW);
Gl.glTranslatef(-(Position.X - lastPoint.X), -(Position.Y - lastPoint.Y), 0);
lastPoint = Position;
}
static void RotateCamera() {
float distance = Geometry.Distance(Point.Zero, Position);
Gl.glMatrixMode(Gl.GL_MODELVIEW);
Gl.glRotatef(-Rotation, 0, 0, 1);
Gl.glTranslatef(-100, -100, 0);
Gl.glRotatef(Rotation - lastRotation, 0, 0, 1);
Gl.glTranslatef(100, 100, 0);
lastRotation = Rotation;
}
public static void CenterOn(Point point) {
Position = point - new Point(width / 2, height / 2);
}[/cpp]
Update is called every frame.
I also call CenterOn every time the object I want to center on and rotate around is moved.
[editline]12:46AM[/editline]
Position is the top left corner of the "camera"
[cpp]#include "stdafx.h"
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
void outlineFile( int, char, char, double );
int getaccount( const char * const );
int main()
{
ifstream inGradeFile( "grades.tst", ios::in );
ifstream inDBFile( "idlog.tst", ios::in );
ifstream inClass1( "CmpPro.gra", ios::in );
ifstream inClass2( "CmpSci.gra", ios::in );
ifstream inClass3( "CmpNet.gra", ios::in );
ifstream inClasslist( "Classlist.tst", ios::in );
if( !inGradeFile )
ofstream outGradeFile( "grades.tst", ios::out | ios::binary );
if( !inDBFile )
ofstream outDBFile( "idlog.tst", ios::out | ios::binary );
if( !inClass1 )
ofstream outClass1( "CmpPro.gra", ios::out | ios::binary );
if( !inClass2)
ofstream outClass2( "CmpSci.gra", ios::out | ios::binary );
if(!inClass3)
ofstream outClass2( "CmpNet.gra", ios::out | ios::binary );
if(!inClasslist)
ofstream outClass2( "Classlist.tst", ios::out | ios::binary );
int INPUT;
cout << "Welcome to Darkrei9n's (Also known as Suicidejeep) gradebook application." << endl << "Please enter the number of section you wish to visit" << endl;
cin >> INPUT;
int idnum;
char lastname;
char firstname;
double grade;
int className;
int test;
if( INPUT == 1)
{
void displaymessage();
cout << "Welcome to the grades section, please choose a class, for a class ID list type 0, after it is done listing the classes it will ask you for the class, write the ID not the class name." << endl;
cin >> test;
if(test == 0)
{
cout << endl << "000001 - Computer Programming" << endl << "000002 - Computer Science" << endl << "000003 - Computer Networking" << endl << "You may now choose a class" << endl;
cin >> className;
if( className = 000001)
{
while( inClass1 >> idnum >> lastname >> firstname >> grade )
outlineFile( idnum, lastname, firstname, grade );
}
}
}
}[/cpp]
Whenever I try to compile it gives me something about the linker.
1>gradebook.obj : error LNK2019: unresolved external symbol "void __cdecl outlineFile(int,char,char,double)" (?outlineFile@@YAXHDDN@Z) referenced in function _main
This is the error.
The whole thing is just... what are you trying to do?
The error refers to outlineFile being declared (near top) but never defined.
Sorry, you need to Log In to post a reply to this thread.