Jump to content

  • Log In with Google      Sign In   
  • Create Account


pandaraf

Member Since 18 Apr 2012
Offline Last Active Jul 01 2012 07:43 PM

Topics I've Started

Need Help : How to make buttons in SDL_opengl?

21 June 2012 - 06:43 PM

How to make buttons in SDL_opengl?

When i'm using SDL and use BlitSurface to make button, it's work! But, currently i'm using SDL_opengl, How can i make buttons in SDL_opengl?
SDL_BlitSurface isn't work in SDL_OpenGL.

Any Help? :)

[ask][SDL_opengl] How to use SDL_BlitSurface to make Button

19 June 2012 - 10:29 PM

Hi, i want to make buttons like Lazyfoo has : http://lazyfoo.net/S...son09/index.php
It use SDL_BlitSurface, i try that and work! But, actually i use SDL_opengl for the project. So, i can't use syntax like : "apply_surface( box.x, box.y, buttonSheet, screen, clip )" again. Posted Image

I use this :
"void muncul(int x, int y, int x2, int y2, int x3, int y3, int x4, int y4, GLuint xyz)" that work for show texture correctly. Of course, its only image that appeared. Not like buttons that has mouse_over, mouse_up, mouse_down and mouse_out(like lazyfoo). Posted Image

I want to make buttons in SDL_opengl Posted Image
So, How to use SDL_BlitSurface to make Button in SDL_opengl?

Need Help : SDL_FreeSurface doesn't work?

18 April 2012 - 08:54 PM

This is the code for the SDL_FreeSurface :

inside int main :
Uint32 start = 0;
bool running = true;
start = SDL_GetTicks();
and
while(QUIT==false){
if( running == true ) {
   std::stringstream time;
   time << "Timer: " << SDL_GetTicks() - start;
   seconds = TTF_RenderText_Solid( font, time.str().c_str(), black );
   apply_surface(( SCREEN_WIDTH - seconds->w ) / 2, 100, seconds, SCREEN );
  //This line :  
   SDL_FreeSurface( seconds );
  }

and this is what the screens say :

SDL FreeSurface error


The text appear without erasing the previous surface.

Any suggest? Posted Image

Need Help : error: syntax error before `*' token

18 April 2012 - 09:41 AM

Until this topic posted, i didn't found the solution. This thing made me told there's something wrong in the MinGW Developer Studio. Or perharps, it's only my depression Posted Image .

This is the codes i wrote :
//music
Mix_Music *music = NULL
//additional musics
Mix_Chunk *muks = NULL;
Mix_Chunk *music2 = NULL;
Mix_Chunk *music3 = NULL;
Mix_Chunk *music4 = NULL;

and

void clean() {
Mix_HaltMusic();
Mix_FreeMusic( music );
Mix_FreeChunk( muks );
Mix_FreeChunk( music2 );
Mix_FreeChunk( music3 );
Mix_FreeChunk( music4 );
Mix_CloseAudio();

and

bool load_files() {
music = Mix_LoadMUS( "vq.wav" );
if( music == NULL ) { return false; }

muks = Mix_LoadWAV( "01.wav" );
music2 = Mix_LoadWAV( "02.wav" );
music3 = Mix_LoadWAV( "03.wav" );
music4 = Mix_LoadWAV( "04.wav" );
if( ( muks == NULL ) || (music2 == NULL ) || (music3 == NULL ) || (music4 == NULL ) ) { return false; }

then, the error was :
--------------------Configuration: my project - Debug--------------------
Compiling...
ini.cpp
ini.cpp:21: error: syntax error before `*' token
ini.cpp: In function `bool load_files()':
ini.cpp:223: error: `muks' undeclared (first use this function)
ini.cpp:223: error: (Each undeclared identifier is reported only once for each
function it appears in.)
ini.o - 3 error(s), 0 warning(s)

any suggest? Posted Image

PARTNERS