Conversion from VC++ to VB, please help
I am trying to convert VC++ code to VB. I hope you don't mind to help me out with this. The problem I have is that VB did not run through the codes between for and next like it skipped all of it. I stopped at "glEnd" and checked the numbers in variables and found that it didnt do the counting work.
Waldoo
I posted the full paragraph code just for in case if you want to review it.
================================================================
VC++ Code:
const double DTR = 3.141593 / 180;
const int inc = 5;
float red = 0.0f, green = 0.0f, blue = 0.0f;
int reda = 1, greena = 1, bluea = 1;
glTranslatef(0.0f, 0.0f, -5.0f);
glBegin(GL_TRIANGLE_FAN);
glColor3f(0.0f, 0.0f, 0.0f);
glVertex3f(0.0f, 0.0f, 0.0f);
for(int i = 0; i <= 360; i+= inc)
{
glColor3f(reda*red, greena*green, bluea*blue);
red += (inc/(float)360)*3;
if(red > 1.0f)
reda = 0;
if(reda == 0)
green += (inc/(float)360)*3;
if(green > 1.0f)
greena = 0;
if(reda == 0 && greena == 0)
blue += (inc/(float)360)*3;
glVertex3f(cos(i*DTR), sin(i*DTR), 0);
}
glEnd();
================================================================
VB Code: (I hope I did the most right:-)
Private Const DTR = 3.141593 / 180
Private Const inc = 5
Public Function DrawGLScene() As Boolean
' Here's Where We Do All The Drawing
Dim Red As Integer: Red = 0
Dim Green As Integer: Green = 0
Dim Blue As Integer: Blue = 0
Dim Reda As Integer: Reda = 1
Dim Greena As Integer: Greena = 1
Dim Bluea As Integer: Bluea = 1
Dim I As Integer
Dim float As Integer
glClear clrColorBufferBit Or clrDepthBufferBit
glLoadIdentity ' Reset The Current Matrix
glTranslatef 0#, 0#, -5# ' Move Into The Screen 5 Units
glRotatef xrot, 1#, 0#, 0# ' Rotate On The X Axis
glRotatef yrot, 0#, 1#, 0# ' Rotate On The Y Axis
glRotatef zrot, 0#, 0#, 1# ' Rotate On The Z Axis
glBegin (bmTriangleFan)
glColor3f 0#, 0#, 0#
glVertex3f 0#, 0#, 0#
For I = 0 To 360 Step Inc
glColor3f (Reda * Red), (Greena * Green), (Bluea * Blue)
Red = Red + (inc / 360) * 3
If Red = 1# Then
Reda = 0
End If
If Reda = 0 Then
Green = Green + (inc / 360) * 3
End If
If Green > 1# Then
Greena = 0
End If
If Reda = 0 And Greena = 0 Then
Blue = Blue + (inc / 360) * 3
End If
glVertex3f Cos(I * DTR), Sin(I * DTR), 0
Next I
glEnd
xrot = xrot + 0.3 ' X Axis Rotation
yrot = yrot + 0.2 ' Y Axis Rotation
zrot = zrot + 0.4 ' Z Axis Rotation
DrawGLScene = True ' Keep Going
End Function
Edited by - waldoo on April 2, 2002 6:16:13 AM
Im curious...If you port from C++ to VB you know C++ right?...why even use VB?
______________________________Only dead fish go with the main-stream.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement