c++ gl question

This is a discussion on c++ gl question within the C++ Programming forums, part of the General Programming Boards category; Quick question. Is there a way to pass an int in c++ into a openGL function that is looking for ...

  1. #1
    Registered User
    Join Date
    Sep 2006
    Posts
    10

    c++ gl question

    Quick question.

    Is there a way to pass an int in c++ into a openGL function that is looking for a GLint??

    example I am trying to pass an int to

    Code:
    glVertex4iv(faces.at(faceLoop));
    Where faces is a vector of ints and faceLoop is an integer.

  2. #2
    Devil's Advocate SlyMaelstrom's Avatar
    Join Date
    May 2004
    Location
    Out of scope
    Posts
    4,069
    I'm pretty sure GLints and GLfloats are just typedef's for ints and floats. You can pass an int where it expect a GLint and you can pass a float where it expects a GLfloat (and so on with other OpenGL types). I could be wrong though. If just passing it doesn't work, then perhaps try casting it.
    Code:
    glVertex4iv((GLint)faces.at(faceLoop));
    Last edited by SlyMaelstrom; 09-24-2006 at 08:04 PM.
    Sent from my iPadŽ

  3. #3
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,046
    If you don't have the prototype for that function (ie, the right header file) then it might not have an implicit cast.
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

  4. #4
    Registered User Tonto's Avatar
    Join Date
    Jun 2005
    Location
    New York
    Posts
    1,465
    glVertex4iv takes an array. Lucky you, vector memory is guaranteed to be contiguous. 100% guaranteed mofckyug, you hear dat?!

    Code:
    glVertex4iv(&faces.at(0));
    glVertex4iv(&faces[0]);
    glVertex4iv(faces.begin());
    Or if the 4 ints you want to pass are not at the start of the vector

    Code:
    glVertex4iv(&faces.at(index));
    glVertex4iv(&faces[index]);
    glVertex4iv(faces.begin() + index);

    ╔╗╔╦══╦╗╔╦══╦╗
    ║╚╝║╔╗║╚╝║╔╗║║
    ║╔╗║╠╣║╔╗║╠╣╠╣
    ╚╝╚╩╝╚╩╝╚╩╝╚╩╝

    codez http://code.google.com/p/zxcvbn/

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Debugging question
    By o_0 in forum C Programming
    Replies: 9
    Last Post: 10-10-2004, 05:51 PM
  2. Open GL Question
    By lrusso in forum C++ Programming
    Replies: 2
    Last Post: 08-01-2004, 11:49 PM
  3. problem with open gl engine.
    By gell10 in forum Game Programming
    Replies: 1
    Last Post: 08-21-2003, 04:10 AM
  4. Question...
    By TechWins in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 07-28-2003, 09:47 PM
  5. Question, question!
    By oskilian in forum A Brief History of Cprogramming.com
    Replies: 5
    Last Post: 12-24-2001, 12:47 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21